Where to put web scrape logic in MVC The Next CEO of Stack OverflowWhat are MVP and MVC and what is the difference?Fat models, skinny controllers and the MVC design patternWhat is the difference between MVC and MVVM?What goes into the “Controller” in “MVC”?How to structure an enterprise MVC app, and where does Business Logic go?Where does the “business logic layer” fit in to an MVC application?Proper place to put logic in MVCWhere to put validation logic in MVC software architectureMVC: Where to put business logic?Where we put validation logic in nodeJs MVC?

What is the difference between 'contrib' and 'non-free' packages repositories?

Creating a script with console commands

Could a dragon use its wings to swim?

Raspberry pi 3 B with Ubuntu 18.04 server arm64: what pi version

How does a dynamic QR code work?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

How to show a landlord what we have in savings?

"Eavesdropping" vs "Listen in on"

Finitely generated matrix groups whose eigenvalues are all algebraic

Is the offspring between a demon and a celestial possible? If so what is it called and is it in a book somewhere?

Why did early computer designers eschew integers?

Compilation of a 2d array and a 1d array

Ising model simulation

Calculating discount not working

Why does freezing point matter when picking cooler ice packs?

What happens if you break a law in another country outside of that country?

Which acid/base does a strong base/acid react when added to a buffer solution?

Prodigo = pro + ago?

Is this a new Fibonacci Identity?

Is it correct to say moon starry nights?

Man transported from Alternate World into ours by a Neutrino Detector

Find a path from s to t using as few red nodes as possible

How dangerous is XSS

That's an odd coin - I wonder why



Where to put web scrape logic in MVC



The Next CEO of Stack OverflowWhat are MVP and MVC and what is the difference?Fat models, skinny controllers and the MVC design patternWhat is the difference between MVC and MVVM?What goes into the “Controller” in “MVC”?How to structure an enterprise MVC app, and where does Business Logic go?Where does the “business logic layer” fit in to an MVC application?Proper place to put logic in MVCWhere to put validation logic in MVC software architectureMVC: Where to put business logic?Where we put validation logic in nodeJs MVC?










1















I'm building a .NET Core MVC application. It has a single endpoint that retrieves an imdb id of a movie by scraping the imdb site. So my question is, where do I put the logic to get the id? My original project structure is shown below.



+--Controller
+--Entry point api call
+--Logic
+--Class that retrieves imdbId
+--Models
+--Models
+--Context


So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller. I was also going to instantiate the model and store it in the DB here. I also do request validation in the controller and make sure the given movie title and release year are correct format.



I'm starting to think this is incorrect though? Should I put request validation and id retrieval in the model layer? Any help on how to approach this would be appreciated.










