Example #1
0
        public IHttpActionResult Update(int id, [FromBody] Principal value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                service.Update(id, value);
                return(StatusCode(HttpStatusCode.NoContent));
            }
            catch (NotSupportedException)
            {
                return(BadRequest());
            }
            catch (UnauthorizedAccessException)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Example #2
0
        public ActionResult Update(int id, Principal value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                service.Update(id, value);
                return(NoContent());
            }
            catch (NotSupportedException)
            {
                return(BadRequest());
            }
            catch (UnauthorizedAccessException)
            {
                return(Forbid());
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }