Esempio n. 1
0
        public IActionResult All(string id)
        {
            var comments = new AllCommentsViewModel
            {
                Comments = this.profileServices.GetComments <CommentViewModel>(id),
                UserId   = id,
            };

            return(this.View(comments));
        }
Esempio n. 2
0
        public IActionResult Comments()
        {
            AllCommentsViewModel model = new AllCommentsViewModel()
            {
                AllComments   = this.dataService.GetComments(),
                AllCategories = this.dataService.GetObjects <CommentCategory>(),
            };

            return(this.View(model));
        }
Esempio n. 3
0
        public IActionResult All()
        {
            var defaultCvId = _cvService.GetId();
            var viewModel   = new AllCommentsViewModel
            {
                Comments   = _commentsService.GetAll <CommentViewModel>(defaultCvId),
                InputModel = new CommentCreateInputModel()
            };

            return(View(viewModel));
        }
Esempio n. 4
0
        private IActionResult AllWithInputModel(CommentCreateInputModel inputModel)
        {
            var defaultCvId = _cvService.GetId();
            var viewModel   = new AllCommentsViewModel
            {
                Comments   = _commentsService.GetAll <CommentViewModel>(defaultCvId),
                InputModel = inputModel
            };

            return(View("All", viewModel));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(AllCommentsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(AllWithInputModel(model.InputModel));
            }

            var defaultCvId = _cvService.GetId();
            var user        = await _userManager.GetUserAsync(User);

            await _commentsService.CreateAsync(model.InputModel.Content, defaultCvId, user.Id);

            return(RedirectToAction(nameof(All)));
        }
Esempio n. 6
0
        public AllCommentsViewModel BuildAllCommentsViewModel(int id)
        {
            var post  = _postRepository.GetPost(id);
            var model = new AllCommentsViewModel()
            {
                CommentList = new List <CommentViewModel>()
            };

            foreach (var comment in post.Comments)
            {
                if (_displayValidator.IsAvailableComment(comment))
                {
                    model.CommentList.Add(BuildCommentViewModel(comment.Id));
                }
            }
            model.CommentList.Reverse();
            return(model);
        }
        public IActionResult All()
        {
            var comments = this.commentsService.All()
                           .Select(vm => new CommentViewModel
            {
                User    = vm.User.UserName,
                Comment = vm.Content,
                Date    = vm.CreatedOn.ToShortDateString()
            })
                           .OrderByDescending(d => d.Date)
                           .ToList();

            var commentViewModels = new AllCommentsViewModel
            {
                Comments = comments
            };

            return(this.View(commentViewModels));
        }
        public IActionResult Left()
        {
            var currentUsername = this.User.Identity.Name;

            var comments = this.commentsService.LeftCommentsByUser(currentUsername)
                           .Select(vm => new CommentViewModel
            {
                Comment = vm.Content,
                Date    = vm.CreatedOn.ToShortDateString()
            })
                           .OrderByDescending(d => d.Date)
                           .ToList();

            var commentViewModels = new AllCommentsViewModel
            {
                Comments = comments
            };

            return(this.View(commentViewModels));
        }
Esempio n. 9
0
        public async Task <AllCommentsViewModel> GetComments([FromQuery] GetCommentsViewModel viewModel)
        {
            var    user   = this.User.FindFirst(ClaimTypes.NameIdentifier);
            string userId = null;

            if (user != null)
            {
                userId = user.Value;
            }

            var comments = new AllCommentsViewModel()
            {
                Page           = viewModel.Page,
                CommentCount   = this.commentService.GetCommentsCountForItem(viewModel.ItemId),
                CommentPerPage = CommentsPerPage,
                Comments       = await this.commentService.GetCommentsForItemAsync(CommentsPerPage, viewModel.Page, viewModel.ItemId, userId),
            };

            return(comments);
        }
Esempio n. 10
0
        public ActionResult AllComments(int Page = 1, int PageSize = 25)
        {
            AllCommentsViewModel viewModel = new AllCommentsViewModel();

            // New search term
            if (System.Web.HttpContext.Current.Request.HttpMethod == "POST")
            {
                Page = 1;
            }

            if (PageSize == 0)
            {
                PageSize = 25;
            }

            viewModel.PageSize = PageSize;

            IQueryable <Comment> comments = repository.Comments;

            viewModel.PaginatedCommentList = comments.OrderByDescending(c => c.Date).ToPaginatedList <Comment>(Page, PageSize);

            return(View(viewModel));
        }