public IActionResult All(string id) { var comments = new AllCommentsViewModel { Comments = this.profileServices.GetComments <CommentViewModel>(id), UserId = id, }; return(this.View(comments)); }
public IActionResult Comments() { AllCommentsViewModel model = new AllCommentsViewModel() { AllComments = this.dataService.GetComments(), AllCategories = this.dataService.GetObjects <CommentCategory>(), }; return(this.View(model)); }
public IActionResult All() { var defaultCvId = _cvService.GetId(); var viewModel = new AllCommentsViewModel { Comments = _commentsService.GetAll <CommentViewModel>(defaultCvId), InputModel = new CommentCreateInputModel() }; return(View(viewModel)); }
private IActionResult AllWithInputModel(CommentCreateInputModel inputModel) { var defaultCvId = _cvService.GetId(); var viewModel = new AllCommentsViewModel { Comments = _commentsService.GetAll <CommentViewModel>(defaultCvId), InputModel = inputModel }; return(View("All", viewModel)); }
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))); }
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)); }
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); }
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)); }