public void OnException(ExceptionContext context) { if (context.Exception is EntityNotExistException e) { if (HttpMethods.IsGet(context.HttpContext.Request.Method)) { context.Result = new NotFoundObjectResult(MakeCommonResponse(e)); } else if (HttpMethods.IsDelete(context.HttpContext.Request.Method)) { if (context.ActionDescriptor.EndpointMetadata.OfType <NotEntityDeleteAttribute>().Any()) { context.Result = new BadRequestObjectResult(MakeCommonResponse(e)); } else { context.Result = new OkObjectResult(CommonDeleteResponse.NotExist()); } } else { context.Result = new BadRequestObjectResult(MakeCommonResponse(e)); } } }
public async Task <ActionResult <CommonDeleteResponse> > Delete([GeneralTimelineName] string timeline) { var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline); var delete = await _service.RemoveHighlightTimelineAsync(timelineId, GetUserId()); return(CommonDeleteResponse.Create(delete)); }
protected ObjectResult DeleteWithCommonDeleteResponse(bool delete = true) { return(StatusCode(StatusCodes.Status200OK, CommonDeleteResponse.Create(delete))); }