Multi-Tier ASP.NET MVC Application

I am starting my first serious ASP.NET MVC application and I need someone to explain to me how to fold it correctly. (all the applications that I have created so far, where I only tested the applications, and I did not care about stratifying it correctly)

I spent some time searching the Internet, for example, from a properly imposed MVC application, but all topics where either are incomplete or just tons of text without a real example.

Let's say I have an e-commerce site (any other example will be fine), can someone write me an example of how you structure this application (for example, when a user buys a product)

What would your interfaces and classes look like , where would you place them , where would you place classes to retrieve data from a database, etc. I do not need the implementation of these classes only by their position of the name, function or properties that they store.

for instance

IProduct → interface in the second project (Project.Whatever → someFolder)

Properties: Name, Price ...

IProductRepsitory → position in the project

Functions: BuyProduct (product product)

Now that you have identified all the details that you think will be needed to understand your example, write down the data about the program flow from the controller to create a view of which function you are calling from the controller, the function call function that you called from the controller, etc. d. until you finally share when you return to the controller and create the view.

I know that an explanation will require a longer record, but you do not need to enter too many details, but enough so that I can figure out how to correctly build the mvc application

Thank you in advance

+4
source share
1 answer

First I must say that I do not know how experienced you are in programming in general, so it is difficult to answer all your questions.

I would say that you should take a look at the .net structure, don't joke, in terms of understanding the understanding. This is one of the most important things and the answer to your question: "What would your interfaces and classes look like, where would you place them."

One sample.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace YourCompanyName { // here goes only stuff that could use in // EVERY kind of .NET Application... // The classes that are placed here dont // know windows, the internet, phones or ... } namespace YourCompany.Web { // here goes only stuff that could use in // any Asp.NET Application.. Mvc and Webforms // like request helpers... Only Asp.NET related // stuff } namespace YourCompany.Web.Mvc { // here goes only stuff that could use in // Asp.NET Mvc Application.. like HtmlHelpers or // EditorTemplates } namespace YourCompany.Web.Forms { // here goes only stuff that could use in // Asp.NET WebForms Application.. like WebControls } // and so on 

etc. if you are doing something with Windows Forms ?, YourCompany.Windows.Forms and you expand System.Windows.Forms Assembly .. this is the right way to think.

There are guys at Asp.NET

Scott Hanselman

Phil Haack

Scott Guthrie

and many others that I recommend you read their blogs and see their webcasts.

At Asp.NET MVC, you MUST see these two videos of Scott Hanselman. You can learn a lot in a short time, your joy and motivation.

ASP.NET MVC 2: Fundamentals, Introduction by Scott Hanselman

ASP.NET MVC 2: Scott Hanselman Ninja Black Belt Tips

And download the demo application to find out asp.net mvc, see how you can structure your application. =>

NerdDinner see it live NerdDinner.com

Hope this helps!

+3
source

All Articles