Пример #1
0
        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));
            }
        }
Пример #2
0
        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());
            }
        }