public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { customers = context.Customers.ToList(); } }
public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { stock = context.Stocks.ToList(); } }
public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { context.Customers.Add(customer); context.SaveChanges(); } }
public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { var animlaQuery = from ani in context.Animals where ani.STATUS != "SOLD" select ani; Animals = animlaQuery.ToList(); } }
public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { context.Stocks.Add(stock); context.SaveChanges(); } }
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. }
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(); } }
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(); } } }
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); } } } }