Пример #1
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         service.Delete(id);
         return(StatusCode(HttpStatusCode.NoContent));
     }
     catch (NotSupportedException)
     {
         return(BadRequest());
     }
     catch (UnauthorizedAccessException)
     {
         return(StatusCode(HttpStatusCode.Forbidden));
     }
     catch (KeyNotFoundException)
     {
         return(NotFound());
     }
 }
Пример #2
0
 public ActionResult <Principal> Delete(int id)
 {
     try
     {
         var value = service.Delete(id);
         return(Ok(value));
     }
     catch (NotSupportedException)
     {
         return(BadRequest());
     }
     catch (UnauthorizedAccessException)
     {
         return(Forbid());
     }
     catch (KeyNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e));
     }
 }