コード例 #1
0
 public IActionResult Put([FromBody] Profile profile)
 {
     if (profile == null)
     {
         return(BadRequest());
     }
     return(new ObjectResult(_profileBusiness.Update(profile)));
 }
コード例 #2
0
 public HttpResponseMessage Put([FromBody] ProfileViewModel model, [FromUri] string code)
 {
     try
     {
         if (string.IsNullOrEmpty(code))
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid code"));
         }
         var exist = profileBusiness.GetByCode(code) != null;
         if (!exist)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, $"Profile with code {code} does not exist."));
         }
         model.Code = code;
         var entity = mapper.MapFromModelToEntity(model);
         profileBusiness.Update(entity);
         var ProfileViewModel = profileBusiness.GetByCode(model.Code);
         return(Request.CreateResponse(HttpStatusCode.OK, ProfileViewModel));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }