Pregunta

I am developing services using Asp.Net Web Api. I am debating on design of our controllers. We have this common scenario where user will be presented with bunch of search field, once he enters the search criteria we will show summary of records (not the complete details), user will select one summary record and can go to details for this.

Ex.

class PersonSummary {
   string FirstName {get;set;}
   string LastName {get;set;}
   string Gender {get;set;}
}


class Person {
   string FirstName {get;set;}
   string LastName {get;set;}
   string Gender {get;set;}
   string SSN {get;set;} 
   string Race {get;set;}
   Address Address {get;set;}
}

User will search by user first\last name and we will show will list of PersonSummary records, he can select one PersonSummary to look at the details (Person record).

Now is it best design that we go with two controllers PersonSummaryController and PersonController?

Thank you.

¿Fue útil?

Solución

I don't see a need for two controllers. You're dealing with one type of resource (Person), but asking for data in two formats (summary and detail). I would leave it at one controller and go on with life.

Licenciado bajo: CC-BY-SA con atribución
scroll top