public IActionResult Index(string function = "", string sector = "") { var model = new CatalogModel(); model.CatalogFunctions = _catalogFunctionService.GetAll(CurrentLang); model.CatalogSectors = _catalogSectorService.GetAll(CurrentLang); ViewBag.color = ""; if (!string.IsNullOrWhiteSpace(function)) { model.Products = _productService.GetProductByFunction(function); model.Title = model.CatalogFunctions.Where(x => x.Slug == function).FirstOrDefault().Name; ViewBag.color = model.CatalogFunctions.Where(x => x.Slug == function).FirstOrDefault().Color; } else if (!string.IsNullOrWhiteSpace(sector)) { model.Products = _productService.GetProductBySector(sector); model.Title = model.CatalogSectors.Where(x => x.Slug == sector).FirstOrDefault().Name; ViewBag.color = model.CatalogSectors.Where(x => x.Slug == sector).FirstOrDefault().Color; } else { model.Products = _productService.GetAll(CurrentLang); model.Title = "Tất cả"; } ViewBag.UrlImage = _webImageService.GetAll(Data.Enum.Position.BreadcrumbProduct).FirstOrDefault()?.URLImage; return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync() { var model = new HeaderModel(); model.CatalogFunctions = await Task.Run(() => _catalogFunctionService.GetAll(Data.Enum.Languages.Vi, true)); model.CatalogSectors = _catalogSectorService.GetAll(Data.Enum.Languages.Vi, true); model.CategoryBlogs = _categoryBlogService.GetAll(Data.Enum.Languages.Vi); model.PageContents = _pageContentService.GetAll(false, Data.Enum.Languages.Vi); return(View("_Header", model)); }
public IActionResult Index() { var model = new HomeModel(); model.Images = _webImageService.GetAll(Data.Enum.Position.HomeSlide); model.PostsHot = _postService.GetAll(CurrentLang, 2, true, active: true, publishDate: true); model.CatalogFunctions = _catalogFunctionService.GetAll(CurrentLang, true, true); model.Logos = _webImageService.GetAll(Data.Enum.Position.Logo); foreach (var item in model.CatalogFunctions) { item.Product = item.Product.Where(x => x.New == true).ToList(); } model.CatalogSectors = _catalogSectorService.GetAll(CurrentLang, true, true); foreach (var item in model.CatalogSectors) { item.Product = item.Product.Where(x => x.New == true).ToList(); } model.Category = _categoryBlogService.GetAll(CurrentLang); foreach (var item in model.Category) { var posts = _postService.GetPagedAll(1, 4, publishDate: true, lang: CurrentLang, cat: item.Slug); if (model.Posts is null) { model.Posts = posts.Results; } else { var tmp = model.Posts.ToList(); foreach (var post in posts.Results) { tmp.Add(post); } model.Posts = tmp; } } return(View(model)); }
public IActionResult Get(string filter = "") { var model = _catalogFunctionService.GetAll(null); return(Ok(model)); }