Exemplo n.º 1
0
        public async Task <bool> Executar(FiltroRelatorioBoletimDto filtroRelatorioBoletimDto)
        {
            if (repositorioDre.ObterPorCodigo(filtroRelatorioBoletimDto.DreCodigo) == null)
            {
                throw new NegocioException("Não foi possível encontrar a DRE");
            }

            if (repositorioUe.ObterPorCodigo(filtroRelatorioBoletimDto.UeCodigo) == null)
            {
                throw new NegocioException("Não foi possível encontrar a UE");
            }

            if (!string.IsNullOrEmpty(filtroRelatorioBoletimDto.TurmaCodigo))
            {
                int codigoTurma;
                if (int.TryParse(filtroRelatorioBoletimDto.TurmaCodigo, out codigoTurma) && codigoTurma <= 0)
                {
                    filtroRelatorioBoletimDto.TurmaCodigo = String.Empty;
                }
                else if (await repositorioTurma.ObterPorCodigo(filtroRelatorioBoletimDto.TurmaCodigo) == null)
                {
                    throw new NegocioException("Não foi possível encontrar a turma");
                }
            }


            unitOfWork.IniciarTransacao();
            var usuarioLogado = await mediator.Send(new ObterUsuarioLogadoQuery());

            filtroRelatorioBoletimDto.Usuario = usuarioLogado;
            var retorno = await mediator.Send(new GerarRelatorioCommand(TipoRelatorio.Boletim, filtroRelatorioBoletimDto, usuarioLogado));

            unitOfWork.PersistirTransacao();
            return(retorno);
        }
Exemplo n.º 2
0
        public async Task <bool> Handle(ValidaSeExisteDrePorCodigoQuery request, CancellationToken cancellationToken)
        {
            if (repositorioDre.ObterPorCodigo(request.CodigoDre) == null)
            {
                throw new NegocioException("Não foi possível encontrar a DRE");
            }

            return(true);
        }
Exemplo n.º 3
0
        private FechamentoReabertura TransformarDtoEmEntidadeParaPersistencia(FechamentoReaberturaPersistenciaDto fechamentoReaberturaPersistenciaDto)
        {
            Dre dre = null;
            Ue  ue  = null;

            if (!string.IsNullOrEmpty(fechamentoReaberturaPersistenciaDto.DreCodigo))
            {
                dre = repositorioDre.ObterPorCodigo(fechamentoReaberturaPersistenciaDto.DreCodigo);
                if (dre == null)
                {
                    throw new NegocioException("Não foi possível localizar a Dre.");
                }
            }

            if (!string.IsNullOrEmpty(fechamentoReaberturaPersistenciaDto.UeCodigo))
            {
                ue = repositorioUe.ObterPorCodigo(fechamentoReaberturaPersistenciaDto.UeCodigo);
                if (ue == null)
                {
                    throw new NegocioException("Não foi possível localizar a UE.");
                }
            }

            var tipoCalendario = repositorioTipoCalendario.ObterPorId(fechamentoReaberturaPersistenciaDto.TipoCalendarioId);

            if (tipoCalendario == null)
            {
                throw new NegocioException("Não foi possível localizar o Tipo de Calendário.");
            }

            var fechamentoReabertura = new FechamentoReabertura()
            {
                Descricao = fechamentoReaberturaPersistenciaDto.Descricao,
                Fim       = fechamentoReaberturaPersistenciaDto.Fim,
                Inicio    = fechamentoReaberturaPersistenciaDto.Inicio
            };

            fechamentoReabertura.AtualizarDre(dre);
            fechamentoReabertura.AtualizarUe(ue);
            fechamentoReabertura.AtualizarTipoCalendario(tipoCalendario);

            fechamentoReaberturaPersistenciaDto.Bimestres.ToList().ForEach(bimestre =>
            {
                fechamentoReabertura.Adicionar(new FechamentoReaberturaBimestre()
                {
                    Bimestre = bimestre
                });
            });

            return(fechamentoReabertura);
        }
Exemplo n.º 4
0
        private (Dre, Ue) ObterDreEUe(string codigoDre, string codigoUe)
        {
            Dre dre = null;

            if (!string.IsNullOrWhiteSpace(codigoDre))
            {
                dre = repositorioDre.ObterPorCodigo(codigoDre.ToString());
            }
            Ue ue = null;

            if (!string.IsNullOrWhiteSpace(codigoUe))
            {
                ue = repositorioUe.ObterPorCodigo(codigoUe.ToString());
            }
            return(dre, ue);
        }