public new ActionResult Profile() { BundleConfig.RegisterProfileBundles(BundleTable.Bundles); ProfileViewModel viewModel = null; try { string userId = User.Identity.GetUserId(); string userName = User.Identity.GetUserName(); PhiUser currentUser = _userStore.FindByNameAsync(userName).Result; UserProfile profile = _userProfileStore.GetUserProfileById(userId); if (currentUser != null) { if (profile == null) { this._userProfileStore.Insert(new UserProfile { PhiUserId = currentUser.Id, NotifyMeAboutSuddenWeatherEvents = true // True by default }); profile = _userProfileStore.GetUserProfileById(User.Identity.GetUserId()); } var location = _GetLocationDescription(profile.LocationId); viewModel = new ProfileViewModel { FirstName = currentUser.FirstName, LastName = currentUser.LastName, UserName = currentUser.UserName, DateCreated = currentUser.DateCreated, Email = currentUser.Email, Gender = profile.Gender, AvatarPictureUrl = profile.AvatarPictureUrl, Location = location, IsCheckedLocation = false }; _GatherStatistics(userId, currentUser.UserName, currentUser.Email, "Profile"); } else { _GatherStatistics(userId, userName, null, "Profile"); } } catch (Exception ex) { _logger.Error("Exception HttpGet Profile", ex); } if (viewModel != null) { return(View(viewModel)); } return(RedirectToAction("Index", "Home")); }
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)); }