Пример #1
0
        public static void CheckContractDeadlines()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var customerList             = context.Customers.Include(i => i.ServiceContract).ToList();

            //
            foreach (var item in context.Customers)
            {
                var serviceContractEndMonth = item.ServiceContract.Months - DateTime.Now.Month;
                if (serviceContractEndMonth == 0)
                {
                    PushBullet.StockAlert();
                    Mailer.SendSimpleMessage(1, "Your contract is about to expire.");
                }
            }
        }
Пример #2
0
        public static void CheckStockLimits()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            foreach (var contextStockItem in context.StockItems)
            {
                if (contextStockItem.LimitWarning >= contextStockItem.QuantityAvailable && contextStockItem.FlagCheck == false)
                {
                    PushBullet.StockAlert();
                    Mailer.SendSimpleMessage(1, "There is a snake in my boot.");
                    //var currentItem = context.StockItems.SingleOrDefault(s => s.Id == contextStockItem.Id);
                    contextStockItem.FlagCheck            = true;
                    context.Entry(contextStockItem).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }