Skip to content

Instantly share code, notes, and snippets.

@pedroreys
Created August 6, 2014 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedroreys/63e116256ec7cfad5910 to your computer and use it in GitHub Desktop.
Save pedroreys/63e116256ec7cfad5910 to your computer and use it in GitHub Desktop.
[RoutePrefix("api/assemble/wip")]
public class AssembleWipItemController : ApiController
{
private readonly IMediator _mediator;
public AssembleWipItemController(IMediator mediator)
{
_mediator = mediator;
}
[Route("")]
public WipItemResult Get([FromUri] GetModel input)
{
return _mediator.Send(input);
}
[Route("{wipId}")]
public WipItemRepresentationModel GetById([FromUri] GetModelById input)
{
return _mediator.Send(input);
}
[Route("{wipId}/start")]
[HttpPost]
public StartWipResult Start([FromUri]StartWipModel input)
{
return _mediator.Send(input);
}
}
@pedroreys
Copy link
Author

Controller actions are a simple call to MediatR to dispatch the request to a handler that can be tested isolated from Web API.

We also use FluentValidation to validate the input models with Validators that also can be tested isolated from Web API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment