public static IDictionary <string, string> GetUserIndexPageCacheHeaders(UserIndexDto userIndexDto) { userIndexDto.ThrowIfNull(nameof(userIndexDto)); var headers = CacheAtCdnFor(GetSecondsInAYear()); headers.Add("Surrogate-Key", string.Join(" ", userIndexDto.UserIds)); return(headers); }
public static UserIndexViewModel ToViewModel(this UserIndexDto source) { return(new UserIndexViewModel { ProductCategries = source.ProductCategries.ToViewModel(), SlideShows = source.SlideShows.ToViewModel(), ProductsAmazing = source.ProductsAmazing.ToViewModel() }); }
public async Task <ActionResult> Index() { Session["LangId"] = 2; var obj = new UserIndexDto(); obj.ParameterClass = _displayParameters.GetParameters(); obj.ParameterClass.MenuLink = _displayParameters.GetMenuLink(); obj.ParentProductDto = await _productService.GetParentProductsWithChildProduct(); obj.ChildProductDto = await _productService.GetDisplayProducts(); return(View(obj)); }
public UserIndexDto GetUserIndexData() { var result = new UserIndexDto(); var categories = _dbContext.Categories .Include(c => c.Children) .Include(c => c.Products) .AsEnumerable() .Where(c => !c.ParentId.HasValue) .ToList(); result.ProductCategries = new List <Domain.Dto.Home.CategoryDto>(); foreach (var category in categories) { var output = new Domain.Dto.Home.CategoryDto(); output.Id = category.Id; output.CategoryTitle = category.Title; _product.AddRange(category.Products.ToList()); GetProduct(category.Children.ToList()); output.Products = _product.Select(i => new Domain.Dto.Home.ProductDto { Id = i.Id, Title = i.Title, Count = i.Count, Price = i.Price, PrimaryImage = i.PrimaryImage, Discount = i.Discount, IsAmazing = i.IsAmazing }).ToList(); _product.Clear(); result.ProductCategries.Add(output); } result.SlideShows = GetAllSlideShows(); result.ProductsAmazing = _dbContext .Products .Where(c => c.IsAmazing && c.Count > 0) .ToList() .ToDto(); return(result); }
public static ResponseWrapper ForUserIndexPage(UserIndexDto userIndexDto) => new ResponseWrapper(HttpStatusCode.OK, GetUserIndexPageCacheHeaders(userIndexDto), userIndexDto);