public AddPartCommandHandlerTest() { partRepository = new Mock <IPartRepository>(); mapper = new Mock <IMapper>(); command = new AddPartCommand(); commandHandler = new AddPartCommandHandler(partRepository.Object, mapper.Object); part = new Part(); }
public async Task <IActionResult> AddPart([FromBody] AddPartCommand addPartCommand) { if (ModelState.IsValid) { var result = await _mediator.Send(addPartCommand); return(Ok(result)); } return(BadRequest()); }
public async Task <IActionResult> Post( [FromServices] IBus bus, [Required] PostModel model) { // Hack: just for testing claims into the command handler HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimsIdentity.DefaultNameClaimType, "test") }, "test")); var command = new AddPartCommand(model.Code, model.Name); await bus.Send(command); return(CreatedAtAction("Get", new { code = model.Code }, model.Code)); }
public void Handle(AddPartCommand message) { }
public async Task <IActionResult> AddPart(AddPartCommand command) { await mediator.Send(command); return(Ok()); }