private void GetContent(HomePageDataContentModel result,
                                DbSet <DAL.Entities.Content.Banner> banners,
                                List <DAL.Entities.Gaming.Category> categories,
                                GamblingType gamblingType)
        {
            var bannerModels = Mapper.Map <List <BannerModel> >(
                banners.Where(x => x.GamblingType == gamblingType)
                .OrderBy(x => x.Priority)
                .ToList());

            for (int i = 0; i < bannerModels.Count; i++)
            {
                bannerModels[i].Num = i + 1;
            }

            result.Content.Add(new GamblingTypeDataModel
            {
                GamblingType       = gamblingType.ToString(),
                Banners            = bannerModels,
                HomePageCategories = Mapper.Map <IEnumerable <HomePageCategoryModel> >(
                    categories.Where(x => x.GamblingType == gamblingType && x.IsOnHomePage)),
                Categories = Mapper.Map <IEnumerable <DefaultCategoryModel> >(
                    categories.Where(x => x.GamblingType == gamblingType))
            });
        }
        public HomePageDataContentModel HomePage()
        {
            HomePageDataContentModel result = new HomePageDataContentModel();

            try
            {
                var banners    = GamblingDbContext.Banners;
                var categories = GamblingDbContext.Categories
                                 .Include(cat => cat.CategoryGames)
                                 .ThenInclude(cg => cg.Game)
                                 .OrderBy(cat => cat.Priority)
                                 .ToList();

                foreach (var item in categories)
                {
                    item.CategoryGames = item.CategoryGames
                                         .Where(cg => cg.IsOnHomePage)
                                         .OrderBy(cg => cg.Priority)
                                         .Take(15)
                                         .ToList();
                }

                GetContent(result, banners, categories, GamblingType.Casino);
                GetContent(result, banners, categories, GamblingType.LiveCasino);
            }
            catch
            {
                result.AddDefaultError();
            }

            return(result);
        }