Exemple #1
0
 public IActionResult Update(int id, [FromBody] GroupMemberViewModel viewModel)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (id != viewModel.Id)
     {
         return(BadRequest());
     }
     try
     {
         var orginalGroupMember = _groupMemberService.Find(id);
         if (orginalGroupMember == null)
         {
             return(NotFound());
         }
         orginalGroupMember = _mapper.Map(viewModel, orginalGroupMember);
         _groupMemberService.Update(orginalGroupMember);
         _unitOfWork.Commit();
         return(NoContent());
     }
     catch
     {
         return(StatusCode(500));
     }
 }