Beispiel #1
0
        /// <summary>
        /// Verifica se já existe um usuário com o email passado por parâmetro
        /// </summary>
        /// <param name="integrante"></param>
        /// <param name="tipoOperacao"></param>
        /// <returns></returns>
        public static bool VericarEmailExistente(Integrante integrante, TipoOperacao tipoOperacao)
        {
            Contexto db = new Contexto();

            List<Integrante> integrantes = (from c in db.Integrantes
                                      where c.Email.Equals(integrante.Email)
                                      select c).ToList();

            if (!string.IsNullOrEmpty(integrante.Email))
            {
                if (tipoOperacao.Equals(TipoOperacao.Create))
                {
                    if (integrantes.Count > 0)
                        return true;
                }
                else if (tipoOperacao.Equals(TipoOperacao.Update))
                {
                    if (integrantes.Count > 0)
                    {
                        foreach (Integrante user in integrantes)
                        {
                            if (user.Email.Equals(integrante.Email) && user.ID != integrante.ID)
                            {
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        }
Beispiel #2
0
        public static void GravarErro(Exception exception, string usuario)
        {
            Log log = new Log()
            {
                TipoLog = TipoLog.Erro,
                Observacao = exception.StackTrace,
                Usuario = usuario,
                DataHora = DateTime.Now
            };

            if (exception.InnerException != null)
            {
                log.Mensagem = exception.InnerException.ToString();
            }
            else
            {
                log.Mensagem = exception.Message;
            }

            using (Contexto db = new Contexto())
            {
                db.Logs.Add(log);
                db.SaveChanges();
            }
        }
Beispiel #3
0
        public static Integrante RetornarIntegrante(int? id)
        {
            Contexto db = new Contexto();

            Integrante integrante = db.Integrantes.Where(i => i.ID == id).FirstOrDefault();

            return integrante;
        }
Beispiel #4
0
        public static TipoIntegrante RetornarTipoIntegrante(string email)
        {
            Contexto db = new Contexto();

            TipoIntegrante tipoIntegrante = db.Integrantes.Where(i => i.Email == email).FirstOrDefault().TipoIntegrante;

            return tipoIntegrante;
        }
Beispiel #5
0
        public static IQueryable<Integrante> RetornarIntegrantesAtivos()
        {
            Contexto db = new Contexto();

            IQueryable <Integrante> integrantes = db.Integrantes.Where(i => i.Ativo == true);

            return integrantes;
        }
Beispiel #6
0
        public static IQueryable<LocalJogo> RetornarLocaisJogoAtivos()
        {
            Contexto db = new Contexto();

            IQueryable<LocalJogo> localJogos = db.LocaisJogo.Where(l => l.Ativo == true);

            return localJogos;
        }
Beispiel #7
0
        public static LocalJogo RetornarLocalJogo(int? id)
        {
            Contexto db = new Contexto();

            LocalJogo localJogo = db.LocaisJogo.Where(l => l.ID == id).FirstOrDefault();

            return localJogo;
        }
Beispiel #8
0
        public static Integrante RetornarIntegranteMensalidades(int? integranteID, int? calendarioID)
        {
            Contexto db = new Contexto();

            Integrante integrante = db.Integrantes.Where(i => i.ID == integranteID).FirstOrDefault();

            integrante.Mensalidades = db.MensalidadesIntegrante.Where(m => m.CalendarioID == calendarioID && m.IntegranteID == integranteID).ToList();

            return integrante;
        }
Beispiel #9
0
        public static void GravarInformacao(string mensagem, string observacao, string usuario)
        {
            Log log = new Log()
            {
                TipoLog = TipoLog.Informacao,
                Mensagem = mensagem,
                Observacao = observacao,
                Usuario = usuario,
                DataHora = DateTime.Now
            };

            using (Contexto db = new Contexto())
            {
                db.Logs.Add(log);
                db.SaveChanges();
            }
        }
Beispiel #10
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            if (FormsAuthentication.CookiesSupported == true)
            {
                if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
                {
                    try
                    {
                        //let us take out the username now
                        string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
                        string roles = string.Empty;

                        using (Contexto entities = new Contexto())
                        {
                            Integrante user = entities.Integrantes.SingleOrDefault(u => u.Email == username);

                            switch (user.TipoIntegrante)
                            {
                                case TipoIntegrante.Diretoria:
                                    roles = "Diretoria";
                                    break;
                                case TipoIntegrante.Integrante:
                                    roles = "Integrante";
                                    break;
                            }
                        }
                        //let us extract the roles from our own custom cookie

                        //Let us set the Pricipal with our user specific details
                        HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(
                          new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';'));
                    }
                    catch (Exception)
                    {
                        //somehting went wrong
                    }
                }
            }
        }
Beispiel #11
0
 public LocalJogoBll()
 {
     db = new Contexto();
 }
        public static int RetornarNumeroPagosMes(int ano, int mes)
        {
            Contexto db = new Contexto();

            IQueryable<MensalidadeIntegrante> mensalidades = (from m in db.MensalidadesIntegrante
                                                     where m.Integrante.Ativo
                                                     select m);

            return 0;
        }
 public MensalidadeIntegranteBll()
 {
     db = new Contexto();
 }
        public static IQueryable<MensalidadeIntegrante> RetornarMensalidadesIntegranteCalendario(int? integranteID, int? calendarioID)
        {
            Contexto db = new Contexto();

            IQueryable<MensalidadeIntegrante> mensalidades = db.MensalidadesIntegrante.Where(x => x.CalendarioID == calendarioID && x.IntegranteID == integranteID);

            return mensalidades;
        }
        public static MensalidadeIntegrante RetornarMensalidadeIntegranteCalendario(int? mensalidadeID)
        {
            Contexto db = new Contexto();

            MensalidadeIntegrante mensalidade = db.MensalidadesIntegrante.FirstOrDefault(x => x.ID == mensalidadeID);

            return mensalidade;
        }
        public static IList<MensalidadeIntegrante> RetornarMensalidadesSeremBaixadas(int? integranteID, int? calendarioID)
        {
            Contexto db = new Contexto();

            IQueryable<MensalidadeIntegrante> mensalidades = db.MensalidadesIntegrante.Where(x => x.CalendarioID == calendarioID && x.IntegranteID == integranteID);
            Calendario calendario = db.Calendarios.FirstOrDefault(c => c.ID == calendarioID);

            IList<MensalidadeIntegrante> mensalidadesSeremBaixadas = RetornarMesesAtivos(calendario, mensalidades);

            return mensalidadesSeremBaixadas;
        }
Beispiel #17
0
 public IntegranteBll()
 {
     db = new Contexto();
 }