Guest User

Untitled

a guest
Jan 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. routes.MapHttpRoute(
  2. name:"DinnerApplicationApi",
  3. routeTemplate: "api/dinner/{dinnerId}/{controller}"
  4. );
  5.  
  6. [ModelValidationFilter]
  7. public HttpResponseMessage Post([FromBody]ApplicationApiModel application, int dinnerId)
  8. {
  9. //this will work when invoked from route /dinner/dinnerId/application and without ModelValidationFilter
  10. application.dinnerId = dinnerId;
  11. if (123456 == application.dinnerId)
  12. return new HttpResponseMessage(HttpStatusCode.OK);
  13. else
  14. {
  15. return new HttpResponseMessage(HttpStatusCode.BadRequest);
  16. }
  17. }
  18.  
  19. public class ApplicationApiModel
  20. {
  21. [Required]
  22. public int DinnerId { get; set; }
  23. [Required]
  24. public AttendeeApiModel Attendee { get; set; }
  25. public string Message { get; set; }
  26. public string Password { get; set; }
  27.  
  28. }
Add Comment
Please, Sign In to add comment