public SimpleListContainerModel GetCommentSupporters(int pageNumber, ICommentable entity, string commentId, string parentId) { Comment comment; if (!string.IsNullOrEmpty(parentId)) { var parent = GetComment(entity, parentId); comment = parent.Comments.Where(c => c.Id == commentId).SingleOrDefault(); } else { comment = GetComment(entity, commentId); } if (comment == null) { return(new SimpleListContainerModel()); } var result = comment.SupportingUserIds.Select( i => new SimpleListModel { Id = i, Subject = GetUserFullName(i) }).OrderByDescending(i => i.Subject) .GetExpandablePage(pageNumber, CustomAppSettings.PageSizeList).ToList(); result.ForEach(r => r.Type = EntryTypes.User); var simpleList = new SimpleListContainerModel(); simpleList.List = new ExpandableList <SimpleListModel>(result, CustomAppSettings.PageSizeList); return(simpleList); }
public virtual ActionResult GetNextGetCommentSupportersPage(int?pageIndex, string entryId, string commentId, EntryTypes type, string parentId) { if (!pageIndex.HasValue) { return(Json(null)); } SimpleListContainerModel model = null; if (type == EntryTypes.Issue) { var service = (VotingService)ServiceLocator.Resolve(typeof(VotingService)); model = service.GetCommentSupporters(pageIndex.Value, entryId, commentId, parentId); } else if (type == EntryTypes.Idea) { var service = (IdeaService)ServiceLocator.Resolve(typeof(IdeaService)); model = service.GetCommentSupporters(pageIndex.Value, entryId, commentId, parentId); } else if (type == EntryTypes.Problem) { var service = (ProblemService)ServiceLocator.Resolve(typeof(ProblemService)); model = service.GetCommentSupporters(pageIndex.Value, entryId, commentId, null); } else { return(Json(null)); } var json = new { Content = RenderPartialViewToString(MVC.Shared.Views.SimpleList, model.List.List), model.List.HasMoreElements }; return(Json(json)); }
public virtual ActionResult GetCommentSupporters(string entryId, string commentId, EntryTypes?type, string parentId) { if (!Request.IsAjaxRequest()) { return(Start()); } if (string.IsNullOrEmpty(entryId) || string.IsNullOrEmpty(commentId) || !type.HasValue) { return(Start()); } SimpleListContainerModel model = null; if (type == EntryTypes.Issue) { var service = (VotingService)ServiceLocator.Resolve(typeof(VotingService)); model = service.GetCommentSupporters(0, entryId, commentId, parentId); } else if (type == EntryTypes.Idea) { var service = (IdeaService)ServiceLocator.Resolve(typeof(IdeaService)); model = service.GetCommentSupporters(0, entryId, commentId, parentId); } else if (type == EntryTypes.Problem) { var service = (ProblemService)ServiceLocator.Resolve(typeof(ProblemService)); model = service.GetCommentSupporters(0, entryId, commentId, null); } else if (type == EntryTypes.User) { var service = (UserService)ServiceLocator.Resolve(typeof(UserService)); model = service.GetCommentSupporters(0, entryId, commentId, parentId); } else { return(Json(null)); } model.ActionResult = MVC.Common.GetNextGetCommentSupportersPage(null, entryId, commentId, type.Value, parentId); var json = new { Content = RenderPartialViewToString(MVC.Shared.Views.SimpleListContainer, model) }; return(Json(json)); }
public SimpleListContainerModel GetMyProjects(int pageNumber, string userObjectId) { using (var actionSession = actionSessionFactory.CreateContext()) { var result = (from a in actionSession.Actions where a.UserObjectId == userObjectId && a.ActionTypeId == (int)ActionTypes.JoinedProject && (!a.IsPrivate || CurrentUser.OrganizationIds.Contains(a.OrganizationId)) && !a.IsDeleted group a by new { Id = a.ObjectId, Subject = a.Subject } into g select new SimpleListModel { Id = g.Key.Id, Subject = g.Key.Subject, Date = g.Max(a => a.Date) }).OrderByDescending(i => i.Date).GetExpandablePage(pageNumber, CustomAppSettings.PageSizeList).ToList(); result.ForEach(r => r.Type = EntryTypes.Project); var simpleList = new SimpleListContainerModel(); simpleList.List = new ExpandableList <SimpleListModel>(result, CustomAppSettings.PageSizeList); return(simpleList); } }