コード例 #1
0
        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);
        }
コード例 #2
0
 public static UserIndexViewModel ToViewModel(this UserIndexDto source)
 {
     return(new UserIndexViewModel
     {
         ProductCategries = source.ProductCategries.ToViewModel(),
         SlideShows = source.SlideShows.ToViewModel(),
         ProductsAmazing = source.ProductsAmazing.ToViewModel()
     });
 }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: UserService.cs プロジェクト: mobinhassani9374/Shop
        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);
        }
コード例 #5
0
 public static ResponseWrapper ForUserIndexPage(UserIndexDto userIndexDto) =>
 new ResponseWrapper(HttpStatusCode.OK, GetUserIndexPageCacheHeaders(userIndexDto), userIndexDto);