예제 #1
0
 public IActionResult Put(Guid id, [FromBody]MarkTodoCommand command)
 {
     command.Id = id;
     
     var result = _handler.Handle(command);
     return Ok(result);
 }
예제 #2
0
 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));
 }
예제 #3
0
        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));
        }