public async Task <ActionResult> Index(string userID, string searchTerm, int?pageNo, int entityID = (int)EntityEnums.Product, bool showUserCommentsOnly = false) { CommentsListingViewModel model = new CommentsListingViewModel { SearchTerm = searchTerm }; if (!string.IsNullOrEmpty(userID)) { model.User = await UserManager.FindByIdAsync(userID); } model.Comments = CommentsService.Instance.SearchComments(entityID: entityID, recordID: null, userID: userID, searchTerm: model.SearchTerm, pageNo: pageNo, recordSize: (int)RecordSizeEnums.Size10, count: out int commentsCount); if (model.Comments != null && model.Comments.Count > 0) { var productIDs = model.Comments.Select(x => x.RecordID).ToList(); model.CommentedProducts = ProductsService.Instance.GetProductsByIDs(productIDs); } model.Pager = new Pager(commentsCount, pageNo, (int)RecordSizeEnums.Size10); if (showUserCommentsOnly) { return(PartialView("_UserComments", model)); } else { return(View(model)); } }
public async Task <ActionResult> Index(string userID, string searchTerm, int?pageNo, int entityID = (int)EntityEnums.Product, bool isPartial = false) { var pageSize = ConfigurationsHelper.DashboardRecordsSizePerPage; pageNo = pageNo ?? 1; CommentsListingViewModel model = new CommentsListingViewModel(); model.SearchTerm = searchTerm; if (!string.IsNullOrEmpty(userID)) { model.User = await UserManager.FindByIdAsync(userID); } model.Comments = CommentsService.Instance.GetComments(userID, searchTerm, entityID, pageNo, pageSize); if (model.Comments != null && model.Comments.Count > 0) { var productIDs = model.Comments.Select(x => x.RecordID).ToList(); model.CommentedProducts = ProductsService.Instance.GetProductsByIDs(productIDs); } var totalCount = CommentsService.Instance.GetCommentsTotalCount(userID, searchTerm, entityID); model.Pager = new Pager(totalCount, pageNo, pageSize); if (Request.IsAjaxRequest() || isPartial) { return(PartialView("_UserComments", model)); } else { return(View(model)); } }