Exemple #1
0
        public void UpdateAllSaleRate()
        {
            var allItems = Context.Items;

            foreach (Item item in allItems)
            {
                item.QuantityWeaklySaleRate = 0;
            }

            TimeSpan weekAgo = new TimeSpan(7, 0, 0);
            List <ItemTransaction> validI_Ts = new List <ItemTransaction>();

            using (var itsRepo = new ItemTransactionsRepo(new InventoryContext()))
            {
                validI_Ts = itsRepo.AllItemTransactionFrom(weekAgo)
                            .ToList();
                itsRepo.Complete();
            }

            //each time an item is sold, increment its sale rate
            //by quantity sold
            foreach (ItemTransaction i_t in validI_Ts)
            {
                var currItem = i_t.Item;
                currItem.QuantityWeaklySaleRate += i_t.Quantity;
            }
        }
Exemple #2
0
 //constructor
 public UnitOfWork()
 {
     Context             = new InventoryContext();
     Items               = new ItemRepository(Context);
     ItemTransactions    = new ItemTransactionsRepo(Context);
     AdminAccounts       = new AdminAccountsRepo(Context);
     CurrentDeliveries   = new CurrentDeliveriesRepo(Context);
     CurrentReservations = new CurrentReservationsRepo(Context);
     ItemDeliveries      = new ItemDeliveriesRepo(Context);
     ItemReservations    = new ItemReservationsRepo(Context);
     PastDeliveries      = new PastDeliveriesRepo(Context);
     PastReservations    = new PastReservationsRepo(Context);
     StaffAccounts       = new StaffAccountsRepo(Context);
 }