当前位置: 首页>>代码示例>>C#>>正文


C# ShoppingCart类代码示例

本文整理汇总了C#中ShoppingCart的典型用法代码示例。如果您正苦于以下问题:C# ShoppingCart类的具体用法?C# ShoppingCart怎么用?C# ShoppingCart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShoppingCart类属于命名空间,在下文中一共展示了ShoppingCart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConstructorSpecifications

		public void ConstructorSpecifications()
		{
			ShoppingCart cart = null;
			"Given new ShoppingCart".Context(() => cart = new ShoppingCart());

			"number of Items is 0".Assert(() => cart.Items.Count.ShouldEqual(0));
		}
开发者ID:ArnoldZokas,项目名称:xunit.net-specifications,代码行数:7,代码来源:ShoppingCartSpecifications.cs

示例2: ViewCartDialog

 public ViewCartDialog(ShoppingCart.Cart cart)
 {
     InitializeComponent();
     this.cart = cart;
     totalLabel.Text = string.Format("${0:#.00}", cart.getTotalPrice());
     totalShippingLabel.Text = string.Format("${0:#.00}", cart.getTotalShipping());
 }
开发者ID:scottkrohn,项目名称:KrohnDesignsSalesApplication,代码行数:7,代码来源:ViewCartDialog.cs

示例3: EventsToShoppingCart

 private static IEnumerable<object> EventsToShoppingCart(IEnumerable<dynamic> source)
 {
     foreach (var @event in source)
     {
         var cart = new ShoppingCart { Id = @event.ShoppingCartId };
         {
             switch ((string)@event.Type)
             {
                 case "Create":
                     cart.Customer = new ShoppingCartCustomer
                     {
                         Id = @event.CustomerId,
                         Name = @event.CustomerName
                     };
                     break;
                 case "Add":
                     cart.AddToCart(@event.ProductId, @event.ProductName, (decimal)@event.Price, 1);
                     break;
                 case "Remove":
                     cart.AddToCart(@event.ProductId, @event.ProductName, (decimal)@event.Price, -1);
                     break;
             }
         }
         yield return new
         {
             @event.__document_id,
             ShoppingCartId = cart.Id,
             Aggregate = cart
         };
     }
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:31,代码来源:ShoppingCartEventsToShopingCart.cs

示例4: PutShoppingCart

        public async Task<IHttpActionResult> PutShoppingCart(int id, ShoppingCart shoppingCart)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != shoppingCart.Id)
            {
                return BadRequest();
            }

            db.Entry(shoppingCart).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShoppingCartExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
开发者ID:aysebasakkoca,项目名称:inf326-aysebasakkoca,代码行数:32,代码来源:ShoppingCartsController.cs

示例5: ApplyCoupon

        public bool ApplyCoupon(ShoppingCart cart, string coupon)
        {
            if (String.IsNullOrWhiteSpace(coupon))
            {
                return false;
            }

            var oldCoupon = cart.CouponCode;

            cart.CouponCode = coupon;

            var context = PricingContext.CreateFrom(cart);
            new PricingPipeline().Execute(context);

            if (context.AppliedPromotions.Any(p => p.RequireCouponCode && p.CouponCode == coupon))
            {
                return true;
            }

            cart.CouponCode = oldCoupon;

            _repository.Database.SaveChanges();

            return false;
        }
开发者ID:Wipcore,项目名称:Ecommerce,代码行数:25,代码来源:ShoppingCartService.cs

示例6: UseExtentionEnumerable

        public ViewResult UseExtentionEnumerable()
        {
            // create and populate Shoppingcart
            ShoppingCart cart = new ShoppingCart
            {
                Products = new List<Product>
                {
                    new Product {Name = "Kayak",Price = 275M },
                    new Product {Name = "Lifejacket",Price = 48.95M },
                    new Product {Name = "Soccer ball",Price = 19.5M },
                    new Product {Name = "Corner flag",Price = 34.95M }
                }
            };

            Product[] productArray = {
                    new Product { Name = "Kayak", Price = 275M },
                    new Product { Name = "Lifejacket", Price = 48.95M },
                    new Product { Name = "Soccer ball", Price = 19.5M },
                    new Product { Name = "Corner flag", Price = 34.95M }
                };

            decimal cartTotal = cart.Totalprices();
            decimal arrayTotal = productArray.Totalprices();

            return View("Result", (object)String.Format("Total: {0:c}, Array Total: {1:c}", cartTotal, arrayTotal ));
        }
开发者ID:n4ppy,项目名称:LanguageFeatures,代码行数:26,代码来源:HomeController.cs

示例7: GetCart

 public static ShoppingCart GetCart(HttpContextBase context, IStoretUnitOfWork storetUnitOfWork)
 {
     var cart = new ShoppingCart();
     _storetUnitOfWork = storetUnitOfWork;
     cart.ShoppingCartId = GetCartId(context);
     return cart;
 }
开发者ID:denmerc,项目名称:Presentations,代码行数:7,代码来源:ShoppingCart.cs

示例8: DeleteShoppingCart

    private void DeleteShoppingCart()
    {
        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.CartGuid = this.CartGUID;

        ProcessGetShoppingCart getShoppingCart = new ProcessGetShoppingCart();
        getShoppingCart.ShoppingCart = shoppingCart;

        try
        {
            getShoppingCart.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }

        ProcessDeleteShoppingCartByGuid deleteCart = new ProcessDeleteShoppingCartByGuid();
        deleteCart.ShoppingCart = getShoppingCart.ShoppingCart;

        try
        {
            deleteCart.Invoke();
            Utilities.DeleteCartGUID();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }
    }
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:30,代码来源:CheckoutReceipt.aspx.cs

