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"));
        }
Esempio n. 2
0
        public IActionResult Contact()
        {
            var model = new OrderContactCartViewModel
            {
                Cart = _cartSessionService.GetCart()
            };

            return(View(model));
        }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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"));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 10
0
        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"));
        }
Esempio n. 11
0
        public IActionResult List()
        {
            var cart = _cartSessionService.GetCart();

            var cartListViewModel = new CartListViewModel
            {
                Cart = cart
            };

            return(View(cartListViewModel));
        }
Esempio n. 12
0
        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"));
        }
Esempio n. 13
0
        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"));
        }
Esempio n. 14
0
        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"));
        }
Esempio n. 15
0
        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"));
        }
Esempio n. 16
0
        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"));
        }
Esempio n. 17
0
        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"));
        }
Esempio n. 18
0
        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));
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        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.
        }
Esempio n. 21
0
        // 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"));
        }
Esempio n. 22
0
        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"));
        }
Esempio n. 24
0
        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"));
        }
Esempio n. 26
0
        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"));
        }
Esempio n. 27
0
        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"));
        }
Esempio n. 28
0
        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));
        }
Esempio n. 30
0
        public ViewViewComponentResult Invoke()
        {
            CartSummaryModel cartSummaryModel = new CartSummaryModel()
            {
                Cart = _cartService.GetCart()
            };

            return(View(cartSummaryModel));
        }