public ProductViewModel GetProductViewModel() { var categories = _context.Categories.ToList(); var districts = _context.Districts.ToList(); var domains = _context.Categories.Select(c => c.Domain).Distinct().ToList(); CartService cs = new CartService(_httpContextAccessor, _context); var totalPrice = cs.GetCartTotalPrice(); var cartCount = cs.GetCartCount(); var viewmodel = new ProductViewModel { District = districts, Category = categories, DistinctCat = domains, CartCount = cartCount, TotalPrice = totalPrice, Sellers = _context.Sellers.ToList() }; return(viewmodel); }
public ProductService(IHttpContextAccessor httpContextAccessor, ApplicationDbContext context) { _httpContextAccessor = httpContextAccessor; _context = context; cartService = new CartService(httpContextAccessor, _context); }