コード例 #1
0
 public async void GoToCommentsPage(CommentsPageViewModel viewModel, bool canGoBack)
 {
     await GoToPage(new CommentsPage()
     {
         BindingContext = viewModel ?? _container.Resolve <CommentsPageViewModel>()
     }, canGoBack);
 }
コード例 #2
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            vm = new CommentsPageViewModel();
            this.BindingContext = vm;
            if (NetworkCheck.IsInternet())
            {
                await vm.FetchCommnetData(requirementId);
            }
            else
            {
                await DisplayAlert("Simon", "No network is available.", "OK");
            }
        }
コード例 #3
0
        private async Task GetComments()
        {
            _commentsPageViewModel = new CommentsPageViewModel();
            _commentsPageViewModel.CommentsCollection = new ObservableCollection <Comment>();
            List <Comment> commentsList = await ProgenyService.GetComments(_viewModel.CurrentPictureViewModel.CommentThreadNumber);

            if (commentsList.Any())
            {
                foreach (var comment in commentsList)
                {
                    _commentsPageViewModel.CommentsCollection.Add(comment);
                }

                _viewModel.CurrentPictureViewModel.CommentsCount = commentsList.Count;
            }
            CommentsCollectionView.ItemsSource = _commentsPageViewModel.CommentsCollection;
        }
コード例 #4
0
        public CommentsPageViewModel GetTaskCommentsPage(int taskId, int pageNumber, long timeOfLoadTicks)
        {
            try
            {
                DateTime timeOfLoad = new DateTime(timeOfLoadTicks);
                using (ApplicationDbContext context = new ApplicationDbContext())
                {
                    CommentsPageViewModel viewModel = new CommentsPageViewModel();
                    var task = context.Tasks.FirstOrDefault(t => t.TaskID == taskId);
                    if (task != null)
                    {
                        viewModel.IsValid = true;

                        if (IsAuthorized(task, context))
                        {
                            viewModel.IsAuthorized = true;
                            viewModel.Comments     = GetComments(task, context, pageNumber, timeOfLoad);

                            return(viewModel);
                        }
                        else
                        {
                            viewModel.IsAuthorized = false;
                        }
                    }
                    else
                    {
                        viewModel.IsValid = false;
                    }
                    return(viewModel);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
コード例 #5
0
 public void GoToCommentsPage(CommentsPageViewModel viewModel, bool canGoBack)
 {
     Device.BeginInvokeOnMainThread(() =>
                                    OnOpenCommentsPage?.Invoke(viewModel, canGoBack));
 }
コード例 #6
0
        public ViewResult Index(SitePageData currentPage, string orderBy = "ASC")
        {
            IPageViewModel <SitePageData> model = CreateModel(currentPage);

            if (currentPage is IContentWithComments)
            {
                var commentsModel = new CommentsPageViewModel(currentPage);

                // get (or create if necessary) the start page's comments folder
                var start = repo.Get <StartPage>(ContentReference.StartPage);

                ContentReference siteCommentsFolderReference;
                if (!ContentReference.IsNullOrEmpty(start.CommentFolder))
                {
                    siteCommentsFolderReference = start.CommentFolder;
                }
                else
                {
                    // create the site comments folder inside the "For This Site" block folder
                    ContentFolder siteCommentsFolder = repo.GetDefault <ContentFolder>(ContentReference.SiteBlockFolder);
                    siteCommentsFolder.Name     = "Comments";
                    siteCommentsFolderReference = repo.Save(siteCommentsFolder,
                                                            EPiServer.DataAccess.SaveAction.Publish,
                                                            EPiServer.Security.AccessLevel.NoAccess);

                    // set reference to the site comments folder on the start page
                    start = start.CreateWritableClone() as StartPage;
                    start.CommentFolder = siteCommentsFolderReference;
                    repo.Save(start,
                              EPiServer.DataAccess.SaveAction.Publish,
                              EPiServer.Security.AccessLevel.NoAccess);
                }

                // check if the Start page has its CommentFolder set
                commentsModel.StartPageHasCommentsFolder = (!ContentReference.IsNullOrEmpty(start.CommentFolder));

                bool publishToStartComments = false;

                if (commentsModel.StartPageHasCommentsFolder)
                {
                    // check if the current user has Publish rights to the Start page's CommentFolder
                    ContentFolder startCommentsFolder = repo.Get <ContentFolder>(start.CommentFolder);
                    publishToStartComments = (startCommentsFolder.QueryDistinctAccess(EPiServer.Security.AccessLevel.Publish));
                }

                bool publishToThisPagesComments = false;

                if (!ContentReference.IsNullOrEmpty(currentPage.CommentFolder))
                {
                    // if current page has CommentFolder, get the comments
                    IEnumerable <CommentBlock> blocks = repo.GetChildren <CommentBlock>(currentPage.CommentFolder);

                    // filter comments to only show those:
                    // 1) with a partial view
                    // 2) the current user can access
                    // 3) are published
                    var filter       = new FilterContentForVisitor(TemplateTypeCategories.MvcPartialView, string.Empty);
                    var listOfBlocks = blocks.OfType <IContent>().ToList();
                    filter.Filter(listOfBlocks);
                    var listOfComments = listOfBlocks.OfType <CommentBlock>();

                    // sort the comments by publish date
                    if (orderBy == "ASC")
                    {
                        commentsModel.Comments = listOfComments.OrderBy(c => c.When);
                    }
                    else
                    {
                        commentsModel.Comments = listOfComments.OrderByDescending(c => c.When);
                    }

                    commentsModel.ThisPageHasAtLeastOneComment = (commentsModel.Comments.Count() > 0);

                    // check if the current user has Publish rights to the current page's CommentFolder
                    ContentFolder commentsFolder = repo.Get <ContentFolder>(currentPage.CommentFolder);
                    publishToThisPagesComments = (commentsFolder.QueryDistinctAccess(EPiServer.Security.AccessLevel.Publish));
                }

                // set flag to indicate the current user can add comments because either:
                // 1) they have Publish rights to Start's CommentFolder
                // 2) they have Publish rights to current page's CommentFolder
                commentsModel.CurrentUserCanAddComments = (publishToStartComments || publishToThisPagesComments);

                model = commentsModel;
            }

            return(View(string.Format("~/Views/{0}/Index.cshtml", currentPage.GetOriginalType().Name), model));
        }