Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 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
 }
Esempio n. 5
0
 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));
 }
Esempio n. 6
0
 public CreateTodoHandlerTests()
 {
     _invalidComand = new CreateTodoCommand("", "", DateTime.Now);
     _validComand   = new CreateTodoCommand("criando tarefa", "douglas", DateTime.Now);
     _handler       = new TodoHandler(new FakeTodoRepository());
     _result        = new GenericCommandResult();
 }
Esempio n. 7
0
 public GenericCommandResult MarkAsUnDone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 8
0
        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);
        }
Esempio n. 10
0
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 11
0
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 12
0
 public GenericCommandResult Update(
     [FromBody] UpdateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 13
0
        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));
 }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 20
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Esempio n. 24
0
        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));
 }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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));
        }
Esempio n. 28
0
        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));
        }
Esempio n. 29
0
        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));
        }
Esempio n. 30
0
 public GenericCommandResult MarkAsUndone([FromServices] TodoHandler handler, [FromBody] MarkTodoAsUndoneCommand command)
 {
     return((GenericCommandResult)handler.Handle(command));
 }