public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); //Salva no banco _repository.Update(todo); //Retorna o resultado return(new GenericCommandResult( true, "Tarefa salva", todo )); }
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 ICommandResult Handle(MarkTodoAsUndoneCommand command) { //Fail Fast Validation if (command.Invalid) { return(new GenericCommandResult( false, "Ops", command.Notifications )); } //Recupera o TodoItem - Ré Hidratação var todo = _repository.GetById(command.Id, command.User); //Altera o estado todo.MarkAsUnDone(); //Atualiza no banco _repository.Update(todo); //Retorna o Generic true return(new GenericCommandResult( true, "Tarefa Atualizada!", todo )); }
public ICommandResult UpdateTodo([FromBody] MarkTodoAsUndoneCommand command) { command.User = "******"; var result = (ResponseCommand)_handler.Handle(command); return(result); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); //salva no banco _repository.Update(todo); _repository.Create(todo); return(new GenericCommandResult( true, "Tarefa salva", command.Notifications )); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand 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.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = "******"; return((GenericCommandResult)handler.Handle(command)); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] TodoHandler handler ) { command.User = getUserAuthenticated(); return((GenericCommandResult)handler.Handle(command)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUnDone(); return(new ResponseCommand(true, "Tarefa salva", todo)); }
public async Task <MutationResult> MarkTodoAsUndone(DateTime?doneDate) { var request = new MarkTodoAsUndoneCommand { TodoId = id }; try { await processor.Run(request); return(MutationResult.Success()); } catch (Exception e) { return(MutationResult.Error(e)); } }
public ICommandResult Handler(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _repository.Update(todo); return(new GenericCommandResult(true, "Task saved", todo)); }
public GenericCommandResult MarkAsUndone( [FromBody] MarkTodoAsUndoneCommand command, [FromServices] MarkTodoAsUndoneHandler handler, Guid id ) { if (id != command.Id) { return(new GenericCommandResult(false, "Id não encontrado", false)); } var user = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; command.User = user; return((GenericCommandResult)handler.Handle(command)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Tarefa errada", command)); } var todo = _repository.GetById(command.Id, command.User); todo.MarkAsDone(); _repository.Update(todo); return(new GenericCommandResult(true, "Tarefa atualizada com sucesso!", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _repository.Update(todo); return(new GenericCommandResult("Tarefa atualizada", true, todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _repository.Update(todo); return(new GenericCommandResult(true, "TODO updated!", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _repository.Update(todo); return(new GenericCommandResult(true, "Tarefa marcada como não concluida", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _repository.Atualizar(todo); return(new GenericCommandResult(true, "Tarefa atualizada com sucesso.", todo)); }
public async Task <IActionResult> MarkAsUndone([FromBody] MarkTodoAsUndoneCommand command) { var response = await _bus.Send(new MarkTodoAsUndoneCommand(command.Id, User.Claims.FirstOrDefault()?.Value)); _logger.LogInformation($"Success to mark todo as undone"); if (_notificationContext.HasErrorNotifications) { var notifications = _notificationContext.GetErrorNotifications(); var message = string.Join(", ", notifications.Select(x => x.Value)); _logger.LogError(message); return(BadRequest(message)); } return(Ok(response)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Ops, problemas com sua tarefa!", command.Notifications)); } var todo = _repository.GetById(command.Id, command.User); todo.MarkAsUndone(); _repository.Update(todo); return(new GenericCommandResult(true, "Tarefa removida das tarefas concluídas!", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _todoRepository.Update(todoItem); return(new GenericCommandResult(true, "Tarefa Salva", todoItem)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUnDone(); _repository.Update(todo); return(new GenericCommandResult(true, "Tarefa Salva", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); // Salva no Banco o TodoItem _todoRepository.Update(todoItem); return(new GenericCommandResult(true, "Sua tarefa foi criada com sucesso.", todoItem)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); //Salvar no banco _repository.Update(todo); return(new GenericCommandResult(true, "Tarefa Atualizada", todo));; }
public async Task MarkToDoAsUndoneCommandHandlerTestShouldReturnGenericCommandResultObject() { var command = new MarkTodoAsUndoneCommand { Id = Guid.NewGuid(), User = "******" }; var todo = new TodoItem("Teste", true, DateTime.Now, "Teste"); var handler = new MarkTodoAsUndoneCommandHandler(_toDoRepositoryMock.Object); _toDoRepositoryMock.Setup(a => a.GetById(command.Id)).ReturnsAsync(todo); _toDoRepositoryMock.Setup(a => a.Update(todo)).ReturnsAsync(todo); //Act var result = await handler.Handle(command, new CancellationToken()); result.Success.Should().BeTrue(); result.Message.Should().Be("Tarefa salva"); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); //salva no banco _repository.Update(todoItem); return(new GenericCommandResult(true, "Tarefa salva", todoItem)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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); //altera estado todo.MarkAsUnDone(); //Salva _repository.Update(todo); //retorna return(new GenericCommandResult(true, "Tarefa salva", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsDone(); // Save Todo in database _repository.Update(todo); // Notify User return(new GenericCommandResult(true, "Tarefa Salva", todo)); }
public ICommandResult Handle(MarkTodoAsUndoneCommand 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.MarkAsUndone(); _TodoRepository.Update(entity); return(new GenericCommandResult( true, "Tarefa atualizada!", entity)); }