public virtual PartialViewResult GetMemberDiscussions(Guid id) { if (Request.IsAjaxRequest()) { var loggedOnUser = User.Identity.IsAuthenticated ? MembershipService.GetUser(User.Identity.Name, true) : null; var usersRole = loggedOnUser == null ? RoleService.GetRole(Constants.GuestRoleName, true) : loggedOnUser.Roles.FirstOrDefault(); var allowedGroups = _groupService.GetAllowedGroups(usersRole, loggedOnUser.Id).ToList(); // Get the user discussions, only grab 100 posts var posts = _postService.GetByMember(id, 100, allowedGroups); // Get the distinct topics var topics = posts.Select(x => x.Topic).Distinct().Take(6) .OrderByDescending(x => x.LastPost.DateCreated).ToList(); // Get the Topic View Models var topicViewModels = ViewModelMapping.CreateTopicViewModels(topics, RoleService, usersRole, loggedOnUser, allowedGroups, SettingsService.GetSettings(), _postService, _notificationService, _pollService, _voteService, _favouriteService); // create the view model var viewModel = new ViewMemberDiscussionsViewModel { Topics = topicViewModels }; return(PartialView(viewModel)); } return(null); }
public PartialViewResult GetMemberDiscussions(int id) { if (Request.IsAjaxRequest()) { using (UnitOfWorkManager.NewUnitOfWork()) { // Get the user discussions, only grab 100 posts var posts = ServiceFactory.PostService.GetByMember(id, 100); // Get the distinct topics var topics = posts.Select(x => x.Topic).Where(x => x.Pending != true).Distinct().Take(6).OrderByDescending(x => x.LastPost.DateCreated).ToList(); ServiceFactory.TopicService.PopulateCategories(topics); // Get all the categories for this topic collection var categories = topics.Select(x => x.Category).Distinct(); // create the view model var viewModel = new ViewMemberDiscussionsViewModel { Topics = topics, AllPermissionSets = new Dictionary <Category, PermissionSet>(), CurrentUser = CurrentMember }; // loop through the categories and get the permissions foreach (var category in categories) { var permissionSet = ServiceFactory.PermissionService.GetPermissions(category, _membersGroup); viewModel.AllPermissionSets.Add(category, permissionSet); } return(PartialView(PathHelper.GetThemePartialViewPath("GetMemberDiscussions"), viewModel)); } } return(null); }
public PartialViewResult GetMemberDiscussions(Guid id) { if (Request.IsAjaxRequest()) { using (UnitOfWorkManager.NewUnitOfWork()) { var allowedCategories = _categoryService.GetAllowedCategories(UsersRole).ToList(); // Get the user discussions, only grab 100 posts var posts = _postService.GetByMember(id, 100, allowedCategories); // Get the distinct topics var topics = posts.Select(x => x.Topic).Distinct().Take(6).OrderByDescending(x => x.LastPost.DateCreated).ToList(); // Get the Topic View Models var topicViewModels = ViewModelMapping.CreateTopicViewModels(topics, RoleService, UsersRole, LoggedOnReadOnlyUser, allowedCategories, SettingsService.GetSettings()); // create the view model var viewModel = new ViewMemberDiscussionsViewModel { Topics = topicViewModels }; return PartialView(viewModel); } } return null; }