0

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.

Patrick
  • 1,717
  • 7
  • 21
  • 28
Ravi Kumar Mistry
  • 1,063
  • 1
  • 13
  • 24
  • 1
    The work required to create this "generic" system would far exceed the amount of work to just create your 90 different CRUD handlers. – Erik Funkenbusch Jun 26 '16 at 05:50
  • I know that but if i do it once i can reuse it in my other projects also this is why i am motivated and want to create the framework for rapid development of CRUD based application. – Ravi Kumar Mistry Jun 26 '16 at 06:50
  • Have you tried a default value for the `controller` argument in your routing? – Tsahi Asher Apr 09 '18 at 14:41
  • @RaviKumarMistry Currently the question is too broad. If you can show us your code for controller factory with the description of error, you can possibly get an answer to that problem. – trailmax Apr 09 '18 at 14:43

0 Answers0