示例#1
0
        public ICommandResult Handle(InactivateResidentCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, erro ao inativar morador.", command.Notifications));
            }

            // Hidrata morador
            var resident = _repository.GetById(command.Id, command.User);

            if (resident == null)
            {
                return(new GenericCommandResult(false, "Ops, erro ao inativar morador.", command.Id));
            }

            resident.Inactivate();

            try
            {
                // Atualiza morador
                _repository.Update(resident);
            }
            catch (Exception ex)
            {
                return(new GenericCommandResult(false, "Erro inesperado!", ex.Message));
            }

            return(new GenericCommandResult(true, "Morador inativado com sucesso!", null));
        }
示例#2
0
 public InvalidateResidentCommandTests()
 {
     _invalidCommand.Validate();
     _validCommand.Validate();
 }