Esempio n. 1
0
        public ICommandResult Handle(AlterarStatusCommand command)
        {
            command.Validar();

            if (command.Invalid)
            {
                return(new GerencCommandResult(false, "Dados inválidos", command.Notifications));
            }

            var pacote = _repositorio.BuscarPorId(command.IdPacote);

            if (pacote == null)
            {
                return(new GerencCommandResult(false, "Pacote não encontrado", null));
            }

            pacote.AlterarStatus(command.Status);

            if (pacote.Invalid)
            {
                return(new GerencCommandResult(false, "Dados inválidos", pacote.Notifications));
            }

            _repositorio.Alterar(pacote);

            return(new GerencCommandResult(true, "Imagem alterado", null));
        }
Esempio n. 2
0
        public GenericCommandResult UpdateStatus(Guid id,
                                                 [FromBody] AlterarStatusCommand command,
                                                 [FromServices] AlterarStatusHandler handler
                                                 )
        {
            if (id == Guid.Empty)
            {
                return(new GenericCommandResult(false, "Informe o Id do Pacote", ""));
            }

            command.IdPacote = id;

            return((GenericCommandResult)handler.Handle(command));
        }