Answers
- We can use the
AddTransientmethod. - We can use the
NotFoundmethod. - We can use the
BadRequestmethod. - The problem is that
buildingDescriptionin the request doesn't match the name of theDescriptionproperty in the model. If the request is changed to have adescriptionfield, then this will resolve the problem. - We can add
Requiredattributes toCodeandNameas follows:public class BuildingPostRequest { [Required] public string Code { get; set; } [Required] public string Name { get; set; } public string Description { get; set; } } - We can use a
Rangeattribute as follows:[Range(1, 10)]
- The
HttpPatchattribute can be used to handle HTTPPATCHrequests.