Answers
- We can use the
AddTransientmethod. - We can use the
NotFoundmethod. - We can use the
BadRequestmethod. - The problem is thatÂ
buildingDescription in the request doesn't match the name of theÂDescription property in the model. If the request is changed to have aÂdescription field, 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.