Exemplo n.º 1
0
        public Cart(Service service, Customer customer, Basket basket)
        {
            this.service = service;
            this.customer = customer;
            this.basket = basket;

            addShoppingList(basket);
        }
Exemplo n.º 2
0
        Basket GetShoppingListForCustomer(int customerId)
        {
            Customer customer =  (from c in Database.Customers where c.Id == customerId select c).SingleOrDefault();
            if (customer == null)
            {
                throw new Exception("Customer not found");
            }

            if (customer.Basket == null)
            {
                Basket basket = new Basket();
                Database.Baskets.InsertOnSubmit(basket);
                Database.SubmitChanges();

                customer.Basket = basket;
                Database.SubmitChanges();
            }
            return customer.Basket;
        }
Exemplo n.º 3
0
 private void addShoppingList(Basket basket)
 {
     foreach (BasketProduct product in basket.BasketProducts)
     {
         Product p = product.Product;
         products.Add(p, 0);
     }
 }