public ActionResult AddToCart(int productId, int count) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); var cartLineProduct = cart.CartLines.FirstOrDefault(c => c.Product.Id == productId); //Stok kontrolü if ((cartLineProduct != null && (cartLineProduct.Quantity + count) > productToBeAdded.Stock) || (cartLineProduct == null && count > productToBeAdded.Stock)) { this.SetAlert(string.Format("Ürün: {0},stok adeti yetersiz.", productToBeAdded.ProductName), true); return(RedirectToAction("Index", "Home")); } _cartService.AddToCart(cart, productToBeAdded, count); _cartSessionService.SetCart(cart); this.SetAlert(string.Format("Ürün: {0}, başarıyla sepete eklendi.", productToBeAdded.ProductName)); return(RedirectToAction("Index", "Home")); }
public ActionResult AddToCart([FromBody] PizzaToAddCartDto pizzaDto) { var cart = _cartSessionService.GetCart(); decimal pizzaTypePrice = _pizzaTypeRepository.GetPizzaTypePrice(pizzaDto.PizzaTypeId); decimal sizeMultiplier = _sizeRepository.GetSizeMultiplier(pizzaDto.SizeId); decimal price = _pizzaPriceCalculater.Calculate(sizeMultiplier, pizzaTypePrice, pizzaDto.EdgeTypeId, pizzaDto.NumberOfPizza); string pizzaName = _pizzaTypeRepository.GetPizzaTypeName(pizzaDto.PizzaTypeId); PizzaToAddCart pizzaToAddCart = new PizzaToAddCart { Id = pizzaDto.PizzaTypeId, PizzaName = pizzaName, NumberOfPizza = pizzaDto.NumberOfPizza, Price = price, Toppings = pizzaDto.Toppings }; _cartService.AddTocart(cart, pizzaToAddCart); _cartSessionService.SetCart(cart); var cartFromSession = _cartSessionService.GetCart(); int totalPizzas = cartFromSession.TotalQuantity; return(Ok(totalPizzas)); }
public IActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded.Data); _cartSessionService.SetCart(cart); //TempData.Add("message", String.Format("{0} sepete eklendi", productToBeAdded.Name)); return RedirectToAction("Index", "Home"); }
public IActionResult AddToCart(int productId) { var product = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, product); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your product {0}, was successfully added to the cart", product.ProductName)); return(RedirectToAction("Index", "Product")); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", $"Your Product,{productToBeAdded.ProductName}, was successfully add to cart!"); return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int supplementId) { var cart = _cartSessionService.GetCart(); var addedSupplement = _supplementService.GetSupplementById(supplementId); _cartService.AddToCart(cart, addedSupplement); _cartSessionService.SetCart(cart); return(RedirectToAction("Index", "Home")); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddtoCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("->,{0},Ürününüz Sepete Eklendi.", productToBeAdded.ProductName)); return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int ProductID) { var productToBeAdded = _productService.GetByID(ProductID); var cart = _cartSessionService.GetCart(); //HttpContext.Session Kullanma! _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your product {0}, was succesfully added to the cart!", productToBeAdded.ProductName)); return(RedirectToAction("Index", "Product")); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); // Sepet Session 'ı verir. Cart nesnesi var. _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your product ,{0}, was successfully added to the cart!", productToBeAdded.ProductName)); // Temp Data tek bir requestlik veri taşır. return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int productId) { var addedProduct = _productService.GetByProductId(productId); var cart = _sessionService.GetCart(); _cartService.AddToCart(cart, addedProduct); _sessionService.SetCart(cart); TempData.Add("message", String.Format("Your product {0},was succes added to cart! ", addedProduct.ProductName)); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> AddToCart(int id) { var productApi = RestService.For <IProductApi>(_configuration.GetSection("MyAddress").Value); var productToBeAdded = await productApi.Get(id); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", string.Format("Your product {0} was succesfully added to cart!", productToBeAdded.Name)); return(RedirectToAction("GetAll", "Product")); }
public IActionResult AddToCart(int productId) { var productToAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToAdded); _cartSessionService.SetCart(cart); TempData.Add("message", string.Format("{0} başarı ile sepete eklendi", productToAdded.ProductName)); return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int productId) { var addToProduct = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, addToProduct); _cartSessionService.SetCart(cart); TempData.Add("message", addToProduct.ProductName + " İsimli ürününüz eklendi."); return(RedirectToAction("Index", "Product")); }
public ActionResult AddToCart(int urun_id) { var urunToBeAdded = _urunService.GetById(urun_id); var cart = _cartSessionService.GetCart(); _cartService.AddToCard(cart, urunToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Ürününüz, {0}, başarıyla sepete eklendi!", urunToBeAdded.urun_adi)); return(RedirectToAction("Index", "Urun")); }
public ActionResult AddToCart(int productId, int quantity = 1, int quantityUp = 0, string currentContreller = "Cart", string currentAction = "OrderDetails") { var productToBeAdded = _productService.Get(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded, quantity, quantityUp); _cartSessionService.SetCart(cart); return(RedirectToAction(currentAction, currentContreller)); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your product, {0}, was successfully added to the cart!", productToBeAdded.ProductName));//Tek istek için kullanılabilir. return(RedirectToAction("Index", "Product")); }
// GET: /<controller>/ public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); // ekledikten sonra cart ı yeniden session a atmam gerek. _cartSessionService.SetCart(cart); TempData.Add("message", string.Format("Your product {0} has been successfully added to the cart!", productToBeAdded.ProductName)); return(RedirectToAction("Index", "Product")); }
public ActionResult AddToCart(int productId) { if (TempData.ContainsKey("message")) { TempData.Remove("message"); } var product = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, product); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("{0},succesfully added to your cart", product.ProductName)); return(RedirectToAction("Index", "Home")); }
public IActionResult AddToCart(Guid prdId) { var product = _productService.GetById(prdId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, product); Stok = product.UnitsInStock; //_productService.Update(product); _cartSessionService.SetCart(cart); TempData["message"] = $"{product.ProductName} isimli ürün başarıyla sepetinize eklenmiştir."; return(RedirectToAction("Index", "Home")); }
public IActionResult AddToCart(int productId, int quantity) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded, quantity); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("{0} adet {1} sepete eklendi", quantity, productToBeAdded.ProductName)); return(RedirectToAction("List", "Product")); }
public ActionResult AddToCart(int productId) //Sepete ekleme { var productToBeAdded = _productService.GetById(productId); //ürünün son halini veritabanından çekmek için. var cart = _cartSessionService.GetCart(); // _cartService.AddToCart(cart, productToBeAdded); //producttobeadded a ürün ekle _cartSessionService.SetCart(cart); //veritabanına nesnemi ekle TempData.Add("message", String.Format("Your product, {0},was succesfully added to the cart", productToBeAdded.ProductName)); //tempdata sadece tek bir requestlik değer taşır.Bir mesaj vermek istiyorsam kullanılırım. return(RedirectToAction("Index", "Product")); //tekrar buraya dönder. }
public IActionResult AddToSessionBasket(int productId) { var productAdded = _productService.GetProduct(productId); var cart = _cartSessionService.GetCart(); _basketService.AddToSession(cart, productAdded); _cartSessionService.SetCart(cart); TempData["sayi"] = sayi++; return(RedirectToAction("GetAllProducts", "Product")); }
public ActionResult AddToCart(int bookId) { var bookToBeAdded = _bookService.GetById(bookId).Data; var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, bookToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your book, {0}, was successfully added to the cart!", bookToBeAdded.Title)); return(RedirectToAction("Index", "Book")); }
public ActionResult AddToCart(int productId) { var productTobeAdded = _productService.GetById(productId); //producttan id ile çektik var cart = _cartSessionservice.GetCart(); //bunun için sessionu genişlettik _cartService.AddToCart(cart, productTobeAdded); // cartServiceye bir cart ekle product tipte _cartSessionservice.SetCart(cart); // ve bunu tekrar set et diyorum TempData.Add("message", String.Format("Ürününüz , {0} ,başarıyla carta eklendi ", productTobeAdded.ProductName)); //TempData tek requestlik veri taşır mesaj filan return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); //Session'daki sepet'i çek. var cart = _cartSessionService.GetCart(); //Sepete'e ürün ekle. _cartService.AddtoCart(cart, productToBeAdded); //Session'daki sepeti güncelle. _cartSessionService.SetCart(cart); TempData["message"] = $"Your product, {productToBeAdded.ProductName}, was successfully added to the cart!"; return(RedirectToAction("Index", "Product")); }
public ReturnModel <string> Post([FromBody] AddToCartRequestModel model) { var productToBeAdded = _productService.Get(model.ProductId).Data; var cart = _cartSessionService.GetCart(); var result = _cartService.AddToCart(cart, productToBeAdded, model.Quantity); _cartSessionService.SetCart(cart); return(result); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); return(RedirectToAction("List", "Product")); }
public IActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetProduct(productId); if (productToBeAdded.UnitsInStock == 0) { TempData.Add("StockMessage", String.Format("Unfortunately there are no products left in stock.")); } else { var cart = _cartSessionService.GetCart(); _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); TempData.Add("message", String.Format("Your Product: {0} was successfully added to the cart", productToBeAdded.ProductName)); } return(RedirectToAction("Index", "Product")); }
public ActionResult AddToCart(int productId, int quantity = 1) { var product = _productService.GetById(productId); var cart = _cartSessionService.GetCart(); var photos = _photoService.GetPhotosofProduct(productId); string photoUrl = ""; photoUrl = (photos.Count > 0) ? photos.FirstOrDefault().PhotoUrl : "nophoto.jpg"; _cartService.AddtoCart(cart, product, quantity, photoUrl); _cartSessionService.SetCart(cart); TempData.Add("message", "Eklendi"); return(RedirectToAction("List", "Cart")); }
public ActionResult AddToCart(int productId) { var productToBeAdded = _productService.GetById(productId); //eklenecek olan product var cart = _cartSessionService.GetCart(); // cart ı alıyoruz..o anki kullanıcının kartını vermiş olucak _cartService.AddToCart(cart, productToBeAdded); _cartSessionService.SetCart(cart); //kartı ekliyor TempData.Add("message", $"Your Product {productToBeAdded.ProductName} was successfully added to the cart!"); // bununla bir request lik veri taşıyabiliyruz. tempdata dan gelen veriyi henüz ekranda gösteremiyoruz return(RedirectToAction("index", "product")); }