protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); bool flag = true; if (!this._isInitialized) { this._ownerId = long.Parse(((Page)this).NavigationContext.QueryString["OwnerId"]); this._videoId = long.Parse(((Page)this).NavigationContext.QueryString["VideoId"]); string accessKey = ((Page)this).NavigationContext.QueryString["AccessKey"]; string videoContext = ""; if (((Page)this).NavigationContext.QueryString.ContainsKey("VideoContext")) { videoContext = ((Page)this).NavigationContext.QueryString["VideoContext"]; } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("Video") as VKClient.Common.Backend.DataObjects.Video; StatisticsActionSource actionSource = (StatisticsActionSource)Enum.Parse(typeof(StatisticsActionSource), ((Page)this).NavigationContext.QueryString["VideoSource"]); this.InitializeCommentVM(); VideoCommentsViewModel commentsViewModel = new VideoCommentsViewModel(this._ownerId, this._videoId, accessKey, parameterForIdAndReset, actionSource, videoContext); commentsViewModel.PageLoadInfoViewModel.LoadingStateChangedCallback = new Action(this.OnLoadingStateChanged); base.DataContext = (commentsViewModel); commentsViewModel.Reload(true); this.RestoreUnboundState(); this._isInitialized = true; flag = false; } if (!flag && (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New)) { WallPostVMCacheManager.TryDeserializeInstance(this._commentVM); } this.ProcessInputData(); this.UpdateAppBar(); }
public async Task <JsonNetResult> ByVideo(GetVideoCommentsViewModel model) { VideoComments result = await _comments.GetVideoComments(new GetVideoComments { VideoId = model.VideoId, PageSize = model.PageSize, FirstCommentIdOnPage = model.FirstCommentIdOnPage }); // For the ViewModel, we also want to include the information about a user who made the comments on the video, so // get the user profile information for the comments and then use a LINQ to Objects Join to merge the two together // (this should be OK since the dataset should be small) IEnumerable <UserProfile> userProfiles = await _userManagement.GetUserProfiles(result.Comments.Select(c => c.UserId).ToHashSet()); var returnModel = new VideoCommentsViewModel { VideoId = result.VideoId, Comments = result.Comments.Join(userProfiles, c => c.UserId, up => up.UserId, (c, up) => new VideoCommentViewModel { CommentId = c.CommentId, Comment = c.Comment, CommentTimestamp = c.CommentTimestamp, UserProfileUrl = Url.Action("Info", "Account", new { userId = c.UserId }), UserFirstName = up.FirstName, UserLastName = up.LastName, UserGravatarImageUrl = GravatarHasher.GetImageUrlForEmailAddress(up.EmailAddress) }).ToList() }; return(JsonSuccess(returnModel)); }