public HttpResponseMessage Execute([FromBody] TCommand command) { if (command == null) { throw new ArgumentNullException("command"); } try { this.commandHandler.Handle(command); } catch (Exception ex) { var response = WebApiErrorResponseBuilder.CreateErrorResponse(ex, this.Request); if (response != null) { return(response); } throw; } return(this.Request.CreateResponse <TCommand>(SuccessStatusCodeForThisCommandType, command)); }
// Note: without [ModelBinder] or [FromUri], the query object won't get deserialized. public HttpResponseMessage Execute([ModelBinder] TQuery query) { if (query == null) { throw new ArgumentNullException("query"); } TResult result; try { result = this.processor.Execute(query); } catch (Exception ex) { var response = WebApiErrorResponseBuilder.CreateErrorResponse(ex, this.Request); if (response != null) { return(response); } throw; } return(this.Request.CreateResponse <TResult>(SuccessStatusCodeForThisQueryType, result)); }