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 )); }
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 )); }
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)); } }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public void CommandValid() { _validCommand.Validate(); Assert.AreEqual(_validCommand.Valid, true); }
public void CommandInvalid() { _invalidCommand.Validate(); Assert.AreEqual(_invalidCommand.Valid, false); }
public MarkTodoAsDoneCommandTests() { _invalidCommand.Validate(); _validCommand.Validate(); }