Example #1
0
        public async Task VerificaPersistenciaGeral(Turma turma)
        {
            var tipoCalendario = await repositorioTipoCalendario.BuscarPorAnoLetivoEModalidade(turma.AnoLetivo, turma.ObterModalidadeTipoCalendario(), turma.Semestre);

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

            var diaAtual = DateTime.Today;

            var eventoFechamento = await repositorioEvento.EventosNosDiasETipo(diaAtual, diaAtual, TipoEvento.FechamentoBimestre, tipoCalendario.Id, turma.Ue.CodigoUe, turma.Ue.Dre.CodigoDre);

            if (eventoFechamento == null || !eventoFechamento.Any())
            {
                throw new NegocioException("Não foi possível localizar um fechamento de período ou reabertura para esta turma.");
            }

            var professorRf = servicoUsuario.ObterRf();
            var professorPodePersistirTurma = await servicoEOL.ProfessorPodePersistirTurma(professorRf, turma.CodigoTurma, diaAtual);

            if (!professorPodePersistirTurma)
            {
                throw new NegocioException("Você não pode executar alterações nesta turma.");
            }
        }
        private async Task <bool> UeEmReaberturaDeFechamento(long tipoCalendarioId, string ueCodigo, string dreCodigo, int bimestre, DateTime dataReferencia)
        {
            // Busca eventos de fechamento na data atual
            var eventosFechamento = await repositorioEvento.EventosNosDiasETipo(dataReferencia, dataReferencia,
                                                                                TipoEvento.FechamentoBimestre, tipoCalendarioId, ueCodigo, dreCodigo);

            foreach (var eventoFechamento in eventosFechamento)
            {
                // Verifica existencia de reabertura de fechamento com mesmo inicio e fim do evento de fechamento
                var reaberturasPeriodo = await repositorioFechamentoReabertura.ObterReaberturaFechamentoBimestre(
                    bimestre,
                    eventoFechamento.DataInicio,
                    eventoFechamento.DataFim,
                    tipoCalendarioId,
                    dreCodigo,
                    ueCodigo);

                if (reaberturasPeriodo != null && reaberturasPeriodo.Any())
                {
                    return(true);
                }
            }

            return(false);
        }