示例#1
0
文件: Order.cs 项目: minhajuddin/Kona
 /// <summary>
 /// Finds an item in the cart
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public OrderItem FindItem(Product product)
 {
     OrderItem result = null;
     if (product != null) {
         //see if this item is in the cart already
         return FindItem(product.SKU);
     }
     return result;
 }
示例#2
0
文件: Order.cs 项目: minhajuddin/Kona
 /// <summary>
 /// Remmoves a product from the cart
 /// </summary>
 public void RemoveItem(Product product)
 {
     RemoveItem(product.SKU);
 }
示例#3
0
文件: Order.cs 项目: minhajuddin/Kona
        /// <summary>
        /// Adds a product to the cart
        /// </summary>
        public void AddItem(Product product, int quantity)
        {
            //see if this item is in the cart already
            OrderItem item = FindItem(product);

            if (quantity != 0) {
                if (item != null) {
                    //if the passed in amount is 0, do nothing
                    //as we're assuming "add 0 of this item" means
                    //do nothing
                    if (quantity != 0)
                        AdjustQuantity(product, item.Quantity + quantity);
                } else {
                    if (quantity > 0) {
                        item = new OrderItem(product, quantity);

                        //add to list
                        this.Items.Add(item);
                    }
                }

            }
        }
示例#4
0
文件: Order.cs 项目: minhajuddin/Kona
        /// <summary>
        /// Adjusts the quantity of an item in the cart
        /// </summary>
        public void AdjustQuantity(Product product, int newQuantity)
        {
            OrderItem itemToAdjust = FindItem(product);
            if (itemToAdjust != null) {
                if (newQuantity <= 0) {
                    this.RemoveItem(product);
                } else {
                    itemToAdjust.AdjustQuantity(newQuantity);
                }

            }
        }
示例#5
0
 public void Save(Product p) {
     productList.Add(p);
 }
示例#6
0
文件: Order.cs 项目: minhajuddin/Kona
 //public LazyList<IIncentive> IncentivesUsed { get; set; }
 //public Order():this("","") {
 //}
 //public Order(string userName)
 //    : this("",userName) {
 //}
 //public Order(string orderNumber, string userName) {
 //    this.OrderNumber = orderNumber;
 //    this.UserName = userName;
 //    this.Status = OrderStatus.NotCheckoutOut;
 //    this.Items=new LazyList<OrderItem>();
 //    this.IncentivesUsed = new LazyList<IIncentive>();
 //    this.ID = Guid.NewGuid();
 //    this.DiscountAmount = 0;
 //    this.DiscountReason = "--";
 //}
 /// <summary>
 /// Adds a product to the cart
 /// </summary>
 public void AddItem(Product product)
 {
     AddItem(product, 1);
 }
示例#7
0
        public MockProductRepository() {
            
            //load up the repo list
            productList = new List<Product>();
            imageList = new List<Image>();
            descriptorList = new List<ProductDescriptor>();

            for(int i=1;i<=3;i++){
                imageList.Add(new Image("noimage.gif","noimage.gif"));
            }
            
            for(int i=1;i<=3;i++){
                descriptorList.Add(new ProductDescriptor("title","Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec non diam eu tellus elementum ullamcorper. Maecenas leo magna, tempor eget, molestie quis, ornare sed, ligula. Etiam purus nisl, tempus a, commodo quis, posuere quis, elit. Nunc urna nisi, varius ut, hendrerit ut, bibendum in, ipsum."));
            }


            for (int i = 1; i <= 5; i++) {

                Product p =new Product("SKU" + i,"Product "+i,true,10);
                p.WeightInPounds = 5;


                //set first three products to shipped
                p.Delivery = i <= 3 ? DeliveryMethod.Shipped : DeliveryMethod.Download;


                //set first three products to Back-orderable
                p.AllowBackOrder = i <= 3;

                //set the 2nd product to BackOrder
                p.Inventory = i == 2 ? InventoryStatus.BackOrder : InventoryStatus.InStock;

                //set all products to taxable, except the 5th
                p.IsTaxable = i != 5;

                p.Recommended = new List<Product>();

                //have it recommend itself, for now
                p.Recommended.Add(p);

                //related
                p.RelatedProducts = new List<Product>();
                for (int x = 0; x < 5; x++)
			    {
                    p.RelatedProducts.Add(new Product("SKU_REL" + x));

                }

                //add some Crosses
                p.CrossSells = new LazyList<Product>();
                for (int x = 0; x < 5; x++)
			    {
                    p.CrossSells.Add(new Product("SKU_CROSS" + x));

                }
                productList.Add(p);
            }



        }
示例#8
0
 public static Product New(string sku, string name, decimal price)
 {
     var result = new Product();
     result.SKU = sku;
     result.Name = name;
     result.Price = price;
     return result;
 }
示例#9
0
 public OrderItem(Product product, int quantity, DateTime dateAdded)
 {
     _product = product;
     _quantity = quantity;
     _dateAdded = dateAdded;
 }
示例#10
0
 public OrderItem(Product product, int quantity)
     : this(product,quantity,DateTime.Now)
 {
 }
示例#11
0
 public OrderItem(Product product)
     : this(product,1)
 {
 }