コード例 #1
0
ファイル: TodoHandler.cs プロジェクト: marcoswoc/Todo
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           "Ops, parece que sua tarefa está errada",
                           command.Notifications
                           ));
            }

            //Recupera o TodoItem
            var todo = _repository.GetById(command.Id, command.User);

            //Altera o estado
            todo.MarkAsDone();

            //Salva no banco
            _repository.Update(todo);

            //Retorna o resultado
            return(new GenericCommandResult(
                       true,
                       "Tarefa salva",
                       todo
                       ));
        }
コード例 #2
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //fail fast validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que sua tarefa está errada!", command.Notifications));
            }

            //recupera o todoItem
            var todo = _repository.GetById(command.Id, command.User);

            //altera o titulo
            todo.MarkAsDone();

            //salva no banco
            _repository.Update(todo);

            _repository.Create(todo);
            return(new GenericCommandResult(
                       true,
                       "Tarefa salva",
                       command.Notifications
                       ));
        }
コード例 #3
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que sua tarefa está errada ", command.Notifications));
            }

            // Recupera TodoItem (rehidratação)
            var todo = _repository.GetById(command.Id, command.User);

            if (todo == null || (todo.User != command.User))
            {
                return(new GenericCommandResult(false, "Usuario invalido", command.Notifications));
            }
            else
            {
                todo.MarkAsDone();

                // Salva no banco
                _repository.Update(todo);

                //Retorna o resultado
                return(new GenericCommandResult(true, "Tarefa salva", todo));
            }
        }
コード例 #4
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new ResponseCommand(false, "Ops, parece que sua tarefa está com problemas.", command.Notifications));
            }

            var todo = _todoRepository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            return(new ResponseCommand(true, "Tarefa salva", todo));
        }
コード例 #5
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult("Opa, temos um erro aqui, por favor verifique", false, command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult("Tarefa atualizada", true, todo));
        }
コード例 #6
0
        public ICommandResult Handler(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, your task is invalid!", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "Task saved", todo));
        }
コード例 #7
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "ops, algo deu errado", command.Notifications));
            }

            var todo = _todoRepository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _todoRepository.Update(todo);

            return(new GenericCommandResult(true, "Tarefa Salva", todo));
        }
コード例 #8
0
ファイル: TodoHandler.cs プロジェクト: Diegorrfc/TodoApi1
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (!command.Valid)
            {
                return(new GenericCommandResult(false, "Houve um erro na solicitação", command.Notifications));
            }

            TodoItem item = _repository.GetByIdAndUser(command.Id, command.User);

            item.MarkAsDone();

            _repository.Update(item);

            return(new GenericCommandResult(true, "certo", item));
        }
コード例 #9
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que sua tarefa está errada!", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "Tarefa marcada como concluida", todo));
        }
コード例 #10
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Error, there's something wrong in your task", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "TODO done!", todo));
        }
コード例 #11
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Tarefa errada", command));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsUnDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "Tarefa atualizada com sucesso!", todo));
        }
コード例 #12
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();

            if (command.Valid)
            {
                return(new GenericCommandResult(false, "Operação inválida", command.Notifications));
            }

            var todoItem = _todoRepository.GetById(command.Id, command.User);

            todoItem.MarkAsDone();

            _todoRepository.Update(todoItem);

            return(new GenericCommandResult(true, "Tarefa Salva", todoItem));
        }
コード例 #13
0
        public ICommandResult Handler(MarkTodoAsDoneCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "ops, tem algo errado ai", command.Notifications));
            }

            //reidtratar o obj, necessario por conta do EF
            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "DONE!", command.Id));
        }
コード例 #14
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, sua tarefa está errada.", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.Usuario);

            todo.MarkAsDone();

            _repository.Atualizar(todo);

            return(new GenericCommandResult(true, "Tarefa atualizada com sucesso.", todo));
        }
コード例 #15
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //Fail Fest Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que a sua tarefa está errada!", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            // Gerar Um TodoItem
            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "Tarefa Salva", todo));
        }
コード例 #16
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Eita, parece que sua tarefa está errada.", command.Notifications));
            }

            // Recupera o TodoItem
            var todoItem = _todoRepository.GetById(command.Id, command.User);

            //Atualiza o título
            todoItem.MarkAsDone();

            // Salva no Banco o TodoItem
            _todoRepository.Update(todoItem);

            return(new GenericCommandResult(true, "Sua tarefa foi criada com sucesso.", todoItem));
        }
コード例 #17
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //Fail Fast Validate
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, tarefa inválida", command.Notifications));
            }

            //Recuperar um TodoItem
            var todo = _repository.GetById(command.Id, command.User);

            //Alterando Status da tarefa
            todo.MarkAsDone();

            //Salvar no banco
            _repository.Update(todo);

            return(new GenericCommandResult(true, "Tarefa Atualizada", todo));
        }
コード例 #18
0
ファイル: TodoHandler.cs プロジェクト: leooalves/task-list
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //fail fast validation
            command.Validate();
            if (!command.IsValid)
            {
                return(new GenericCommandResult(false, "Ops, sua tarefa está errada", command.Notifications));
            }


            //Busca o TodoItem
            var todoItem = _repository.GetById(command.Id, command.User);

            //altera o estado
            todoItem.MarkAsDone();

            //salva no banco
            _repository.Update(todoItem);

            return(new GenericCommandResult(true, "Tarefa salva", todoItem));
        }
コード例 #19
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return
                    (new GenericCommandResult(false, "Ops, parece que sua tarefa está errada !", command.Notifications));
            }

            // Get TodoItem
            var todo = _repository.GetById(command.Id, command.User);

            // Alter To Done
            todo.MarkAsUndone();

            // Save Todo in database
            _repository.Update(todo);

            // Notify User
            return(new GenericCommandResult(true, "Tarefa Salva", todo));
        }
コード例 #20
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           "Algo náo está certo!",
                           command.Notifications));
            }

            TodoItem entity = _TodoRepository.GetById(command.Id, command.User);

            entity.MarkAsDone();

            _TodoRepository.Update(entity);

            return(new GenericCommandResult(
                       true,
                       "Tarefa atualizada!",
                       entity));
        }
コード例 #21
0
        public ICommandResult Handle(MarkTodoAsDoneCommand command)
        {
            //Fail fast validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           "Ops, parece que sua tarefa está errada",
                           command.Notifications
                           ));
            }
            //Recurepera TodoItem (Recuperar dados mais atualizadoa)
            var todo = _repository.GetById(command.Id, command.RefUser);

            //Alterar o título
            todo.MarkAsDone();

            //Salva no banco
            _repository.Update(todo);

            //Retorna o resultado
            return(new GenericCommandResult(true, "Tarefa salva!", todo));
        }
コード例 #22
0
 public void CommandValid()
 {
     _validCommand.Validate();
     Assert.AreEqual(_validCommand.Valid, true);
 }
コード例 #23
0
 public void CommandInvalid()
 {
     _invalidCommand.Validate();
     Assert.AreEqual(_invalidCommand.Valid, false);
 }
コード例 #24
0
 public MarkTodoAsDoneCommandTests()
 {
     _invalidCommand.Validate();
     _validCommand.Validate();
 }