Пример #1
0
        public PartialViewResult MainView()
        {
            BundleConfig.RegisterMainViewBundles(BundleTable.Bundles);

            var model = new MainViewModel();

            // Set current location.
            UserProfile profile = _userProfileStore.GetUserProfileById(User.Identity.GetUserId());

            _SetLocation(profile, ref model);

            // Fill model.
            model.Language = CurrentLang.Id;

            foreach (CommonSuggestionType itemType in Enum.GetValues(typeof(CommonSuggestionType)))
            {
                model.CommonSuggestionTypes.Add(itemType.ToString());
            }

            var blog = this._dataStore.GetBlogs(1, CurrentLang.Id, NewsTagsHelpers.GetTagDescription(NewsTags.Video));

            if (blog.Any())
            {
                model.PromoVideoDescription = blog[0].Header;
            }

            model.NewsDevicesItems = this._dataStore.GetBlogs(NewsConstants.NumberOfVisibleFeeds, CurrentLang.Id,
                                                              NewsTagsHelpers.GetTagDescription(NewsTags.Devices),
                                                              NewsTagsHelpers.GetTagDescription(NewsTags.AI),
                                                              NewsTagsHelpers.GetTagDescription(NewsTags.Robots));
            model.NewsClothesItems = this._dataStore.GetBlogs(NewsConstants.NumberOfVisibleFeeds, CurrentLang.Id, NewsTagsHelpers.GetTagDescription(NewsTags.Clothes));
            model.NewsStatupsItems = this._dataStore.GetBlogs(NewsConstants.NumberOfVisibleFeeds, CurrentLang.Id, NewsTagsHelpers.GetTagDescription(NewsTags.Startups));

            model.ActionTypes = this._dataStore
                                .GetAllActiveActionTypes(base.CurrentLang.Id)
                                .Where(x => x.Id != 11 && x.Id != 12 && x.Id != 15 && x.Id != 16 && x.Id != 11 && x.Id != 12 && x.Id != 17 && x.Id != 18) // TODO Temporary hide redundant filters.
                                .ToList();
            //model.ItemTypes = CommonHelpers.GetItemTypesForFilter(base.CurrentLang.Id);

            // Gather statistics of page visiting.
            if (profile != null && !string.IsNullOrEmpty(profile.PhiUserId))
            {
                _GatherStatistics(profile.PhiUserId, null, null, "mainView");
            }
            else
            {
                _GatherStatistics(null, null, null, "mainView");
            }

            return(PartialView(model));
        }
Пример #2
0
        private static string DetectTheme(News newsItem)
        {
            var possible = new Dictionary <NewsTags, string[]>()
            {
                {
                    NewsTags.Devices, new [] { "часы", "часов", "watch", "наушники", "phones", "audio", "звук", "аудио", "фитнес", "трекер", "fitnes", "track" }
                },
                {
                    NewsTags.AI, new [] { "artificial", "intelligence", "machine learning", "recognition", "deep learning", "интеллект", "машинно" }
                },
                {
                    NewsTags.Robots, new [] { "robot", "робот" }
                },
                // Important to have it last.
                {
                    NewsTags.Clothes, new [] { "clothe", "clothi", "wears", "weari", "smart-", "одежд", "текстиль", "смарт-", "умных", "умные", "умная" }
                },
                {
                    NewsTags.Startups, new [] { "startup", "стартап" }
                }
            };

            foreach (NewsTags tag in possible.Keys)
            {
                for (int i = 0; i < possible[tag].Length; i++)
                {
                    if ((newsItem.Header != null && newsItem.Header.IndexOf(possible[tag][i], StringComparison.InvariantCultureIgnoreCase) > -1) ||
                        (newsItem.Description != null && newsItem.Description.IndexOf(possible[tag][i], StringComparison.InvariantCultureIgnoreCase) > -1))
                    {
                        return(NewsTagsHelpers.GetTagDescription(tag));
                    }
                }
            }

            return(NewsTagsHelpers.GetTagDescription(NewsTags.Common));
        }