Exemple #1
0
        public async Task Remover(Guid id)
        {
            IEnumerable <OportunidadeLog> oportunidadeLogs = await _oportunidadeLogRepository.Buscar(o => o.Id == id);

            if (oportunidadeLogs.Any())
            {
                OportunidadeLog oportunidadeLog = oportunidadeLogs.FirstOrDefault();
                await _oportunidadeLogRepository.Atualizar(oportunidadeLog);
            }
            else
            {
                Notificar("Id não encontrado para exclusão!");
            }
        }
Exemple #2
0
        private OportunidadeLog MapearOportunidadeParaOportunidadeLog(Oportunidade oportunidade)
        {
            OportunidadeLog oportunidadeLog = new OportunidadeLog()
            {
                Id             = Guid.NewGuid(),
                OportunidadeId = oportunidade.Id,
                VeiculoId      = oportunidade.VeiculoId,
                VendedorId     = oportunidade.VendedorId,
                Valor          = oportunidade.Valor,
                Comissao       = oportunidade.Comissao,
                Status         = oportunidade.Status,
                Excluido       = oportunidade.Excluido,
                DataEvento     = DateTime.Now
            };

            oportunidade = null;
            return(oportunidadeLog);
        }
Exemple #3
0
        public async Task <bool> Remover(Guid id)
        {
            IEnumerable <Oportunidade> oportunidades = await _oportunidadeRepository.Buscar(o => o.Id == id &&
                                                                                            o.Excluido == false);

            Oportunidade    oportunidade    = new Oportunidade();
            OportunidadeLog oportunidadeLog = new OportunidadeLog();

            if (oportunidades.Any())
            {
                oportunidade = oportunidades.FirstOrDefault();
            }
            else
            {
                Notificar("Id não encontrado para exclusão!");
                return(false);
            }

            if (VerificaSeNaoEhMesmoVendedorAutenticado(oportunidade))
            {
                Notificar("Usuário somente tem acesso às oportunidades criadas por ele mesmo!");
                return(false);
            }

            if (VerificaSeStatusPossibilitaExclusao(oportunidade))
            {
                await _oportunidadeRepository.Remover(id);
            }
            else
            {
                oportunidade.Excluido     = true;
                oportunidade.DataExclusao = DateTime.Now;
                await _oportunidadeRepository.Atualizar(oportunidade);
            }

            oportunidadeLog = MapearOportunidadeParaOportunidadeLog(oportunidade);
            AdicionaOportunidadeLog(oportunidadeLog);

            return(true);
        }
Exemple #4
0
        public async Task <bool> Atualizar(Oportunidade oportunidade)
        {
            if (!ExecutarValidacao(new OportunidadeValidation(), oportunidade))
            {
                return(false);
            }

            if (!await RegrasAtualizar(oportunidade))
            {
                return(false);
            }

            oportunidade.Comissao = await ObterComissao();

            OportunidadeLog oportunidadeLog = MapearOportunidadeParaOportunidadeLog(oportunidade);

            await _oportunidadeRepository.Atualizar(oportunidade);

            AdicionaOportunidadeLog(oportunidadeLog);

            return(true);
        }
Exemple #5
0
 private void AdicionaOportunidadeLog(OportunidadeLog oportunidadeLog)
 {
     _oportunidadeLogService.Adicionar(oportunidadeLog);
 }
Exemple #6
0
 public async Task Atualizar(OportunidadeLog oportunidadeLog)
 {
     await _oportunidadeLogRepository.Atualizar(oportunidadeLog);
 }
Exemple #7
0
 public async Task Adicionar(OportunidadeLog oportunidadeLog)
 {
     await _oportunidadeLogRepository.Adicionar(oportunidadeLog);
 }