public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { var odata = actionContext.Request.ODataProperties(); var context = new ODataQueryContext(odata.Model, typeof(PrintJob), odata.Path); var options = new ODataQueryOptions <PrintJob>(context, actionContext.Request); var modelState = actionContext.ModelState; var result = default(IHttpActionResult); if (!options.IsValidField(o => o.CatalogId, modelState)) { result = actionContext.BadRequest(nameof(InvalidPrintJobItem), InvalidPrintJobItem); } else if (!options.IsValidField(o => o.Quantity, modelState)) { result = actionContext.BadRequest(nameof(InvalidPrintJobQuantity), InvalidPrintJobQuantity); } else { return; } actionContext.Response = await result.ExecuteAsync(cancellationToken); }
public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { var request = actionContext.Request; var ifMatch = request.Headers.IfMatch; if (ifMatch.Count == 1) { return; } var result = actionContext.BadRequest("InvalidEntityTag", "The request requires exactly one entity tag value provided in the If-Match header."); actionContext.Response = await result.ExecuteAsync(cancellationToken); }