// PUT api/Roles/5 public IHttpActionResult PutRole(int id, Role role) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != role.RoleID) { return(BadRequest()); } try { _roleService.UpdateRole(role); _roleService.SaveRole(); } catch (Exception ex) { if (!RoleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public PutRoleResponse Put(PutRoleRequest request) { bool isNew; unitOfWork.BeginTransaction(); var role = roleService.SaveRole(request.Id ?? Guid.Empty, request.Data.Version, request.Data.Name, request.Data.Description, out isNew, true); unitOfWork.Commit(); if (isNew) { Events.UserEvents.Instance.OnRoleCreated(role); } else { Events.UserEvents.Instance.OnRoleUpdated(role); } return(new PutRoleResponse { Data = role.Id }); }