public void InvalidCommand() { var command = new CreateAlunoCommand("Antonio Fracisco da Silva", "00000000000", DateTime.Now, "*****@*****.**", "0124"); command.Validate(); Assert.AreEqual(command.Valid, true); }
public void ValidCommand() { var command = new CreateAlunoCommand("", "", DateTime.Now, "", ""); command.Validate(); Assert.AreEqual(command.Valid, false); }
public void ValidHandler() { var command = new CreateAlunoCommand("Antonio Fracisco da Silva", "00000000000", DateTime.Now, "*****@*****.**", "0124"); var handler = new AlunoHandler(new FakeAlunoRepository()); var result = (CommandResult)handler.Handle(command); Assert.AreEqual(result.Sucess, true); }
public void InvalidHandler() { var command = new CreateAlunoCommand("", "", DateTime.Now, "", ""); var handler = new AlunoHandler(new FakeAlunoRepository()); var result = (CommandResult)handler.Handle(command); Assert.AreEqual(result.Sucess, false); }
public CommandResult Create( [FromBody] CreateAlunoCommand command, [FromServices] AlunoHandler handler ) { //Gravando o usuário token da google command.RefUser = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; return((CommandResult)handler.Handle(command)); }
public async Task <ActionResult <CreateAlunoCommand> > Create(CreateAlunoCommand command) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _alunoService.Create(_mapper.Map <Aluno>(command)); return(CustomResponse(command)); }
public async Task <IActionResult> Post(CreateAlunoCommand command) { try { await _alunoApplicationService.Add(command); return(Ok(new { Message = "Aluno Cadastrado com sucesso." })); } catch (ValidationException e) { return(BadRequest(ValidationAdapter.Parse(e.Errors))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public async Task Add(CreateAlunoCommand command) { await mediator.Send(command); }