public MaterialApostilaAluno GetApostilaAtiva(int idMaterial, int matricula, int idVersao) { try { var apostila = new MaterialApostilaAluno(); using (MiniProfiler.Current.Step("Obter apostila do aluno atraves de matricula e versão")) { apostila = GetUltimaApostila(idMaterial, matricula, idVersao); } if (apostila == null) { using (MiniProfiler.Current.Step("Registrando nova apostila")) { if (!RegistraNovaApostila(idMaterial, matricula)) { return(new MaterialApostilaAluno()); } } using (MiniProfiler.Current.Step("Registrado progresso")) { RegistraProgresso(idMaterial, matricula); } using (MiniProfiler.Current.Step("Obtendo ultima apostila salva")) { return(GetUltimaApostila(idMaterial, matricula, idVersao)); } } return(apostila); } catch { throw; } }
public MaterialApostilaAluno LimpaVersoes(MaterialApostilaAluno apostila) { return(new MaterialApostilaEntity().LimpaVersoes(apostila.EntidadeId, apostila.ClientId)); }
public int PostModificacaoApostila(MaterialApostilaAluno apostila) { return(new MaterialApostilaEntity().PostModificacaoApostila(apostila.ClientId, apostila.ApostilaId, apostila.Conteudo)); }
public MaterialApostilaAluno GetUltimaApostila(int MaterialId, int matricula, int IdVersao) { var apostilaAluno = new MaterialApostilaAluno(); var materialApostilaAlunoManager = new MaterialApostilaAlunoManager(); using (var ctx = new DesenvContext()) { var query = (from a in ctx.tblMaterialApostilaAluno join b in ctx.tblMaterialApostila on a.intMaterialApostilaID equals b.intID where a.bitAtiva == 1 && a.intClientID == matricula && b.intProductId == MaterialId select new MaterialApostilaAluno() { DataAtualizacao = a.dteDataCriacao, Id = a.intID, PdfId = b.intProductId.Value, ClientId = a.intClientID.Value, ApostilaId = a.intMaterialApostilaID.Value, Ativa = a.bitAtiva == 1, EntidadeId = b.intProductId.Value }); apostilaAluno = query.OrderByDescending(x => x.Id).FirstOrDefault(); if (apostilaAluno != null) { apostilaAluno.DataRelease = GetDataReleaseApostila(MaterialId, matricula); var anoRelease = GetAnoReleaseApostila(MaterialId); apostilaAluno.Configs = ctx.tblMaterialApostilaConfig .Select(x => new MaterialApostilaConfig() { Descricao = x.txtDescricao, Ativa = x.bitAtiva }) .ToList(); //carrega o link do css da apostila var cssName = GetNameCss(MaterialId, anoRelease); apostilaAluno.LinkCss = GetApostilaCss(anoRelease, cssName); //carregar o material do aluno para obter o nome da apostila que está no S3 var materialApostilaAluno = ctx.tblMaterialApostilaAluno .Where(x => x.intClientID == matricula && x.intMaterialApostilaID == apostilaAluno.ApostilaId && x.bitAtiva == 1) .FirstOrDefault(); var apostilaVersao = Utilidades.GetDetalhesApostila(materialApostilaAluno); //carregar o conteudo da apostila do aluno string chave = Utilidades.CriarNomeApostila(matricula, apostilaAluno.ApostilaId, apostilaVersao.Versao); apostilaAluno.Conteudo = materialApostilaAlunoManager.ObterArquivo(chave); //retorna se o aluno tem permissão de edição do material var alunoEntity = new AlunoEntity(); if (alunoEntity.IsAlunoPendentePagamento(matricula)) { apostilaAluno.Bloqueado = false; } else { apostilaAluno.Bloqueado = alunoEntity.IsExAlunoTodosProdutos(matricula); } var anoAtual = Utilidades.GetYear(); var anoApostila = Utilidades.UnixTimeStampToDateTime(apostilaAluno.DataRelease).Year; apostilaAluno.NaoInterageDuvidas = apostilaAluno.Bloqueado ? apostilaAluno.Bloqueado : anoApostila < anoAtual; } } return(apostilaAluno); }