public IActionResult Put(Guid id, [FromBody]MarkTodoCommand command) { command.Id = id; var result = _handler.Handle(command); return Ok(result); }
public GenericCommandResult MarkAsDone( [FromBody] MarkTodoCommand command, [FromServices] TodoHandler handler ) { command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value; return((GenericCommandResult)handler.Handle(command)); }
public ICommandResult Handle(MarkTodoCommand 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.MarkAsDone(); //Salva _repository.Update(todo); //retorna return(new GenericCommandResult(true, "Tarefa salva", todo)); }