Answers
- We can use the
AddTransient
method. - We can use the
NotFound
method. - We can use the
BadRequest
method. - The problem is that
buildingDescription
in the request doesn't match the name of theDescription
property in the model. If the request is changed to have adescription
field, then this will resolve the problem. - We can add
Required
attributes toCode
andName
as 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
Range
attribute as follows:[Range(1, 10)]
- The
HttpPatch
attribute can be used to handle HTTPPATCH
requests.