Exemple #1
0
        private PeriodoFechamento MapearParaDominio(FechamentoDto fechamentoDto)
        {
            var(dre, ue) = ObterDreEUe(fechamentoDto.DreId, fechamentoDto.UeId);
            var fechamento = repositorioFechamento.ObterPorTipoCalendarioDreEUE(fechamentoDto.TipoCalendarioId.Value, dre?.Id, ue?.Id);

            if (fechamento == null)
            {
                fechamento = new PeriodoFechamento(dre, ue);
            }

            var tipoCalendario = repositorioTipoCalendario.ObterPorId(fechamentoDto.TipoCalendarioId.Value);

            if (tipoCalendario == null)
            {
                throw new NegocioException("Tipo calendário não encontrado.");
            }

            if (fechamentoDto.FechamentosBimestres != null && fechamentoDto.FechamentosBimestres.Any())
            {
                foreach (var bimestre in fechamentoDto.FechamentosBimestres)
                {
                    var periodoEscolar = repositorioPeriodoEscolar.ObterPorId(bimestre.PeriodoEscolarId);
                    PeriodoFechamentoBimestre fechamentoBimestreExistente = fechamento.ObterFechamentoBimestre(bimestre.PeriodoEscolarId);
                    if (fechamentoBimestreExistente != null)
                    {
                        fechamentoBimestreExistente.AtualizarDatas(bimestre.InicioDoFechamento, bimestre.FinalDoFechamento);
                    }
                    else
                    {
                        fechamento.AdicionarFechamentoBimestre(new PeriodoFechamentoBimestre(fechamento.Id, periodoEscolar, bimestre.InicioDoFechamento, bimestre.FinalDoFechamento));
                    }
                }
            }
            return(fechamento);
        }
        private PeriodoEscolar ObterPeriodo(long Id, PeriodoEscolarDto periodo)
        {
            var periodoSalvar = repositorioPeriodo.ObterPorId(Id);

            periodoSalvar.PeriodoInicio = periodo.PeriodoInicio.Date;
            periodoSalvar.PeriodoFim    = periodo.PeriodoFim.Date;

            return(periodoSalvar);
        }
Exemple #3
0
        public async Task Reprocessar(long fechamentoTurmaDisciplinaId)
        {
            var fechamentoTurmaDisciplina = repositorioFechamentoTurmaDisciplina.ObterPorId(fechamentoTurmaDisciplinaId);

            if (fechamentoTurmaDisciplina == null)
            {
                throw new NegocioException("Fechamento ainda não realizado para essa turma.");
            }

            var turma = await repositorioTurma.ObterTurmaComUeEDrePorId(fechamentoTurmaDisciplina.FechamentoTurma.TurmaId);

            if (turma == null)
            {
                throw new NegocioException("Turma não encontrada.");
            }

            var disciplinaEOL = (await repositorioComponenteCurricular.ObterDisciplinasPorIds(new long[] { fechamentoTurmaDisciplina.DisciplinaId })).ToList().FirstOrDefault();

            if (disciplinaEOL == null)
            {
                throw new NegocioException("Componente Curricular não localizado.");
            }

            var periodoEscolar = repositorioPeriodoEscolar.ObterPorId(fechamentoTurmaDisciplina.FechamentoTurma.PeriodoEscolarId.Value);

            if (periodoEscolar == null)
            {
                throw new NegocioException("Período escolar não encontrado.");
            }

            fechamentoTurmaDisciplina.AdicionarPeriodoEscolar(periodoEscolar);
            fechamentoTurmaDisciplina.AtualizarSituacao(SituacaoFechamento.EmProcessamento);
            repositorioFechamentoTurmaDisciplina.Salvar(fechamentoTurmaDisciplina);

            var usuarioLogado = await servicoUsuario.ObterUsuarioLogado();

            Cliente.Executar <IServicoFechamentoTurmaDisciplina>(c => c.GerarPendenciasFechamento(fechamentoTurmaDisciplina.DisciplinaId, turma, periodoEscolar, fechamentoTurmaDisciplina, usuarioLogado, !disciplinaEOL.LancaNota, disciplinaEOL.RegistraFrequencia));
        }