예제 #1
0
 public GenericCommandResult MarkAsDone(
     [FromBody] MarkAsDoneTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
     return((GenericCommandResult)handler.Handle(command));
 }
예제 #2
0
        public ICommandResult Handle(MarkAsDoneTodoCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Algo deu errado", command.Notifications));
            }

            var todo = _repository.GetById(command.Id, command.User);

            todo.MarkAsDone();

            _repository.Update(todo);

            return(new GenericCommandResult(true, "Salvo", todo));
        }