Thursday, January 31, 2013

How to create a Custom model in MVC architecture?



1.Model can be written in any form that makes sense to your application.There is no constraints or                                                               requirements put on it by MVC.

2.If you want to share the same model with any application,you have the option of placing the model in App_Code directory or in any class library project.

Creating Custom Model:


public class CustomerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Phone { get; set; }

public static int Insert(Customer customer)
{
}
public static void Delete(int id)
{
}
public static void Update(Customer customer)
{
}
public static List GetAllCustomers()
{
}
public static Customer GetCustomer(int id)
{
}
}