private List <DTOMensagemGuia> VerificarPrimeiroAcesso(UsuarioTrilha matricula, enumMomento momento, PontoSebrae pontoSebrae = null) { try { var mensagens = new List <DTOMensagemGuia>(); // Refresh básico da matrícula. Foi mal, mas estamos com pressa. var trilha = new ManterTrilha().ObterTrilhaPorId(matricula.TrilhaNivel.Trilha.ID); if (matricula.ListaVisualizacoesMensagemGuia.All(x => x.MensagemGuia.ID != momento)) { var mensagem = new ManterMensagemGuia().ObterPorId(momento); var visualizacao = RegistrarVisualizacao(matricula, mensagem); // Caso tenha um tutorial vinculado if (mensagem.Tipo == enumTipoMensagemGuia.Tutorial) { mensagens.Add(new DTOMensagemGuia(visualizacao.ID, ObterTutoriaisMensagemGuia(mensagem.Tutoriais))); return(mensagens); } mensagens.Add(new DTOMensagemGuia(visualizacao.ID, mensagem.ObterTexto(trilha, matricula, pontoSebrae: pontoSebrae))); return(mensagens); } return(null); } catch { return(null); } }
private void ValidarDependencias(PontoSebrae ponto) { if (ponto.ListaMissoes.Count > 0) { throw new AcademicoException("Não é possível excluir o registro, existem missões vincualdas ao ponto sebrae"); } }
private DTOMensagemGuia VerificarHistoricoLider(UsuarioTrilha matricula, PontoSebrae pontoSebrae) { var manterLogLider = new ManterLogLider(); var trilha = new ManterTrilha().ObterTrilhaPorId(matricula.TrilhaNivel.Trilha.ID); // Só interessa obter os dois últimos logs. var ultimosLogs = manterLogLider.ObterPorAlunoPontoSebrae(matricula, pontoSebrae) .Where(x => x.PontoSebrae.ID == pontoSebrae.ID) .OrderByDescending(x => x.ID) .Take(2) .ToList(); // Só interessa se a quantidade de logs for maior que 1. Se houver somente 1 log, não é necessário exibir nenhuma msg. if (ultimosLogs.Count() > 1) { var ultimoLog = ultimosLogs[0]; var penultimoLog = ultimosLogs[1]; // Explicando a lógica complicada abaixo: // Se não havia líder no último acesso e agora tem, exibe a msg do primeiro líder. // Caso existem líderes nos dois últimos logs, mas sejam líderes diferentes, exibe a msg. // Se nenhuma condição for satisfeita, retorna null e escapa da mensagem. var momento = penultimoLog.Lider == null && ultimoLog.Lider != null ? enumMomento.PrimeiroLiderLojaUltimoAcesso : (penultimoLog.Lider != null && ultimoLog.Lider != null && penultimoLog.Lider.ID != ultimoLog.Lider.ID ? (enumMomento?)enumMomento.AlteracaoLiderLojaUltimoAcesso : null); // Ragequit. if (momento == null) { return(null); } var mensagem = new ManterMensagemGuia().ObterPorId(momento.Value); // Verificar se a última visualização da mensagem foi para o líder atual. // Só faz sentido ser executado caso o momento seja AlteracaoLiderLojaUltimoAcesso if (momento.Value == enumMomento.AlteracaoLiderLojaUltimoAcesso && mensagem.ListaUsuarioTrilhaMensagemGuia.LastOrDefault( x => x.UsuarioTrilha.ID == matricula.ID && x.LogLider != null && x.LogLider.Lider.ID == penultimoLog.Lider.ID) != null) { return(null); } var visualizacao = RegistrarVisualizacao(matricula, mensagem, ultimoLog); return(new DTOMensagemGuia(visualizacao.ID, mensagem.ObterTexto(trilha, matricula, ultimoLog, pontoSebrae: pontoSebrae))); } return(null); }
/// <summary> /// Validação das informações de um Tópico Temático. /// </summary> /// <param name="pontoSebrae"></param> public void ValidarTrilhaTopicoTematicoInformado(PontoSebrae pontoSebrae) { ValidarInstancia(pontoSebrae); if (string.IsNullOrWhiteSpace(pontoSebrae.Nome)) { throw new AcademicoException("Nome. Campo Obrigatório"); } VerificarExistenciaPontoSebrae(pontoSebrae); }
private void PreencherComboMissao(PontoSebrae pontoSebrae) { var listaMissao = new ManterMissao().ObterPorPontoSebrae(pontoSebrae); if (listaMissao != null && listaMissao.Any()) { WebFormHelper.PreencherLista(listaMissao, ddlMissao, false, true); } else { ddlTrilhaNivel.Items.Clear(); } }
private void VerificarExistenciaPontoSebrae(PontoSebrae pontoSebrae) { var pontoSebraeCadastrado = ObterPrimeiroPorNome(pontoSebrae); if (pontoSebraeCadastrado != null) { if (pontoSebrae.ID != pontoSebraeCadastrado.ID) { throw new AcademicoException(string.Format("O Ponto Sebrae '{0}' já está cadastrado", pontoSebrae.Nome.Trim())); } } }
public void IncluirPontoSebrae(PontoSebrae pontoSebrae) { _bmPontoSebrae.ValidarTrilhaTopicoTematicoInformado(pontoSebrae); var pontosSebrae = ObterPontoSebraePorNome(pontoSebrae.Nome); if (pontosSebrae != null && pontosSebrae.Any()) { throw new AcademicoException("Este Ponto Sebrae Já está Cadastrado!"); } _bmPontoSebrae.Salvar(pontoSebrae); }
public void Excluir(PontoSebrae pontoSebrae) { try { ValidarDependencias(pontoSebrae); _repositorio.Excluir(pontoSebrae); } catch (AcademicoException e) { WebFormHelper.ExibirMensagem(Dominio.Enumeracao.enumTipoMensagem.Erro, e.Message); } catch (Exception) { } }
public void ExcluirPontoSebrae(int pontoSebraeId) { try { PontoSebrae pontoSebrae = null; if (pontoSebraeId > 0) { pontoSebrae = _bmPontoSebrae.ObterPorId(pontoSebraeId); } _bmPontoSebrae.Excluir(pontoSebrae); } catch (AcademicoException ex) { throw ex; } }
public IQueryable <PontoSebrae> ObterPorFiltro(PontoSebrae pontoSebrae) { var query = _repositorio.session.Query <PontoSebrae>(); if (pontoSebrae != null) { if (!string.IsNullOrWhiteSpace(pontoSebrae.Nome)) { query = query.Where(x => x.Nome.Contains(pontoSebrae.Nome.ToUpper())); } } if (pontoSebrae.TrilhaNivel != null) { query = query.Where(x => x.TrilhaNivel.ID == pontoSebrae.TrilhaNivel.ID); } return(query); }
public IQueryable <LogLider> ObterPorAlunoPontoSebrae(UsuarioTrilha aluno, PontoSebrae pontoSebrae) { return(_repositorio.ObterTodosIQueryable().Where(x => x.Aluno.ID == aluno.ID && x.PontoSebrae.ID == pontoSebrae.ID)); }
public IQueryable <LogLider> ObterPorAlunoPontoSebrae(UsuarioTrilha aluno, PontoSebrae pontoSebrae) { return(_bmLogLider.ObterPorAlunoPontoSebrae(aluno, pontoSebrae)); }
public IQueryable <PontoSebrae> ObterPontoSebraePorFiltro(PontoSebrae pontoSebrae) { return(_bmPontoSebrae.ObterPorFiltro(pontoSebrae)); }
public void AlterarPontoSebrae(PontoSebrae pontoSebrae) { _bmPontoSebrae.ValidarTrilhaTopicoTematicoInformado(pontoSebrae); _bmPontoSebrae.Salvar(pontoSebrae); }
private DTOMensagemGuia VerificarConclusaoMetadeSolucoesLoja(UsuarioTrilha matricula, PontoSebrae pontoSebrae) { try { var trilha = new ManterTrilha().ObterTrilhaPorId(matricula.TrilhaNivel.Trilha.ID); // Refresh básico da loja. Foi mal, mas estamos com pressa. pontoSebrae = new ManterPontoSebrae().ObterPorId(pontoSebrae.ID); var momento = enumMomento.ConcluirMetadeSolucoesLoja; // Refresh básico da matrícula. Foi mal, mas estamos com pressa. matricula = new ManterUsuarioTrilha().ObterPorId(matricula.ID); var solucoesSebrae = pontoSebrae.ObterItensTrilha(); if (!new ManterUsuarioTrilhaMensagemGuia().ObterTodos() .Any( x => x.UsuarioTrilha.ID == matricula.ID && x.ItemTrilha.Missao.PontoSebrae.ID == pontoSebrae.ID && x.MensagemGuia.ID == momento)) { var concluidos = solucoesSebrae .Count( x => x.Usuario == null && x.Missao.PontoSebrae.TrilhaNivel.ID == matricula.TrilhaNivel.ID && x.PodeExibir() && x.ObterStatusParticipacoesItemTrilha(matricula) == enumStatusParticipacaoItemTrilha.Aprovado && x.Ativo.Value); if (concluidos > 0) { var mensagem = new ManterMensagemGuia().ObterPorId(momento); var ids = solucoesSebrae.Select(x => new { x.ID }).Select(x => x.ID).ToList(); var solucaoSebraeMetade = solucoesSebrae .FirstOrDefault(x => ids.IndexOf(x.ID) >= concluidos / 2); var visualizacao = RegistrarVisualizacao(matricula, mensagem, null, solucaoSebraeMetade); return(new DTOMensagemGuia(visualizacao.ID, mensagem.ObterTexto(trilha, matricula, solucaoSebrae: solucaoSebraeMetade, pontoSebrae: pontoSebrae))); } } return(null); } catch (Exception) { return(null); } }
public PontoSebraeParticipacao ObterPorUsuarioPontoSebrae(UsuarioTrilha usuarioTrilha, PontoSebrae pontoSebrae) { var query = repositorio.session.Query <PontoSebraeParticipacao>(); return(query.FirstOrDefault(x => x.UsuarioTrilha == usuarioTrilha && x.PontoSebrae.ID == pontoSebrae.ID)); }
private DTOMensagemGuia VerificarConclusaoTodasSolucoesLoja(UsuarioTrilha matricula, PontoSebrae pontoSebrae) { try { var trilha = new ManterTrilha().ObterTrilhaPorId(matricula.TrilhaNivel.Trilha.ID); // Refresh básico da loja. Foi mal, mas estamos com pressa. pontoSebrae = new ManterPontoSebrae().ObterPorId(pontoSebrae.ID); var momento = enumMomento.ConclusoesTodasSolucoesLoja; // Refresh básico da matrícula. Foi mal, mas estamos com pressa. matricula = new ManterUsuarioTrilha().ObterPorId(matricula.ID); if ( !new ManterUsuarioTrilhaMensagemGuia().ObterTodos() .Any( x => x.UsuarioTrilha.ID == matricula.ID && x.ItemTrilha.Missao.PontoSebrae.ID == pontoSebrae.ID && x.MensagemGuia.ID == momento)) { var total = pontoSebrae.ObterItensTrilha() .Count( x => x.Usuario == null && x.Missao.PontoSebrae.TrilhaNivel.ID == matricula.TrilhaNivel.ID && x.PodeExibir() && x.Ativo.Value); var concluidos = pontoSebrae.ObterItensTrilha() .Count( x => x.Usuario == null && x.Missao.PontoSebrae.TrilhaNivel.ID == matricula.TrilhaNivel.ID && x.PodeExibir() && x.ObterStatusParticipacoesItemTrilha(matricula) == enumStatusParticipacaoItemTrilha.Aprovado && x.Ativo.Value); if (total > 0 && concluidos == total) { var mensagem = new ManterMensagemGuia().ObterPorId(momento); var ultimaSolucaoSebrae = pontoSebrae.ObterItensTrilha() .LastOrDefault( x => x.Missao.PontoSebrae.ID == pontoSebrae.ID && x.ListaItemTrilhaParticipacao.Any() && x.ListaItemTrilhaParticipacao.FirstOrDefault().UsuarioTrilha.ID == matricula.ID); var visualizacao = RegistrarVisualizacao(matricula, mensagem, null, ultimaSolucaoSebrae); return(new DTOMensagemGuia(visualizacao.ID, mensagem.ObterTexto(trilha, matricula, solucaoSebrae: ultimaSolucaoSebrae, pontoSebrae: pontoSebrae))); } } return(null); } catch { return(null); } }
public IQueryable <Missao> ObterPorPontoSebrae(PontoSebrae pontoSebrae) { return(ObterTodosIQueryable().Where(x => x.PontoSebrae.ID == pontoSebrae.ID)); }
public List <DTOMensagemGuia> ObterMensagensGuiaLoja(UsuarioTrilha matricula, PontoSebrae pontoSebrae) { var retorno = new List <DTOMensagemGuia>(); // Primeiro acesso à loja. var mensagemPrimeiroAcesso = VerificarPrimeiroAcesso(matricula, enumMomento.PrimeiroAcessoLoja, pontoSebrae); if (mensagemPrimeiroAcesso != null) { retorno = mensagemPrimeiroAcesso; } // Verificar histórico de líderes. var mensagemHistoricoLider = VerificarHistoricoLider(matricula, pontoSebrae); if (mensagemHistoricoLider != null) { retorno.Add(mensagemHistoricoLider); } // Primeira conclusão. var mensagemPrimeiraConclusaoSolucaoSebrae = VerificarPrimeiraConclusaoSolucaoSebrae(matricula); if (mensagemPrimeiraConclusaoSolucaoSebrae != null) { retorno.Add(mensagemPrimeiraConclusaoSolucaoSebrae); } // Demais conclusões. var mensagensDemaisConclusaoSolucaoSebrae = VerificarDemaisConclusoesSolucaoSebrae(matricula); if (mensagensDemaisConclusaoSolucaoSebrae.Any()) { retorno.AddRange(mensagensDemaisConclusaoSolucaoSebrae); } // Metade conclusão. var mensagemMetadeSolucoesSebrae = VerificarConclusaoMetadeSolucoesLoja(matricula, pontoSebrae); if (mensagemMetadeSolucoesSebrae != null) { retorno.Add(mensagemMetadeSolucoesSebrae); } // Concluiu metade das soluções var mensagensConcluiuTodasSolucoesSebrae = VerificarConclusaoTodasSolucoesLoja(matricula, pontoSebrae); if (mensagensConcluiuTodasSolucoesSebrae != null) { retorno.Add(mensagensConcluiuTodasSolucoesSebrae); } // Possuí o mínimo de moedas para prova final var mensagensPossuiMoedasProvaFinal = VerificarMoedasProvaFinal(matricula); if (mensagensPossuiMoedasProvaFinal != null) { retorno.Add(mensagensPossuiMoedasProvaFinal); } var mensagemEvolucaoPin = VerificarEvolucaoPin(matricula); if (mensagemEvolucaoPin != null) { retorno.Add(mensagemEvolucaoPin); } return(retorno); }
public PontoSebrae ObterPrimeiroPorNome(PontoSebrae pontoSebrae) { return(ObterPrimeiroPorNome(pontoSebrae.Nome)); }
public IQueryable <PontoSebrae> ObterPorNome(PontoSebrae pontoSebrae) { return(ObterPorNome(pontoSebrae.Nome)); }
public void Salvar(PontoSebrae pontoSebrae) { _repositorio.Salvar(pontoSebrae); }