public ActionResult AddToCart(int id) { if (Session["kullanici"] != null) { //MyCart myCart = new MyCart(); bu kullanım bana sürekli yeni sepetler oluşturur. MyCart cart = Session["cart"] as MyCart; CartItemDTO cartItem = new CartItemDTO(); var eklenenAlbum = albumService.Get(id); cartItem.ID = eklenenAlbum.ID; cartItem.Name = eklenenAlbum.Title; cartItem.Price = eklenenAlbum.Discontinued ? eklenenAlbum.Price * 0.90m : eklenenAlbum.Price; cartItem.Amount = 1; cart.Add(cartItem); Session["cart"] = cart; } else { throw new Exception(); } return(PartialView("_CartButton")); }
public ActionResult AddToCart(int id) { if (Session["UserName"] != null) { MyCart cart = Session["cart"] as MyCart; CartItemDTO cartItem = new CartItemDTO(); using (SinemaSitesiEntities db = new SinemaSitesiEntities()) { var data = db.Movie.Where(x => x.ID == id).FirstOrDefault(); cartItem.ID = data.ID; cartItem.Name = data.Name; cartItem.Price = data.Price; cartItem.Amount = 1; cart.Add(cartItem); Session["cart"] = cart; } } else { throw new Exception(); } return(PartialView("_CartButton")); }
private void buttonAddCart_Click(object sender, EventArgs e) { int amount = (int)numericUpDown1.Value; if (amount > 0) { Product product = _productManager.GetProduct(_idProduct); CartItem cartItem = new CartItem() { ID = product.ProductID, Amount = amount, Name = product.ProductName, Price = (decimal)product.UnitPrice }; _myCart.Add(cartItem); listBox1.Items.Clear(); foreach (CartItem item in _myCart.ListCart) { listBox1.Items.Add($"Product Name={item.Name} Amount={item.Amount.ToString()} Price={item.Price.ToString()} Sub Price= {(item.SubPrice).ToString()}"); } labelTotalPrice.Text = _myCart.TotalPrice.ToString(); } else { MessageBox.Show("Ürün Sayısını Giriniz"); } }
public void OnAddDiscountedItemToCart(SalesDealContainer itemToAdd) { var existingBasket = MyCart.FirstOrDefault(s => s.cartDiscountDeal != null && s.cartDiscountDeal.SalesCombination.SalesCombinationID == itemToAdd.SalesCombination.SalesCombinationID); if (existingBasket != null) { existingBasket.AddOne(); } else { MyCart.Add(new CartItem(itemToAdd)); } CartCount = MyCart.Sum(s => s.cartOrderLine.Quantity); CartCost = MyCart.Sum(s => s.cartOrderLine.Price); }
public void OnAddToCart(Product productToAdd) { var existingBasket = MyCart.FirstOrDefault(s => s.cartProduct != null && s.cartProduct.ProductID == productToAdd.ProductID); if (existingBasket != null) { existingBasket.AddOne(); } else { MyCart.Add(new CartItem(productToAdd)); } CartCount = MyCart.Sum(s => s.cartOrderLine.Quantity); CartCost = MyCart.Sum(s => s.cartOrderLine.Price); }
public ActionResult AddToCart(int id) { var Eklenecek = _albumDb.SelectByID(id); CartItem citem = new CartItem(); citem.ID = Eklenecek.ID; citem.Name = Eklenecek.Title; citem.Price = Eklenecek.Price; citem.Quantity = 1; //MyCart cart = Session["cart"] == null ? new MyCart() : Session["cart"] as MyCart; MyCart cart = Session["cart"] as MyCart; cart.Add(citem); Session["cart"] = cart; return(PartialView("_CartButton")); }
public ActionResult AddToMyCart(int id) { // MyCart mycart = new MyCart(); bu kullanım her sepete ekle için yeni sepet oluşturur yani her ürün farklı sepette olur MyCart cart = Session["cart"] as MyCart; CartItemDTO cartItem = new CartItemDTO(); var eklenenAlbum = albumService.Get(id); cartItem.ID = eklenenAlbum.ID; cartItem.Name = eklenenAlbum.Title; //cartItem.Price = eklenenAlbum.Price; //price eklerken indirim olsun,%10 indirim olsun cartItem.Price = eklenenAlbum.Discounted ? eklenenAlbum.Price * 0.9m : eklenenAlbum.Price; cartItem.Amount = 1; cart.Add(cartItem); Session["cart"] = cart; return(PartialView("_CartButton")); }
public ActionResult AddToCart(int id) { if (Session["kullanici"] != null) { MyCart cart = Session["cart"] as MyCart; CartItemDTO cartItem = new CartItemDTO(); var eklenenAlbum = albumService.Get(id); cartItem.ID = eklenenAlbum.ID; cartItem.Name = eklenenAlbum.Title; cartItem.Price = eklenenAlbum.Discontinued ? eklenenAlbum.Price * 0.9m : eklenenAlbum.Price; //indirim varsa indirimli fiyat, yoksa normal fiyatı verir (????) cartItem.Amount = 1; cart.Add(cartItem); Session["cart"] = cart; } else { throw new Exception(); } return(PartialView("_CartButton")); }