public GenericCommandResult Create( [FromBody] CreateTodoCommand command, [FromServices] TodoHandler handler) { command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler) { command.Usuario = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value.ToString(); return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Create([FromBody] CreateTodoCommand command, [FromServices] TodoHandler todoHandler) { command.User = User.Claims.FirstOrDefault(us => us.Type.Equals("user_id"))?.Value; return((GenericCommandResult)todoHandler.Handle(command)); }
public GenericCommandResult MarkAsUnDone( // converte automaticamente em JSON, por causa do FromBody (ModelBind) [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler) // From services vem do startup, ve o que tem dentro do AddTransient e instancia a dependencia { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); // retorna se O.K ou não }
public GenericCommandResult Atualizar( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler) { command.Usuario = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value.ToString(); return((GenericCommandResult)handler.Handle(command)); }
public CreateTodoHandlerTests() { _invalidComand = new CreateTodoCommand("", "", DateTime.Now); _validComand = new CreateTodoCommand("criando tarefa", "douglas", DateTime.Now); _handler = new TodoHandler(new FakeTodoRepository()); _result = new GenericCommandResult(); }
public GenericCommandResult MarkAsUnDone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public void Dado_um_comando_valido_deve_criar_a_tarefa() { var command = new CreateTodoCommand("Titulo da Tarefa", "Administrador", DateTime.Now); var handler = new TodoHandler(new FakeTodoRepository()); var result = (GenericCommandResult)handler.Handle(command); Assert.AreEqual(result.Success, true); }
public void Dado_um_comando_valido_deve_criar_a_tarefa() { var handler = new TodoHandler(new FakeTodoRepository()); _result = (GenericCommandResult)_handler.Handle(_validCommand); Assert.AreEqual(_result.Success, true); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Update( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler ) { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public void DadoUmComandoInvalidoDeveInterromperExecucao() { var command = new CreateTodoCommand("", DateTime.Now, ""); var handle = new TodoHandler(new FakeTodoRepository()); ResponseCommand result = (ResponseCommand)handle.Handle(command); Assert.AreEqual(result.Success, false); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = getUserAuthenticated(); return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Update( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler ) { command.User = getUserAuthenticated(); return((GenericCommandResult)handler.Handle(command)); }
public void Dado_um_comando_valido() { var command = new CreateTodoCommand("title", DateTime.Now, "usuario"); var handler = new TodoHandler(new FakeTodoRepository()); var result = (GenericCommandResult)handler.Handler(command); Assert.AreEqual(result.Sucess, true); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = User.Claims.FirstOrDefault(x => x.Type == "name").Value; return((GenericCommandResult)handler.Handle(command)); }
public void DadoUmComandoValidoDeveCriarTarefa() { var command = new CreateTodoCommand("Titulo da Descrição", DateTime.Now, "Usuário"); var handle = new TodoHandler(new FakeTodoRepository()); ResponseCommand result = (ResponseCommand)handle.Handle(command); Assert.AreEqual(result.Success, true); }
public GenericCommandResult Create( [FromBody] CreateTodoCommand command, [FromServices] TodoHandler handler ) { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult MarkAsDone([FromBody] MarkTodoAsDoneCommand command, [FromServices] TodoHandler todoHandler) { var user = User.Claims.FirstOrDefault(us => us.Type.Equals("user_id"))?.Value; command.User = user; return((GenericCommandResult)todoHandler.Handle(command)); }
public void Dado_um_comando_invalido_deve_interromper_a_execucao() { var handler = new TodoHandler(new FakeTodoRepository()); _result = (GenericCommandResult)_handler.Handle(_invalidCommand); Assert.AreEqual(_result.Success, false); }
public void Dado_um_comando_invalido_deve_interromper_a_execucao() { var command = new CreateTodoCommand("", "", DateTime.Now); var handler = new TodoHandler(new FakeTodoRepository()); var result = (GenericCommandResult)handler.Handle(command); Assert.AreEqual(result.Success, false); }
public GenericCommandResult Update( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler ) { command.User = User.Claims.Where(x => x.Type == "name").FirstOrDefault().Value; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Create( [FromBody] CreateTodoCommand command, //Quando fizerem um post o Frombory converte o JSON no objeto [FromServices] TodoHandler handler //A partir do que foi configurado no Startup.cs no AddTransient do Handler, vai resolver a dependência rapidamente ) { command.User = getUserAuthenticated(); //O command recebe os dados e passa para o Handler pois é ele quem vai tratar return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Create([FromBody] CreateTodoCommand command, [FromServices] TodoHandler todoHandler) { var t = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; command.User = "******"; var commandResult = (GenericCommandResult)todoHandler.Handle(command); return(commandResult); }
public GenericCommandResult MarkAsDone( [FromBody] MarkTodoAsDoneCommand command, [FromServices] TodoHandler handler) { var user = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; command.User = user; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Update( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler ) { string user = User.Claims.FirstOrDefault(a => a.Type == "user_id")?.Value; command.User = user; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult Update( [FromBody] UpdateTodoCommand command, [FromServices] TodoHandler handler, [FromRoute] Guid id ) { command.Id = id; command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult MarkAsUndone([FromServices] TodoHandler handler, [FromBody] MarkTodoAsUndoneCommand command) { return((GenericCommandResult)handler.Handle(command)); }