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 IActionResult Contact() { var model = new OrderContactCartViewModel { Cart = _cartSessionService.GetCart() }; return(View(model)); }
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 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 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 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 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 IActionResult List() { var cart = _cartSessionService.GetCart(); var cartListViewModel = new CartListViewModel { Cart = cart }; return(View(cartListViewModel)); }
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")); }
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 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 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 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")); }
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 async Task <IActionResult> OrderView() { var user = await _userManager.GetUserAsync(User).ConfigureAwait(false); OrderViewModel model = new OrderViewModel(); Cart newCard = _cartSessionService.GetCart(); model.Cart = newCard; model.Addresses = _addressService.GetByUserId(user.Id); model.Shipping = 0; ViewBag.BestShipping = 5; return(View(model)); }
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. }
// 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 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 ViewViewComponentResult Invoke() { Cart Cart = new Cart(); Cart = _cartSessionService.GetCart(); return(View(Cart)); }
public ViewViewComponentResult Invoke() { var model = new CartSummaryViewModel { Cart = _cartSessionService.GetCart() }; return(View(model)); }
public ViewViewComponentResult Invoke() { CartSummaryModel cartSummaryModel = new CartSummaryModel() { Cart = _cartService.GetCart() }; return(View(cartSummaryModel)); }