public bool AlreadyWinner(int idPerson)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt.Where(w => w.idPerson == idPerson).Any(a => a.isValidated == true));
     }
 }
 public int GetCountByParticipation(string productType)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt.Count());
     }
 }
 public int GetCountBy(int idPerson, string productType)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt.Count(r => r.idPerson == idPerson));
     }
 }
 public int GetCountBy(string productType, bool isWinner)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt.Count(r => r.isValidated == isWinner));
     }
 }
 public int NumberCoupons()
 {
     using (var context = new GymPass())
     {
         return(context.Voucher.Where(v => v.idPerson != null).ToList().Count);
     }
 }
 public BlockedCPF GetCPF(long CPF)
 {
     using (var context = new GymPass())
     {
         return(context.BlockedCPF.Where(b => b.CPF == CPF).FirstOrDefault());
     }
 }
 public TEntity Get(int id)
 {
     using (var context = new GymPass())
     {
         return(context.Set <TEntity>().Find(id));
     }
 }
 public int GetCountByNotWinners()
 {
     using (var context = new GymPass())
     {
         return(context.Receipt.Count(r => r.isValidated == true));
     }
 }
示例#9
0
 public AdminAccount GetByCredentials(string username, string password)
 {
     using (var context = new GymPass())
     {
         return(context.AdminAccount.FirstOrDefault(aa => aa.Username == username && aa.Password == password));
     }
 }
 public void Insert(TEntity entity)
 {
     using (var context = new GymPass())
     {
         context.Set <TEntity>().Add(entity);
         context.SaveChanges();
     }
 }
 public void Update(TEntity entity)
 {
     using (var context = new GymPass())
     {
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public int GetCountByAll(string productType = null)
 {
     using (var context = new GymPass())
     {
         //var query = context.Receipt.Where(r => r.Product.type == productType).ToList();
         //return query.Count();
         return(0);
     }
 }
 public List <ViewReceiptExport> GetReceiptsBy2(DateTime @from, DateTime to)
 {
     using (var context = new GymPass())
     {
         return(context.ViewReceiptExport
                .Where(v => v.Data_do_Cadastro_do_Recibo > from && v.Data_do_Cadastro_do_Recibo < to)
                .ToList());
     }
 }
 public IEnumerable <ConfigPromotion> GetByType(string type)
 {
     using (var context = new GymPass())
     {
         return(context.ConfigPromotion
                .Where(p => p.type == type)
                .ToList());
     }
 }
 public Receipt GetLastBy(int idPerson, string productType)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                .Where(r => r.idPerson == idPerson)
                .OrderByDescending(r => r.dtCreation)
                .FirstOrDefault());
     }
 }
 public Person GetByCpf(string cpf)
 {
     using (var context = new GymPass())
     {
         return(context.Person
                .Where(pd => pd.cpf == cpf)
                .Include(pd => pd.Receipt)
                .FirstOrDefault());
     }
 }
 public Receipt GetReceiptWinnerByIdPerson(int idPerson)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                .Include(r => r.Person)
                .Where(r => r.idPerson == idPerson && r.isValidated == true)
                .FirstOrDefault());
     }
 }
 public Receipt GetLastBy(bool isWinner, string productType)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                //.Where(r => r.Product.type == productType)
                .OrderByDescending(r => r.dtCreation)
                .FirstOrDefault());
     }
 }
 public IEnumerable <Person> GetBy(DateTime @from, DateTime to)
 {
     using (var context = new GymPass())
     {
         return(context.Person
                .Where(p => p.dtCreation >= from &&
                       p.dtCreation <= to)
                .ToList());
     }
 }
 public Receipt GetById(int idReceipt)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                .Include(r => r.Person)
                .Where(r => r.idReceipt == idReceipt)
                .OrderByDescending(r => r.dtCreation)
                .FirstOrDefault());
     }
 }
 public Person GetByCpfNotBlackList(string cpf)
 {
     using (var context = new GymPass())
     {
         return(context.Person
                .Where(pd => pd.cpf == cpf)
                .Include(pd => pd.Receipt)
                //.Include(pd => pd.Receipt.Select(r => r.Product))
                .FirstOrDefault());
     }
 }
 public List <Receipt> GetReceiptsBy(DateTime @from, DateTime to)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                //.Include(r => r.LuckyCode)
                .Include(r => r.Person)
                //.Include(r => r.Product)
                .Where(r => r.dtCreation >= from && r.dtCreation <= to)
                .ToList());
     }
 }
 public List <Receipt> GetReceiptsByIdPerson(int idPerson)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                //.Include(r => r.LuckyCode)
                .Include(r => r.Person)
                //.Include(r => r.Product)
                .Where(r => r.idPerson == idPerson)
                .ToList());
     }
 }
        public List <Receipt> GetReceiptsByWinners(string type)
        {
            using (var context = new GymPass())
            {
                var entity = context.Receipt
                             //.Where(r => r.isValidated == true && r.Product.type == type)
                             .Where(r => r.isValidated == true)
                             .ToList();

                return(entity);
            }
        }
 public List <Receipt> GetBy(string type, bool isWinner, bool?isValidated)
 {
     using (var context = new GymPass())
     {
         return(context.Receipt
                .Include(rts => rts.Person)
                //.Include(rts => rts.LuckyCode)
                //.Include(rts => rts.Product)
                .Where(r => r.isValidated == isValidated)
                .OrderByDescending(r => r.dtCreation)
                .ToList());
     }
 }
        public int GetCountBy(DateTime dtSince, DateTime?dtUntil = null)
        {
            using (var context = new GymPass())
            {
                var query = context.Person.Where(r => r.dtCreation >= dtSince).AsQueryable();

                if (dtUntil != null)
                {
                    query = query.Where(r => r.dtCreation <= dtUntil);
                }
                return(query.Count());
            }
        }
 public Person GetById(int id)
 {
     using (var context = new GymPass())
     {
         return(context.Person
                .Where(pd => pd.idPerson == id)
                .Include(pd => pd.Receipt)
                //.Include(pd => pd.Receipt.Select(r => r.Product))
                //.Include(pd => pd.Address)
                //.Include(pd => pd.Address.City)
                .FirstOrDefault());
     }
 }
        public void DeclaredWinner(Receipt receipt)
        {
            using (var context = new GymPass())
            {
                var entity = context.Receipt.FirstOrDefault(r => r.idReceipt == receipt.idReceipt);

                if (entity != null)
                {
                    entity.isValidated = true;
                }

                context.SaveChanges();
            }
        }
 public Voucher GenarateWinner(int idPerson)
 {
     using (var context = new GymPass())
     {
         var voucher = context.Voucher.Where(v => v.idPerson == null).OrderBy(v => v.code).First();
         if (voucher != null)
         {
             voucher.idPerson = idPerson;
             voucher.dtWinner = DateTime.Now;
         }
         context.SaveChanges();
         return(voucher);
     }
 }
示例#30
0
 public IEnumerable <NewsSending> GetToSend(int count)
 {
     using (var context = new GymPass())
     {
         return(context.NewsSending
                .Include(ns => ns.Person)
                .Include(ns => ns.Receipt)
                //.Include(ns => ns.Receipt.Product)
                .Include(ns => ns.Receipt.Person)
                //.Include(ns => ns.Receipt.LuckyCode)
                .Where(ns => ns.dtSending == null)
                .OrderBy(ns => ns.idNewsSending)
                .Take(count)
                .ToList());
     }
 }