示例#1
0
        public IActionResult ShowCart()
        {
            List <ShowCartViewModel> list = new List <ShowCartViewModel>();

            if (User.Identity.IsAuthenticated)
            {
                string uId = User.FindFirstValue(ClaimTypes.NameIdentifier);
                Order  o   = _orderRepository.OrderExists(uId);
                if (o != null)
                {
                    var details = _orderDetailRepository.FindOrder(o.OrderId);
                    foreach (var item in details)
                    {
                        var p = _pizzaRepository.GetPizzaById(item.PizzaId);
                        list.Add(new ShowCartViewModel()
                        {
                            OrderDetailId = item.OrderDetailID,
                            Count         = item.Count,
                            Title         = p.Name,
                            ImageName     = p.ImageUrl
                        });
                    }
                }
            }

            return(View(list));
        }