protected IHttpActionResult BadRequestWithError(ApiErrorEnum error, string message = null) { var response = Request.CreateResponse(HttpStatusCode.BadRequest, new { error = error, message = message ?? ApiErrorMessages.BadRequest }); return(ResponseMessage(response)); }
protected IHttpActionResult BadRequestWithError(ApiErrorEnum generalError, ModelStateDictionary modelState) { var error = ModelState.Values.Where(x => x.Errors != null && x.Errors.Any()).First().Errors.First(); var response = Request.CreateResponse(HttpStatusCode.BadRequest, new { error = generalError, message = !string.IsNullOrEmpty(error.ErrorMessage) ? error.ErrorMessage : error.Exception != null ? error.Exception.Message : ApiErrorMessages.BadRequest }); return(ResponseMessage(response)); }