public AddPartCommandHandlerTest()
 {
     partRepository = new Mock <IPartRepository>();
     mapper         = new Mock <IMapper>();
     command        = new AddPartCommand();
     commandHandler = new AddPartCommandHandler(partRepository.Object, mapper.Object);
     part           = new Part();
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 4
0
 public void Handle(AddPartCommand message)
 {
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> AddPart(AddPartCommand command)
        {
            await mediator.Send(command);

            return(Ok());
        }