I have to create an CRUD based application for a database which is having about 90 tables, but I don't want to do a lot of repetitive coding again and again.
So I have come up with the Idea of a Generic Controller and views. All the information to render the view and Authorization Authentication thing will be defined in the model as attributes.
[Authorize]
public class Person : ControllerModel
{
[PrimaryKey]
[Hidden]
public int Id {get;set;}
public string Name {get;set;}
[TextArea]
public string Address{get;set;}
[Dropdown(DataSource="Countries")]
public string Country {get; set;}
public List<SelectListItem> Countries {get; set;}
[RelationShip(Type="ManyToMany")]
[Grid(Colunms="Name,Address",Rows="10,20,50")]
public List<Person> FamilyMambers {get; set;}
}
If the controller for Person
not found in the controller directory of project it will handled by the Generic Controller.
I have whole idea how do I create views and persist the data in database. Just dont have the Idea how to instantiate the Generic controllers? I found few clues to achieve this on following links How to impelment a custom controller factory ASP.Net MVC But the code is throwing null reference exception. Any help or idea would be appreciated.