Esempio n. 1
0
        // GET: CartItems/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CartItem cartItem = repo.Find((int)id);

            if (cartItem == null)
            {
                return(HttpNotFound());
            }
            return(View(cartItem));
        }
        public IActionResult Index()
        {
            var customer = _customerRepository.First(e => true);
            var items    = _cartItemRepository.Find(e => e.CartId == customer.CustomerId).ToList();
            var products = _productRepository.GetAll();

            foreach (var cartItem in items)
            {
                cartItem.Product = products.FirstOrDefault(e => e.ProductId == cartItem.ProductId);
            }

            var viewModel = new CartViewModel
            {
                Customer  = customer,
                CartItems = items.ToList()
            };

            return(View(viewModel));
        }