title: Return a list of errors with BadRequest (WebApi)
body: <p>As the title indicates all I'm trying to do is return a custom collection of errors if the "Model" is incomplete.</p>
  
  <p>Whilst actively "SO'ing/Googling" I haven't found a solution to help with my problem.</p>
  
  <p>I could of used "ModelState" but due to "Customisation", I'd like to do this manually.</p>
  
  <p>Code as Follows:</p>
  
  <p><strong>API Level</strong></p>
  
  <pre><code>// POST api/&lt;controller&gt;
  [HttpPost]
  [Route("")]
  public async Task&lt;IHttpActionResult&gt; Post([FromBody]Order order)
  {
      var modelResponse = new ModelResponse&lt;Order&gt;(order);
      if (order == null)
          return BadRequest("Unusable resource, object instance required.");
  
      //Check if all required properties contain values, if not, return response
      //with the details
      if (!modelResponse.IsModelValid())
          return this.PropertiesRequired(modelResponse.ModelErrors());
  
      try
      {
          await _orderService.AddAsync(order);
      }
      catch (System.Exception ex)
      {
          return InternalServerError();
      }
      finally
      {
          _orderService.Dispose();
      }
  
      return Ok("Order Successfully Processed.");
  }
  </code></pre>
  
  <p><strong>Properties Required Action Result</strong></p>
  
  <pre><code>public List&lt;string&gt; Messages { get; private set; }
  public HttpRequestMessage Request { get; private set; }
  
  public PropertiesRequiredActionResult(List&lt;string&gt; message, 
      HttpRequestMessage request)
  {
      this.Messages = message;
      this.Request = request;
  }
  public Task&lt;HttpResponseMessage&gt; ExecuteAsync(CancellationToken cancellationToken)
  {
      return Task.FromResult(Execute());
  }
  
  public HttpResponseMessage Execute()
  {
      HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest);
      response.Content = new ObjectContent()
          //new List&lt;StringContent&gt;(Messages); //Stuck here
      response.RequestMessage = Request;
      return response;
  }
  </code></pre>
  
  <p><strong>Finding incomplete properties, based on a custom Attribute</strong></p>
  
  <pre><code>private T _obj;
  
  public ModelResponse(T obj)
  {
      _obj = obj;
  }
  
  private Dictionary&lt;string, object&gt; GetPropertyAttributes(PropertyInfo property)
  {
      Dictionary&lt;string, object&gt; attribs = new Dictionary&lt;string, object&gt;();
      // look for attributes that takes one constructor argument
      foreach (CustomAttributeData attribData in property.GetCustomAttributesData())
      {
  
          if (attribData.ConstructorArguments.Count == 1)
          {
              string typeName = attribData.Constructor.DeclaringType.Name;
              if (typeName.EndsWith("Attribute")) typeName = typeName.Substring(0, typeName.Length - 9);
              attribs[typeName] = attribData.ConstructorArguments[0].Value;
          }
  
      }
      return attribs;
  }
  private IEnumerable&lt;PropertyInfo&gt; GetProperties()
  {
      var props = typeof(T).GetProperties().Where(
              prop =&gt; Attribute.IsDefined(prop, typeof(APIAttribute)));
  
      return props;
  }
  public bool IsModelValid()
  {
      var props = GetProperties();
      return props.Any(p =&gt; p != null);
  }
  public List&lt;string&gt; ModelErrors()
  {
          List&lt;string&gt; errors = new List&lt;string&gt;();
          foreach (var p in GetProperties())
          {
  
              object propertyValue = _obj.GetType()
                  .GetProperty(p.Name).GetValue(_obj, null);
  
              if (propertyValue == null)
              {
                  errors.Add(p.Name + " - " + GetPropertyAttributes(p).FirstOrDefault());
              }
          }
          return errors;
  }
  </code></pre>
  
  <p><strong>Sample of Attribute</strong></p>
  
  <pre><code>/// &lt;summary&gt;
  /// The date and time when the order was created.
  /// &lt;/summary&gt;
  [API(Required = "Order Created At Required")]
  public DateTime Order_Created_At { get; set; }
  </code></pre>
  
  <p>So ignoring the two latter snippets, that was more to give a full process overview. I completely understand there are a few "out the box" techniques but I do enjoy crafting my own implementations.</p>
  
  <p>To the point, Is it possible to return a list of errors with "BadRequest"?</p>
  
  <p>Much appreciated.</p>