public HttpResponseMessage Post(OrganizationRightDTO dto) { var organizationRight = Map <OrganizationRightDTO, OrganizationRight>(dto); try { var result = _organizationRightsService.AssignRole(dto.OrganizationId, organizationRight.UserId, organizationRight.Role); return(result.Ok ? NewObjectCreated(result.Value) : FromOperationFailure(result.Error)); } catch (Exception e) { Logger.ErrorException("Failed to add right", e); return(LogError(e)); } }
public IHttpActionResult PostRights(int orgKey, OrganizationRight entity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = _organizationRightsService.AssignRole(orgKey, entity.UserId, entity.Role); if (result.Ok) { return(Created(entity)); } return(FromOperationFailure(result.Error)); } catch (Exception e) { Logger.ErrorException("Failed to add right", e); return(InternalServerError()); } }