コード例 #1
0
 public async Task SalvarAsync(RelatorioSemestralPAPAlunoSecao secaoRelatorioAluno)
 {
     if (secaoRelatorioAluno.Id > 0)
     {
         await database.Conexao.UpdateAsync(secaoRelatorioAluno);
     }
     else
     {
         secaoRelatorioAluno.Id = (long)await database.Conexao.InsertAsync(secaoRelatorioAluno);
     }
 }
 public async Task SalvarAsync(RelatorioSemestralPAPAlunoSecao secaoRelatorioAluno)
 => await repositorioRelatorioSemestralAlunoSecao.SalvarAsync(secaoRelatorioAluno);
コード例 #3
0
 public async Task RemoverAsync(RelatorioSemestralPAPAlunoSecao secaoRelatorioAluno)
 {
     await database.Conexao.DeleteAsync(secaoRelatorioAluno);
 }
コード例 #4
0
        public async Task <AuditoriaRelatorioSemestralAlunoDto> Salvar(string alunoCodigo, string turmaCodigo, int semestre, RelatorioSemestralAlunoPersistenciaDto relatorioSemestralAlunoDto)
        {
            var turma = await ObterTurma(turmaCodigo);

            await ValidarPersistenciaTurmaSemestre(turma, semestre);

            var relatorioSemestralAluno = relatorioSemestralAlunoDto.RelatorioSemestralAlunoId > 0 ?
                                          await repositorioRelatorioSemestralAluno.ObterCompletoPorIdAsync(relatorioSemestralAlunoDto.RelatorioSemestralAlunoId) :
                                          await NovoRelatorioSemestralAluno(relatorioSemestralAlunoDto.RelatorioSemestralId, alunoCodigo, turma, semestre, relatorioSemestralAlunoDto);

            using (var transacao = unitOfWork.IniciarTransacao())
            {
                try
                {
                    // Relatorio Semestral
                    if (relatorioSemestralAluno.RelatorioSemestralTurmaPAP != null)
                    {
                        await comandosRelatorioSemestral.SalvarAsync(relatorioSemestralAluno.RelatorioSemestralTurmaPAP);

                        relatorioSemestralAluno.RelatorioSemestralTurmaPAPId = relatorioSemestralAluno.RelatorioSemestralTurmaPAP.Id;
                    }

                    // Relatorio Semestral Aluno
                    await repositorioRelatorioSemestralAluno.SalvarAsync(relatorioSemestralAluno);

                    foreach (var secaoRelatorio in relatorioSemestralAlunoDto.Secoes)
                    {
                        var secaoRelatorioAluno = relatorioSemestralAluno.Secoes.FirstOrDefault(c => c.SecaoRelatorioSemestralPAPId == secaoRelatorio.Id);
                        if (secaoRelatorioAluno != null)
                        {
                            secaoRelatorioAluno.RelatorioSemestralPAPAlunoId = relatorioSemestralAluno.Id;
                            secaoRelatorioAluno.Valor = secaoRelatorio.Valor;

                            if (!string.IsNullOrEmpty(secaoRelatorioAluno.Valor))
                            {
                                // Relatorio Semestral Aluno x Secao
                                await comandosRelatorioSemestralAlunoSecao.SalvarAsync(secaoRelatorioAluno);
                            }
                            else
                            {
                                await comandosRelatorioSemestralAlunoSecao.RemoverAsync(secaoRelatorioAluno);
                            }
                        }
                        else if (!string.IsNullOrEmpty(secaoRelatorio.Valor))
                        {
                            secaoRelatorioAluno = new RelatorioSemestralPAPAlunoSecao()
                            {
                                RelatorioSemestralPAPAlunoId = relatorioSemestralAlunoDto.RelatorioSemestralAlunoId,
                                SecaoRelatorioSemestralPAPId = secaoRelatorio.Id,
                                Valor = secaoRelatorio.Valor
                            };

                            await comandosRelatorioSemestralAlunoSecao.SalvarAsync(secaoRelatorioAluno);
                        }
                    }

                    unitOfWork.PersistirTransacao();
                }
                catch (Exception)
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }

            return(MapearParaAuditorio(relatorioSemestralAluno));
        }