public IActionResult Confirm()
        {
            UserCartManager.DeleteAll();

            ViewData["Confirm"] = "Your order has been processed";
            return(View());
        }
        public IActionResult DeleteFromCart(int id)
        {
            var itemId = id;

            UserCartManager.DeleteFromCart(itemId);
            return(RedirectToAction(nameof(MyCart)));
        }
        public IActionResult Confirm()

        {
            UserCartManager.ConfirmOrderAndDeleteItemsFromCart(HttpContext.Session.GetUserId());

            return(View());
        }
예제 #4
0
        public IActionResult MyCart()
        {
            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());
            // attēlošanai nepieciešamas tikai preces
            var items = userCart.Select(c => c.Item.ToModel()).ToList();

            return(View(items));
        }
예제 #5
0
        public IActionResult Confirm()
        {
            // TODO: pārbaude, ka lietotājs ir pieslēdzies (autentificējies)
            UserCartManager.RemoveByUser(HttpContext.Session.GetUserId());
            TempData["message"] = "Your order has been successfully received!";

            return(RedirectToAction(nameof(MyCart)));
        }
예제 #6
0
        public IActionResult DeleteCartItem(int id)
        {
            // nepieciešams norādīt arī UserId no sesijas, lai nedzēstu cita lietotāja preces.
            UserCartManager.RemoveByItem(HttpContext.Session.GetUserId(), id);
            TempData["message"] = "Item removed!";

            return(RedirectToAction(nameof(MyCart)));
        }
예제 #7
0
        public IActionResult MyCart()
        {
            // veikt lietotaja groza atlasi no DB, izmantojot UserCartManager.
            // attelot lietotaja groza saturu
            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());
            // attēlošanai nepieciešamas tikai preces
            var items = userCart.Select(c => c.Item.ToModel()).ToList();

            return(View(items));
        }
        public IActionResult MyCart()
        {
            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());
            // attēlošanai nepieciešamas tikai preces
            var items = userCart.Select(c => c.Item.ToModel()).ToList();

            var distinctItems = items.GroupBy(x => x.Id).Select(group => {
                var item   = group.First();
                item.Count = group.Count();
                return(item);
            }).ToList();

            return(View(distinctItems));
        }
예제 #9
0
        public IActionResult MyCart()
        {
            //todo: veikta lietotaja groza atlasi no DB, izmantojot UserCart Manager
            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());
            //todo: attelot lietotaja groza saturu
            var items = userCart.Select(c => c.Item.ToModel()).ToList();

            foreach (var item in items)
            {
                item.ItemCount = UserCartManager.GetItemCount(item.Id);
            }

            return(View(items));
        }
        public IActionResult MyCart(int userId)
        {
            // TODO: veikt lietotāja groza atlasi no DB, izmantojot UserCartManager.
            var cart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());

            if (cart.Count == 0)
            {
                ModelState.AddModelError("cart", "cart is empty!");
            }

            // TODO: attēlot lietotāja groza saturu.
            var items = cart.Select(c => c.Item.ToModel()).ToList();

            //var items = cart.Select(c => c.Item.ToModel()).Distinct().ToList();


            return(View(items));
        }
예제 #11
0
        public IActionResult MyCart()
        {
            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());
            // attēlošanai nepieciešamas tikai preces
            // grupējam pēc ItemId un skaitām, cik preces ir.
            var items = userCart.Select(c => c.Item.ToModel())
                        .GroupBy(i => i.Id)
                        .Select(g =>
            {
                // grupas pirmais ieraksts ir - prece
                // un skaits - cik šādu preču
                var item   = g.First();
                item.Count = g.Count();

                return(item);
            }).ToList();

            return(View(items));
        }
예제 #12
0
        public IActionResult MyCart()
        {
            //veikt lietotāja groza atlasi no DB, izmantojot usercartmanaget get by user

            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());

            //japarveido uz modeli, attēlojot groza saturu
            var items = userCart.Select(c => c.Item.ToIModel()).ToList();



            foreach (var item in items)
            {
                item.Quantity = UserCartManager.GetItemQuantity(item.Id);
            }

            //jāattēlo tikai preces
            return(View(items));
        }
예제 #13
0
        public IActionResult MyCart()
        {
            // veikt user groza atlasi no DB, izm. UserCartManager.GetByUser()

            var userCart = UserCartManager.GetByUser(HttpContext.Session.GetUserId());

            // pārvērš par modeļiem un attēlot user groza saturu (tikai preces), izm. MyCart skatu.
            // grupē pēc ItemId un skaita preces, cik tās ir

            var items = userCart.Select(c => c.Item.ToModel())
                        .GroupBy(i => i.Id)
                        .Select(g =>
            {
                var item       = g.First();
                item.ItemCount = g.Count();

                return(item);
            }).ToList();

            return(View(items));
        }
 public IActionResult Delete(int id)
 {
     UserCartManager.Delete(id);
     return(RedirectToAction(nameof(MyCart)));
 }
 public IActionResult Confirm(int userId)
 {
     // TODO: veikt lietotāja groza atlasi no DB, izmantojot UserCartManager.
     UserCartManager.Clear(HttpContext.Session.GetUserId());
     return(View());
 }
예제 #16
0
 public IActionResult DeleteFromCart(int id)
 {
     UserCartManager.DeleteFromCart(id);
     return(RedirectToAction("MyCart", "Account"));
 }
예제 #17
0
 public IActionResult Confirm()
 {
     UserCartManager.Clear();
     return(View());
 }
예제 #18
0
        public IActionResult Confirm()
        {
            UserCartManager.DeleteByUser(HttpContext.Session.GetUserId());

            return(View());
        }
예제 #19
0
 public IActionResult Buy(int id)
 {
     UserCartManager.Create(HttpContext.Session.GetUserId(), id);
     return(RedirectToAction("MyCart", "Account"));
 }
예제 #20
0
 public IActionResult Buy(int id)
 {
     //jasaglaba izveleta prece lietotaja groza.
     UserCartManager.Create(HttpContext.Session.GetUserId(), id);
     return(RedirectToAction("MyCart", "Account"));
 }