I have an MVC project that will accept data via the HTTP 'Post' verb. I'm keen to follow best practice and wanted to ask a quick question around how best to set up my models.
Generally when working with posted data I would design my controller to use the concrete model. However as I'm looking to use IoC I wanted to ascertain if I should carry on as I have been OR if I should be creating interfaces.
My gut feel is that I should be using interfaces for all of my models and classes throughout my web app to effectively implement IoC. And I just wanted to get validation that I'm on the right path! :o)
example:
My concrete model
public class PhoneBook : IPhoneBook
{
public string Firstname {get; set;}
public string LastName {get; set;}
public string PhoneNumber {get; set;}
}
My interface
public interface IPhoneBook
{
string Firstname {get;set;}
string Lastname {get;set;}
string Phonenumber {get;set;}
}
My controller
//Accept posted data from web form
public void Post(IPhoneBook passInDetails)
{
...
}
Thanks in advance.