public void executeBusinessLogic() { using (PetShopDBContext context = new PetShopDBContext()) { context.Customers.Add(customer); context.SaveChanges(); } }
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(); } } }