public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { if (!context.ModelState.IsValid) { BasicApiResponse responseObj = new BasicApiResponse(false, context.ModelState.Values.SelectMany(v => v.Errors.Select(e => new ErrorMessage() { Code = ApiErrorCode.Validation, Message = e.ErrorMessage })).ToArray()); context.Result = new JsonResult(responseObj); return; } await next(); }
public HttpResponseMessage Delete(string id) { BasicApiResponse response = new BasicApiResponse(); try { this.CustomerService.DeleteCustomer(id); response.Message = ResponseMessages.DeleteCustomerOk; } catch (Exception ex) { response.Message = ex.Message; return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } return(this.Request.CreateResponse(HttpStatusCode.OK, response)); }