Real Life Example Of ASP.NET MVC 5

3
549

What is MVC
MVC is an architecture pattern which separates logic, UI & database connection of our application. It’s divided into three broader sections, “Model”, “View” and “Controller”.

  • The “View” is responsible for look and feel of our application.
  • Model” represents the real world object and provides data to the “View” (If we need data from the database then we can get it.
  • The “Controller” is responsible to take the end user request and load the appropriate “Model” and “View”.

The following diagram represents how MVC pattern works internally.

  • Everytime first request comes into controller.
  • Controller decides which action to be executed and that action goes to directly to View or through Model to View by taking data from database.

Real Life Example of MVC 5

Suppose there is one restaurant, in this restaurant some people are working as follows:

  • Guys who are an expert cook, they works in kitchen.
  • Guys (Manager) who take order from customer & write down that order on small paper with appropriate table number i.e one.
  • Now some customer comes into the restaurant, the guy who is going to take an order shows menu card of this restaurant to that customer.
  • Customer see this menu card. For example, customer see items such as Poha, Upma, Dosa etc. Now that customer would like to order Poha or dosa, then the customer can imagine how Poha or Dosa looks like.

 

  • After taking order from customer, that guy (Manager) give this small purchi to a man who is sitting outside the kitchen. This man who is sitting outside the kitchen is acting like a Controller in MVC, means every order is handled by this controller.
    This man gives order to appropriate cook for making the order ready.
  • The cook will see the order & try to make the food ready. If he needs some extra items to make food like for Dosa he need to make 1 Chatani from coconuts then cook, visit the fridge & take this coconut & make chatani ready by adding water, sugar etc. In this scenario the cook is taking data from the database means cook is acting like Model in MVC.

  • After some time, the order of that customer is ready. Now the man sit outside the kitchen, calls the waiter & tell him to serve this order to the customer who ordered from table number one.

  • Now waiter adds some items to make better look & feel of food like he add some.

Now the order is ready to eat. This is actual View in MVC. Waiter is responsible for making decorate view.

For more information related to this article and to download the code please refer my article http://www.c-sharpcorner.com/UploadFile/a8024d/real-life-example-of-Asp-Net-mvc-5/

 

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here