示例9: Delete

        public object Delete(ShoppingCart.ShoppingCartItem request)
        {
            var success = ShoppingCarts.RemoveFromCart(UserId, request.Product.Id);

            if (success) return new HttpResult(HttpStatusCode.NoContent, "");
            return new HttpError(HttpStatusCode.BadRequest, "");
        }
开发者ID:jaysan1292,项目名称:COMP-3073-Group-Project,代码行数:7,代码来源:ShoppingCartService.cs

示例10: UseExtensionEnumerable

        //http://localhost:50070/Home/UseExtensionEnumerable
        public ViewResult UseExtensionEnumerable()
        {
            //A Type
            IEnumerable<Product> products = new ShoppingCart {
                Products = new List<Product>
                {
                    new Product { Name="p1", Price=10 },
                    new Product { Name="p2", Price=20 },
                    new Product { Name="p3", Price=30 }
                }
            };

            //B Type  (배열도 IEnumerable 인터페이스를 구현하고 있다)
            Product[] productArray =
            {
                new Product { Name="p1", Price=10 },
                new Product { Name="P2", Price=20 },
                new Product { Name="p3", Price=30 }
            };

            //Total
            decimal cartTotal = products.TotalPrices();
            decimal arrayTotal = productArray.TotalPrices();

            return View("Result", (object)String.Format("Cart Total : {0}, Array Total: {1}", cartTotal, arrayTotal));
        }
开发者ID:nekoYouknow,项目名称:Sample,代码行数:27,代码来源:HomeController.cs

示例11: UpdateStockLevel

    protected void UpdateStockLevel()
    {
        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.CartGuid = this.CartGUID;

        ProcessGetShoppingCart getShoppingCart = new ProcessGetShoppingCart();
        getShoppingCart.ShoppingCart = shoppingCart;

        ProcessUpdateStockLevel updateStockLevel = new ProcessUpdateStockLevel();

        try
        {
            getShoppingCart.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }

        updateStockLevel.ShoppingCart = getShoppingCart.ShoppingCart;

        try
        {
            updateStockLevel.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }
    }
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:30,代码来源:CheckoutReceipt.aspx.cs

示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                Cart = HttpContext.Current.Session["Cart"] as ShoppingCart;
                if (Cart == null)
                {
                    Cart = new ShoppingCart("ProductsGrid");
                    HttpContext.Current.Session["Cart"] = Cart;
                }

                ProductsGrid.DataSource = Cart.ToTable();
                ProductsGrid.DataBind();

                if (ProductsGrid.Rows.Count > 0)
                {
                    CartTotal.Text = "<p class='total'>Grand Total: "  String.Format("{0:c}", Cart.Total)  "</p>";
                }
                else
                {
                    CartBody.Text = "<p>Your cart is empty!</p>";
                }
            }
            catch (Exception ex)
            {
                CartBody.Text = "<p>Error: "  ex.Message  "</p>";
            }
        }
    }
开发者ID:insomnissippi,项目名称:ProjectMilestone,代码行数:31,代码来源:shopping_cart.aspx.cs

示例13: getItemNumber

        // Generates an item number based on the attributes of an Item object.
        public static int getItemNumber(ShoppingCart.Item item)
        {
            int itemNumber = (int)item.getType() + 1;
            itemNumber = (itemNumber * 10) + (int)item.getStain();

            // Based on the type of the item, generate additional digits for the item number based on that Item_Types attributes.
            if(item.getType() == ShoppingCart.Item.Item_Type.Board){
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getMagneticType();
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getFrameStyle();
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getHangingDirection();
                itemNumber = (itemNumber * 100) + (int)((ShoppingCart.Chalkboard)item).getLength();
                itemNumber = (itemNumber * 100) + (int)((ShoppingCart.Chalkboard)item).getWidth();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Sconce){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10000000) + (int)((ShoppingCart.Sconce)item).getHeight();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Box){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10000000) + (int)((ShoppingCart.Box)item).getLength();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Organizer){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.JarOrganizer)item).getJarCount();
                itemNumber = (itemNumber * 1000000) + (int)((ShoppingCart.JarOrganizer)item).getWidth();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.JarSconce){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.JarSconce)item).getSconceCount();
                itemNumber = (itemNumber * 1000000) + (int)((ShoppingCart.JarSconce)item).getHeight();
            }
            return itemNumber;
        }
开发者ID:scottkrohn,项目名称:KrohnDesignsSalesApplication,代码行数:34,代码来源:ItemNumberGenerator.cs

示例14: AddItemInputValidationSpecifications

		public void AddItemInputValidationSpecifications()
		{
			ShoppingCart cart = null;
			"Given new ShoppingCart".Context(() => cart = new ShoppingCart());

			"AddItem throws when ArgumentNullException when null product name is passed".AssertThrows<ArgumentNullException>(() => cart.AddItem(null));
		}
开发者ID:ArnoldZokas,项目名称:xunit.net-specifications,代码行数:7,代码来源:ShoppingCartSpecifications.cs

示例15: AssignPromotionsToShoppingCartItems

 public void AssignPromotionsToShoppingCartItems(ShoppingCart cart) {
     foreach (Item item in cart.GetItemsInCart()) {
         if (promotionModel.HasPromotionForItem(item)) {
             cart.AttachPromotionToItem(item, promotionModel.GetPromotionForItem(item));
         }
     }
 }
开发者ID:mtqtran8182,项目名称:checkout,代码行数:7,代码来源:PricingController.cs


注:本文中的ShoppingCart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。