share|improve this question


























    1















    I'm building a .NET Core MVC application. It has a single endpoint that retrieves an imdb id of a movie by scraping the imdb site. So my question is, where do I put the logic to get the id? My original project structure is shown below.



    +--Controller
    +--Entry point api call
    +--Logic
    +--Class that retrieves imdbId
    +--Models
    +--Models
    +--Context


    So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller. I was also going to instantiate the model and store it in the DB here. I also do request validation in the controller and make sure the given movie title and release year are correct format.



    I'm starting to think this is incorrect though? Should I put request validation and id retrieval in the model layer? Any help on how to approach this would be appreciated.










    share|improve this question
























      1












      1








      1








      I'm building a .NET Core MVC application. It has a single endpoint that retrieves an imdb id of a movie by scraping the imdb site. So my question is, where do I put the logic to get the id? My original project structure is shown below.



      +--Controller
      +--Entry point api call
      +--Logic
      +--Class that retrieves imdbId
      +--Models
      +--Models
      +--Context


      So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller. I was also going to instantiate the model and store it in the DB here. I also do request validation in the controller and make sure the given movie title and release year are correct format.



      I'm starting to think this is incorrect though? Should I put request validation and id retrieval in the model layer? Any help on how to approach this would be appreciated.










      share|improve this question














      I'm building a .NET Core MVC application. It has a single endpoint that retrieves an imdb id of a movie by scraping the imdb site. So my question is, where do I put the logic to get the id? My original project structure is shown below.



      +--Controller
      +--Entry point api call
      +--Logic
      +--Class that retrieves imdbId
      +--Models
      +--Models
      +--Context


      So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller. I was also going to instantiate the model and store it in the DB here. I also do request validation in the controller and make sure the given movie title and release year are correct format.



      I'm starting to think this is incorrect though? Should I put request validation and id retrieval in the model layer? Any help on how to approach this would be appreciated.







      asp.net-core model-view-controller






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 19:45









      user3736114user3736114

      8718




      8718






















          2 Answers
          2






          active

          oldest

          votes


















          2















          So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller.




          This is what I would do too. ID retrieval is not a concern of the controller (the presentation layer does not care how you retrieve the ID) so it should be placed in a separate layer.




          Should I put request validation and id retrieval in the model layer?




          No, because this does not pertain to the models. The model layer should just contain the classes for your models. I would put request validation in the controller (presentation layer).



          My suggestion is that your original project structure works fine. Within the logic layer, I would further separate concerns among different services, so that the ID retrieval functionality would reside in a separate service from the DB storage functionality (DB management could also be a separate layer on its own).






          share|improve this answer






























            1














            I would suggest you put it in the Logic class, so you can unit test the logic outside of the model. Your models should be super simple, just properties, and if there is some other internal logic they need.



            The http call you will need to make I would put in your logic and ensure you are using some interface for your http client so you can create moqs for easier unit testing.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051720%2fwhere-to-put-web-scrape-logic-in-mvc%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2















              So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller.




              This is what I would do too. ID retrieval is not a concern of the controller (the presentation layer does not care how you retrieve the ID) so it should be placed in a separate layer.




              Should I put request validation and id retrieval in the model layer?




              No, because this does not pertain to the models. The model layer should just contain the classes for your models. I would put request validation in the controller (presentation layer).



              My suggestion is that your original project structure works fine. Within the logic layer, I would further separate concerns among different services, so that the ID retrieval functionality would reside in a separate service from the DB storage functionality (DB management could also be a separate layer on its own).






              share|improve this answer



























                2















                So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller.




                This is what I would do too. ID retrieval is not a concern of the controller (the presentation layer does not care how you retrieve the ID) so it should be placed in a separate layer.




                Should I put request validation and id retrieval in the model layer?




                No, because this does not pertain to the models. The model layer should just contain the classes for your models. I would put request validation in the controller (presentation layer).



                My suggestion is that your original project structure works fine. Within the logic layer, I would further separate concerns among different services, so that the ID retrieval functionality would reside in a separate service from the DB storage functionality (DB management could also be a separate layer on its own).






                share|improve this answer

























                  2












                  2








                  2








                  So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller.




                  This is what I would do too. ID retrieval is not a concern of the controller (the presentation layer does not care how you retrieve the ID) so it should be placed in a separate layer.




                  Should I put request validation and id retrieval in the model layer?




                  No, because this does not pertain to the models. The model layer should just contain the classes for your models. I would put request validation in the controller (presentation layer).



                  My suggestion is that your original project structure works fine. Within the logic layer, I would further separate concerns among different services, so that the ID retrieval functionality would reside in a separate service from the DB storage functionality (DB management could also be a separate layer on its own).






                  share|improve this answer














                  So I was originally going to put the logic where it retrieves the id in the "Logic" folder and call it from the Controller.




                  This is what I would do too. ID retrieval is not a concern of the controller (the presentation layer does not care how you retrieve the ID) so it should be placed in a separate layer.




                  Should I put request validation and id retrieval in the model layer?




                  No, because this does not pertain to the models. The model layer should just contain the classes for your models. I would put request validation in the controller (presentation layer).



                  My suggestion is that your original project structure works fine. Within the logic layer, I would further separate concerns among different services, so that the ID retrieval functionality would reside in a separate service from the DB storage functionality (DB management could also be a separate layer on its own).







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 20:36









                  MarioMendietaMarioMendieta

                  1859




                  1859























                      1














                      I would suggest you put it in the Logic class, so you can unit test the logic outside of the model. Your models should be super simple, just properties, and if there is some other internal logic they need.



                      The http call you will need to make I would put in your logic and ensure you are using some interface for your http client so you can create moqs for easier unit testing.






                      share|improve this answer



























                        1














                        I would suggest you put it in the Logic class, so you can unit test the logic outside of the model. Your models should be super simple, just properties, and if there is some other internal logic they need.



                        The http call you will need to make I would put in your logic and ensure you are using some interface for your http client so you can create moqs for easier unit testing.






                        share|improve this answer

























                          1












                          1








                          1







                          I would suggest you put it in the Logic class, so you can unit test the logic outside of the model. Your models should be super simple, just properties, and if there is some other internal logic they need.



                          The http call you will need to make I would put in your logic and ensure you are using some interface for your http client so you can create moqs for easier unit testing.






                          share|improve this answer













                          I would suggest you put it in the Logic class, so you can unit test the logic outside of the model. Your models should be super simple, just properties, and if there is some other internal logic they need.



                          The http call you will need to make I would put in your logic and ensure you are using some interface for your http client so you can create moqs for easier unit testing.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 7 at 20:24









                          DeadlyChambersDeadlyChambers

                          2,76332949




                          2,76332949



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051720%2fwhere-to-put-web-scrape-logic-in-mvc%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              1928 у кіно

                              Захаров Федір Захарович

                              Ель Греко