public ActionResult Index(string urlName, int page = 1) { var forum = _forumService.Get(urlName); if (forum == null) { return(this.NotFound("NotFound", null)); } var user = this.CurrentUser(); var permissionContext = _forumService.GetPermissionContext(forum, user); if (!permissionContext.UserCanView) { return(this.Forbidden("Forbidden", null)); } var closureDate = _categoryService.GetValue().ClosureDate.Date; if (DateTime.Now.Date > closureDate) { permissionContext.NotPost = true; } PagerContext pagerContext; var topics = _topicService.GetTopics(forum, permissionContext.UserCanModerate, page, out pagerContext); if (this.CurrentUser().UserType == 1) { foreach (var item in topics) { item.ReplyCount = _postService.GetReplyCountByStudent(item.TopicID, false, 0); } } var container = new ForumTopicContainer { Forum = forum, Topics = topics, PagerContext = pagerContext, PermissionContext = permissionContext }; _lastReadService.GetTopicReadStatus(user, container); var adapter = new ForumAdapterFactory(forum); if (adapter.IsAdapterEnabled) { adapter.ForumAdapter.AdaptForum(this, container); if (String.IsNullOrWhiteSpace(adapter.ForumAdapter.ViewName)) { return(View(adapter.ForumAdapter.Model)); } return(View(adapter.ForumAdapter.ViewName, adapter.ForumAdapter.Model)); } if (forum.IsQAForum) { return(View("IndexQA", container)); } return(View(container)); }
public ActionResult Posts(int id, int page = 1) { var postUser = _userService.GetUser(id); if (postUser == null) { return(NotFound()); } var includeDeleted = false; var user = _userRetrievalShim.GetUser(HttpContext); if (user != null && user.IsInRole(PermanentRoles.Moderator)) { includeDeleted = true; } var titles = _forumService.GetAllForumTitles(); PagerContext pagerContext; var topics = _topicService.GetTopics(user, postUser, includeDeleted, page, out pagerContext); var container = new PagedTopicContainer { ForumTitles = titles, PagerContext = pagerContext, Topics = topics }; _lastReadService.GetTopicReadStatus(user, container); ViewBag.PostUserName = postUser.Name; return(View(container)); }
public async Task <ViewResult> Result(string query, SearchType searchType = SearchType.Rank, int pageNumber = 1) { ViewBag.SearchTypes = new SelectList(Enum.GetValues(typeof(SearchType))); ViewBag.Query = query; ViewBag.SearchType = searchType; var includeDeleted = false; var user = _userRetrievalShim.GetUser(); if (user != null && user.IsInRole(PermanentRoles.Moderator)) { includeDeleted = true; } var titles = _forumService.GetAllForumTitles(); var(topics, pagerContext) = await _searchService.GetTopics(query, searchType, user, includeDeleted, pageNumber); var container = new PagedTopicContainer { ForumTitles = titles, PagerContext = pagerContext, Topics = topics.Data }; ViewBag.IsError = !topics.IsValid; if (topics.IsValid) { await _lastReadService.GetTopicReadStatus(user, container); } return(View("Index", container)); }
public ActionResult Index(string urlName, int page = 1) { if (String.IsNullOrWhiteSpace(urlName)) { return(NotFound()); } var forum = _forumService.Get(urlName); if (forum == null) { return(NotFound()); } var user = _userRetrievalShim.GetUser(HttpContext); var permissionContext = _forumService.GetPermissionContext(forum, user); if (!permissionContext.UserCanView) { return(Forbid()); } PagerContext pagerContext; var topics = _topicService.GetTopics(forum, permissionContext.UserCanModerate, page, out pagerContext); var container = new ForumTopicContainer { Forum = forum, Topics = topics, PagerContext = pagerContext, PermissionContext = permissionContext }; _lastReadService.GetTopicReadStatus(user, container); var adapter = new ForumAdapterFactory(forum); if (adapter.IsAdapterEnabled) { adapter.ForumAdapter.AdaptForum(this, container); if (String.IsNullOrWhiteSpace(adapter.ForumAdapter.ViewName)) { return(View(adapter.ForumAdapter.Model)); } return(View(adapter.ForumAdapter.ViewName, adapter.ForumAdapter.Model)); } if (forum.IsQAForum) { return(View("IndexQA", container)); } return(View(container)); }
public async Task <ActionResult> Index(string urlName, int pageNumber = 1) { if (string.IsNullOrWhiteSpace(urlName)) { return(NotFound()); } var forum = await _forumService.Get(urlName); if (forum == null) { return(NotFound()); } var user = _userRetrievalShim.GetUser(); var permissionContext = await _forumPermissionService.GetPermissionContext(forum, user); if (!permissionContext.UserCanView) { return(StatusCode(403)); } var(topics, pagerContext) = await _topicService.GetTopics(forum, permissionContext.UserCanModerate, pageNumber); var container = new ForumTopicContainer { Forum = forum, Topics = topics, PagerContext = pagerContext, PermissionContext = permissionContext }; await _lastReadService.GetTopicReadStatus(user, container); var adapter = new ForumAdapterFactory(forum); if (adapter.IsAdapterEnabled) { adapter.ForumAdapter.AdaptForum(this, container); if (string.IsNullOrWhiteSpace(adapter.ForumAdapter.ViewName)) { return(View(adapter.ForumAdapter.Model)); } return(View(adapter.ForumAdapter.ViewName, adapter.ForumAdapter.Model)); } if (forum.IsQAForum) { return(View("IndexQA", container)); } return(View(container)); }
public async Task <ViewResult> Topics(int pageNumber = 1) { var user = _userRetrievalShim.GetUser(); if (user == null) { return(View()); } var(topics, pagerContext) = await _subService.GetTopics(user, pageNumber); var titles = _forumService.GetAllForumTitles(); var container = new PagedTopicContainer { PagerContext = pagerContext, Topics = topics, ForumTitles = titles }; await _lastReadService.GetTopicReadStatus(user, container); return(View(container)); }
public ViewResult Topics(int page = 1) { var user = _userRetrievalShim.GetUser(HttpContext); if (user == null) { return(View()); } PagerContext pagerContext; var topics = _favoriteTopicService.GetTopics(user, page, out pagerContext); var titles = _forumService.GetAllForumTitles(); var container = new PagedTopicContainer { PagerContext = pagerContext, Topics = topics, ForumTitles = titles }; _lastReadService.GetTopicReadStatus(user, container); return(View(container)); }
public ViewResult Topics(int page = 1) { var user = this.CurrentUser(); if (user == null) { return(View()); } PagerContext pagerContext; var topics = _subService.GetTopics(user, page, out pagerContext); var titles = _forumService.GetAllForumTitles(); var container = new PagedTopicContainer { PagerContext = pagerContext, Topics = topics, ForumTitles = titles }; _lastReadService.GetTopicReadStatus(user, container); return(View(container)); }
public ViewResult Result(string query, SearchType searchType = SearchType.Rank, int page = 1) { ViewBag.SearchTypes = new SelectList(Enum.GetValues(typeof(SearchType))); ViewBag.Query = query; ViewBag.SearchType = searchType; var includeDeleted = false; var user = _userRetrievalShim.GetUser(HttpContext); if (user != null && user.IsInRole(PermanentRoles.Moderator)) { includeDeleted = true; } var titles = _forumService.GetAllForumTitles(); PagerContext pagerContext; var topics = _searchService.GetTopics(query, searchType, user, includeDeleted, page, out pagerContext); var container = new PagedTopicContainer { ForumTitles = titles, PagerContext = pagerContext, Topics = topics }; _lastReadService.GetTopicReadStatus(user, container); return(View("Index", container)); }