public static void update(BasketInRecipt basket) { lock (Lock) { context.basketsInReceipts.Update(basket); context.SaveChanges(); } }
public static void Delete(BasketInRecipt basket, bool propogate = false) { lock (Lock) { if (propogate) { foreach (var item in basket.products) { Delete(item, propogate); } } context.basketsInReceipts.Remove(basket); context.SaveChanges(); } }
public ShoppingBasket(BasketInRecipt shoppingBasketData) { this.products = new LinkedList <Product>(); ICollection <ProductData> productsInBasketData = shoppingBasketData.products; foreach (ProductData p_data in productsInBasketData) { this.products.Add(new Product(p_data)); } ThreadStart linkStore = new ThreadStart(() => this.store = Stores.searchStore(shoppingBasketData.recipt.store.storeName)); ThreadStart linkOwner = new ThreadStart(() => this.owner = UserServices.getUser(shoppingBasketData.recipt.user.userName)); // this.store = new Store(shoppingBasketData.recipt.store); // this.owner = new Member(shoppingBasketData.recipt.user); Build.addLink(linkStore); Build.addLink(linkOwner); }
public BasketInRecipt toDataObjectRecipt(int id) { List <ProductData> products = new List <ProductData>(); foreach (Product product in this.products) { products.Add(product.toDataObject(this.store.name)); } BasketInRecipt ans = DataAccess.getBasket(id); if (ans == null) { return(new BasketInRecipt(products, id)); } ans.products = products; return(ans); }
public ReceiptData toDataObject() { BasketInRecipt bask = basket.toDataObjectRecipt(this.receiptId); ReceiptData ans = DataAccess.getReciept(this.receiptId); //= new ReceiptData(this.receiptId, bask, this.store.toDataObject(), this.user.toDataObject(), this.price, this.date, new iPolicyDiscountData(), new iPolicyData());//todo if (ans == null) { bask.recipt = ans; return(ans); } ans.price = this.price; ans.date = this.date; ans.purchasePolicy = this.purchasePolicy.toDataObject(); ans.discount = this.discount.toDataObject(); return(ans); }