ASP.Net MVC Tute 1 - The Theory

ASP.Net MVC Tute 1 (Starter)

The Theory

The theory is inside the name it self.

M - Model
V - View
C - Controller


When ASP.Net MVC project is created you can see there are 3 folders for Models, Controllers and Views within the project structure (See the figure bellow).








Models folder 

We create normal classes.
Ex. Item class.

    public class Item
    {
        public int Id { get; set; }
        public string ItemName { get; set; }
        public double Price { get; set; }

    }

Controllers Folder

Use to handle the business logic.
Ex. Create new Item

        public ActionResult Index()
        {
            Item item = new Item();
            item.Id = 1;
            item.ItemName = "Lumia 820";
            item.Price = 35000;
            return View(item);
        }

Views Folder

Use to manage the front end.
Ex. Display Item details.

@model ERP.Models.ItemModels.Item



    
    Index


    

This is the Item page.

Item Details

  • ID: @Model.Id
  • Name: @Model.ItemName
  • Price: @Model.Price

Comments

Popular posts from this blog

Deploy Angular 8 app to Azure with Azure DevOps

Apache ActiveMQ 5 with .Net Core 3.1 and C#

Firebase with.Net Core and C#