예제 #1
0
 public static void update(BasketInCart basket)
 {
     lock (Lock)
     {
         context.basketsInCarts.Update(basket);
         context.SaveChanges();
     }
 }
예제 #2
0
        public static void Delete(BasketInCart basket, bool propogate = false)
        {
            lock (Lock)
            {
                if (propogate)
                {
                    foreach (var item in basket.products)
                    {
                        Delete(item, propogate);
                    }
                }
                context.basketsInCarts.Remove(basket);

                context.SaveChanges();
            }
        }
예제 #3
0
        public BasketInCart toDataObject()
        {
            List <ProductData> products = new List <ProductData>();

            foreach (Product product in this.products)
            {
                products.Add(product.toDataObject(this.store.name));
            }
            BasketInCart ans = DataAccess.getBasket(this.owner.getUserName(), this.store.name);

            if (ans == null)
            {
                return(new BasketInCart(this.store.toDataObject(), ((Member)this.owner).toDataObject(), products));
            }
            ans.products = products;
            return(ans);
        }// (ICollection<ProductData>)this.products.Select(p => p.toDataObject()),
예제 #4
0
        /* public ShoppingBasket(BasketData shoppingBasketData)
         * {
         *   this.products = new LinkedList<Product>();
         *   ICollection<ProductData> productsInBasketData = shoppingBasketData.products;
         *
         *   foreach (ProductData p_data in productsInBasketData)
         *   {
         *       this.products.Add(new Product(p_data));
         *   }
         *   //this.store = new Store();
         *   //this.owner = UserServices.getUser(shoppingBasketData);
         * }*/
        public ShoppingBasket(BasketInCart 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.storeName));
            ThreadStart linkOwner = new ThreadStart(() => this.owner = UserServices.getUser(shoppingBasketData.userName));

            //  this.store = new Store(shoppingBasketData.recipt.store);
            // this.owner = new Member(shoppingBasketData.recipt.user);
            Build.addLink(linkStore);
            Build.addLink(linkOwner);
        }