public async Task <IActionResult> GetAllCategories() { ProductCategoryListViewModel result = await _queryDispatcher.DispatchAsync <QueryProductCategoryListView, ProductCategoryListViewModel>( new QueryProductCategoryListView()); return(Ok(result)); }
public IActionResult List() { var ProductCategoryListViewModel = new ProductCategoryListViewModel() { Products = _productService.GetAll(), }; return(View(ProductCategoryListViewModel)); }
public ActionResult Index() { var viewModel = new ProductCategoryListViewModel() { products = productRepository.GetProducts(), productCategories = productCategoryRepository.GetProductCategoris(), }; return(View(viewModel)); }
public IActionResult Index() { var ProductCategoryListViewModel = new ProductCategoryListViewModel() { Products = _productService.GetAll(), Categories = _categoryService.GetAll() }; return(View(ProductCategoryListViewModel)); }
//List public async Task <ActionResult> Index(int page = 1) { int pageSize = 10; var items = _mapper.Map <IEnumerable <ProductCategoryViewModel> >(await _service.GetItems(pageSize, page - 1)); var pageInfo = new PageInfo() { PageNumber = page, PageSize = pageSize, TotalItems = await _service.Count() }; ProductCategoryListViewModel categorytList = new ProductCategoryListViewModel() { Categories = items, PageInfo = pageInfo }; return(View(categorytList)); }
public async Task <IActionResult> ProductCatalog(int id, int?pageSize, string sortBy, int page = 1) { var productCategory = new ProductCategoryListViewModel(); var categories = new List <LookupItem>(); var category = await _productCategoryService.GetById(id); if (category.ParentId == null) { // lấy tất cả danh sách các sản phẩm cùng cha var dataReturn = await _productCategoryService.GetAllByParentId(category.Id); categories = dataReturn.AsParallel().WithExecutionMode(ParallelExecutionMode.ForceParallelism).Select(x => new LookupItem { Id = x.Id, Name = x.Name, Key = x.SeoAlias }).ToList(); } else { var dataReturn = await _productCategoryService.GetAllByParentId(category.ParentId.Value); categories = dataReturn.AsParallel().WithExecutionMode(ParallelExecutionMode.ForceParallelism).Select(x => new LookupItem { Id = x.Id, Name = x.Name, Key = x.SeoAlias }).ToList(); } var sizeVMs = await _sizeService.GetAll(); productCategory.Sizes = sizeVMs.Select(x => new LookupItem { Id = x.Id, Name = x.Name }).ToList(); var colorVMs = await _colorService.GetAll(); productCategory.Colors = colorVMs.Select(x => new LookupItem { Id = x.Id, Name = x.Name }).ToList(); var categoryCurrent = await _productCategoryService.GetById(id); productCategory.CurrentCategory = new LookupItem { Id = categoryCurrent.Id, Name = categoryCurrent.SeoAlias }; //get cart model productCategory.CartViewModels = HttpContext.Session.Get <List <ShoppingCartViewModel> >(CommonConstants.CartSession); productCategory.Categories = categories; return(View(productCategory)); }