public override IHttpActionResult Delete(int key) { var entity = Repository.AsQueryable().SingleOrDefault(m => m.Id == key); if (entity == null) { return(NotFound()); } if (!AllowDelete(entity)) { return(Forbidden()); } if (!entity.CanBeDeleted) { return(BadRequest("Cannot delete advice which is active or has been sent")); } try { _adviceService.Delete(entity); } catch (Exception e) { Logger.ErrorException("Failed to delete advice", e); return(StatusCode(HttpStatusCode.InternalServerError)); } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteAdvices(int[] ids) { return(Json(adviceService.Delete(ids))); }