// add new items to db, may be utilized at a later date public void AddProductToDb(string name, string barcode, int price) { using (DDEntities context = new DDEntities()) { Product product = new Product() { ItemName = name, Barcode = barcode, Price = price }; context.Products.Add(product); context.SaveChanges(); } }
public int StoreIdLookUp(string storeCode) { using (DDEntities context = new DDEntities()) { try { // finds store info in database int storeId = context.Stores.FirstOrDefault(x => x.Code == storeCode).ID; return(storeId); } catch { return(0); } } }
public Product ItemLookup(string barcode) { using (DDEntities context = new DDEntities()) { try { // finds product info in database Product product = context.Products.FirstOrDefault(x => x.Barcode == barcode); return(product); } catch { return(null); } } }
public int QuantityLookup(int itemId, int storeId) { using (DDEntities context = new DDEntities()) { try { // finds quantity info in database int itemQuantity = context.Quantities.FirstOrDefault(x => (x.ItemID == itemId && x.StoreID == storeId)).Quantity1; return(itemQuantity); } catch { return(0); } } }