public static ErrorResponse Error(ResultBase result, string id = null, short status = (short)HttpStatusCode.BadRequest) { var response = new ErrorResponse { ErrorId = id ?? Guid.NewGuid().ToString(), StatusCode = status, Title = status == (short)HttpStatusCode.BadRequest ? "One or more validation failures have occurred." : "Some kind of error occurred in the API. Please use the id and contact our " + "support team if the problem persists." }; foreach (var error in result.GetFailures()) { response.Errors.Add(new ErrorModel(error.PropertyName, error.Message, error.RowKey)); } return(response); }