11 Eylül 2016 Pazar

How to call a Controller method which is accepting two models?

I would say that instead of justifying this lack of support of multiple models with documentation, you should find an argument in terms of software architecture perspective: ASP.NET Web API is built on top of MVC paradigm, where a view is bound to a model and handled by a controller.
In other words: 1 Model, 1 View, 1 Controller.
Your use case shouldn't be solved with 2 models, but using a DTO. Instead of binding 2 parameter to 2 models, design a DTO which includes both models as associations of the whole DTO:
// You don't need [FromBody] since complex types are already taken
// from the request body
public IHttpActionResult DoStuff(SomeDto dto)
 
http://stackoverflow.com/questions/25889205/how-to-call-a-controller-method-which-is-accepting-two-models 

Hiç yorum yok:

Yorum Gönder

.net 6 mapget kullanımı

 app.UseEndpoints(endpoints => {     endpoints.MapGet("/", async context =>     {         var response = JsonConvert.Seriali...