/// <summary> /// The method that puts the supplied data together into a HTTP Response Message. /// </summary> /// <param name="cancellationToken"> /// The cancellation token. /// </param> /// <returns> /// The custom 400 - Bad Request HTTP Response. /// </returns> public async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken) { if (BrokenRules == null) { return(null); } var response = new HttpResponseMessage(HttpStatusCode.BadRequest); var validationRules = BrokenRules as IList <ValidationRule> ?? BrokenRules.ToList(); var errors = new { Error = "The provided " + ClassName + " failed to validate.", ValidationErrors = validationRules.ToList() }; response.Content = new StringContent(Json.Encode(errors)); response.RequestMessage = Request; return(await Task.FromResult(response)); }