Beispiel #1
0
        public buy getApprovedBuy(long productID, DateTime date, string storeName)
        {
            buy buy;

            using (var ctx = new approvedBuysContext())
            {
                buy = ctx.Buys.FirstOrDefault(b => b.productID == productID && b.date == date && b.storeName == storeName);
            }
            return(buy);
        }
Beispiel #2
0
        public List <buy> getApprovedBuys()
        {
            List <buy> Buys = new List <buy>();

            using (var ctx = new approvedBuysContext())
            {
                Buys = ctx.Buys.ToList();
            }
            return(Buys);
        }
Beispiel #3
0
        public void updateAppruvedBuy(buy newBuy)
        {
            buy buy;

            using (var ctx = new approvedBuysContext())
            {
                buy = ctx.Buys.FirstOrDefault(b => b.productID == newBuy.productID && b.date == newBuy.date && b.storeName == newBuy.storeName);
                buy.DeepCopy(newBuy);
                ctx.SaveChanges();
            }
        }
Beispiel #4
0
 public void addApprovedBuy(buy newBuy)
 {
     try
     {
         using (var ctx = new approvedBuysContext())
         {
             ctx.Buys.Add(newBuy);
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         buy   buy         = getApprovedBuy(newBuy.productID, newBuy.date, newBuy.storeName);
         float pricePerOne = buy.price / buy.amount;
         buy.amount += newBuy.amount;
         buy.price  += pricePerOne;
         updateAppruvedBuy(buy);
     }
 }