Could you tell me when I need to use several parameters instead of a separate model in my WebApi / MVC application?
I have an action that takes several parameters.
[HttpPost]
public InfoViewModel GetInfo(IEnumerable<Guid> Ids, DocumentType type)
{
}
I can also convert this action to the following:
[HttpPost]
public InfoViewModel GetInfo(RequestViewModel model)
{
}
I need a special model for the second case.
public class RequestViewModel
{
public IEnumerable<Guid> Ids { get; set; }
public DocumentType DocumentType { get; set; }
}
I send my data to the server in JSON format. Could you tell me about some of the advantages and disadvantages of these two approaches? Thank.
source
share