Example #1
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
     }
 }
Example #2
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         context.Stocks.Add(stock);
         context.SaveChanges();
     }
 }
Example #3
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         context.Animals.Add(animal);
         context.SaveChanges();
     }
     // using is the equivalent of try-catch-finally all rolled together.
 }
Example #4
0
        public void executeBusinessLogic()
        {
            using (PetShopDBContext context = new PetShopDBContext())
            {
                var query = from stock in context.Stocks where stock.ID == _id select stock;
                List<Stocks> stocks = query.ToList();

                foreach(Stocks st in stocks)
                {
                    st.MARKUP = _newmark;
                    double priceOfEachItem = st.PRICE / st.STOCKLEFT;
                    double markupMargin = (priceOfEachItem * _newmark) / 100;
                    double targetprice = markupMargin + priceOfEachItem;
                    st.TARGETSALEMK = targetprice * st.STOCKLEFT;
                    st.PRICE_TOMEET_MARK = targetprice;
                }

                context.SaveChanges();
            }
        }
Example #5
0
        public void executeBusinessLogic()
        {
            using (PetShopDBContext context = new PetShopDBContext())
            {
                context.AnimalSolds.Add(animalsold);
                context.SaveChanges();
            }

            System.Windows.Forms.MessageBox.Show("Updating animal database");

            using (PetShopDBContext contect = new PetShopDBContext())
            {
                var qur = from ani in contect.Animals where ani.ID == _id select ani;
                List<Animals> lis = qur.ToList();

                foreach(Animals animal in lis)
                {
                    animal.STATUS = "SOLD";
                    contect.SaveChanges();
                }
            }
        }