public ICommandResult Handle(MakeTodoAsDoneCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Ops, parece que sua tarefa está errada!", 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(MakeTodoAsDoneCommand command) { // Fail fast Validation command.Validate(); if (command.Invalid) { return(new GenericCommandResult( false, "Ops, parece que a sua tarefa está errada", command.Notifications )); } //Recuperar TodoItem TodoItem todoItem = _repository.GetById(command.Id, command.User); todoItem.MarkAsUnDone(); return(new GenericCommandResult(true, "Tarefa atualizada", todoItem)); }
public GenericCommandResult MarkAsDone([FromBody] MakeTodoAsDoneCommand command, [FromServices] TodoHandler handler) { command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; return((GenericCommandResult)handler.Handle(command)); }