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; }
public PartialViewResult GetMemberDiscussions(Guid Id) { if (Request.IsAjaxRequest()) { using (UnitOfWorkManager.NewUnitOfWork()) { // Get the user discussions, only grab 100 posts var posts = _postService.GetByMember(Id, 100); // Get the distinct topics var topics = posts.Select(x => x.Topic).Distinct().Take(6).OrderByDescending(x => x.LastPost.DateCreated).ToList(); // 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 = LoggedOnUser }; // loop through the categories and get the permissions foreach (var category in categories) { var permissionSet = RoleService.GetPermissions(category, UsersRole); viewModel.AllPermissionSets.Add(category, permissionSet); } return PartialView(viewModel); } } return null; }