Exemplo n.º 1
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         customers = context.Customers.ToList();
     }
 }
Exemplo n.º 2
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         stock = context.Stocks.ToList();
     }
 }
Exemplo n.º 3
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         var animlaQuery = from ani in context.Animals where ani.STATUS != "SOLD" select ani;
         Animals = animlaQuery.ToList();
     }
 }
Exemplo n.º 5
0
 public void executeBusinessLogic()
 {
     using (PetShopDBContext context = new PetShopDBContext())
     {
         context.Stocks.Add(stock);
         context.SaveChanges();
     }
 }
Exemplo n.º 6
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.
 }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
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();
                }
            }
        }
Exemplo n.º 9
0
        public void executeBusinessLogic()
        {
            HashSet<string> ste = new HashSet<string>();

            using (PetShopDBContext conetxt = new PetShopDBContext())
            {
                var pullall = from an in conetxt.Animals where an.STATUS != "SOLD" select an;
                List<Animals> list = pullall.ToList();

                foreach(Animals animal in list)
                {
                    ste.Add(animal.TYPE);
                }
            }

            System.Windows.Forms.MessageBox.Show(""+ste.Count);

            using (PetShopDBContext context = new PetShopDBContext())
            {
                foreach(string str in ste)
                {
                    var pull1 = from ani1 in context.Animals
                                where ani1.TYPE.Equals(str) && ani1.GENDER.Equals("MALE") && ani1.STATUS != "SOLD"
                                select ani1;
                    List<Animals> maleAnimal = pull1.ToList();

                    var pull2 = from ani2 in context.Animals
                                where ani2.TYPE.Equals(str) && ani2.GENDER.Equals("FEMALE") && ani2.STATUS != "SOLD"
                                select ani2;
                    List<Animals> femaleAnimal = pull1.ToList();

                    if(femaleAnimal.Count < 2 || maleAnimal.Count < 2)
                    {
                        System.Windows.Forms.MessageBox.Show("Constraint vialoated at sector " + str);
                    }
                }
            }
        }