public virtual async Task <ForumBreadcrumbModel> PrepareForumBreadcrumb(string forumGroupId, string forumId, string forumTopicId) { var model = new ForumBreadcrumbModel(); ForumTopic forumTopic = null; if (!String.IsNullOrEmpty(forumTopicId)) { forumTopic = await _forumService.GetTopicById(forumTopicId); if (forumTopic != null) { model.ForumTopicId = forumTopic.Id; model.ForumTopicSubject = forumTopic.Subject; model.ForumTopicSeName = forumTopic.GetSeName(); } } Forum forum = await _forumService.GetForumById(forumTopic != null?forumTopic.ForumId : (!String.IsNullOrEmpty(forumId) ? forumId : "")); if (forum != null) { model.ForumId = forum.Id; model.ForumName = forum.Name; model.ForumSeName = forum.GetSeName(); } var forumGroup = await _forumService.GetForumGroupById(forum != null?forum.ForumGroupId : (!String.IsNullOrEmpty(forumGroupId) ? forumGroupId : "")); if (forumGroup != null) { model.ForumGroupId = forumGroup.Id; model.ForumGroupName = forumGroup.Name; model.ForumGroupSeName = forumGroup.GetSeName(); } return(model); }
/// <summary> /// Prepare the forum breadcrumb model /// </summary> /// <param name="forumGroupId">Forum group identifier; pass null to load nothing</param> /// <param name="forumId">Forum identifier; pass null to load breadcrumbs up to forum group</param> /// <param name="forumTopicId">Forum topic identifier; pass null to load breadcrumbs up to forum</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the forum breadcrumb model /// </returns> public virtual async Task <ForumBreadcrumbModel> PrepareForumBreadcrumbModelAsync(int?forumGroupId, int?forumId, int?forumTopicId) { var model = new ForumBreadcrumbModel(); ForumTopic forumTopic = null; if (forumTopicId.HasValue) { forumTopic = await _forumService.GetTopicByIdAsync(forumTopicId.Value); if (forumTopic != null) { model.ForumTopicId = forumTopic.Id; model.ForumTopicSubject = forumTopic.Subject; model.ForumTopicSeName = await _forumService.GetTopicSeNameAsync(forumTopic); } } var forum = await _forumService.GetForumByIdAsync(forumTopic != null?forumTopic.ForumId : (forumId ?? 0)); if (forum != null) { model.ForumId = forum.Id; model.ForumName = forum.Name; model.ForumSeName = await _forumService.GetForumSeNameAsync(forum); } var forumGroup = await _forumService.GetForumGroupByIdAsync(forum != null?forum.ForumGroupId : (forumGroupId ?? 0)); if (forumGroup != null) { model.ForumGroupId = forumGroup.Id; model.ForumGroupName = forumGroup.Name; model.ForumGroupSeName = await _forumService.GetForumGroupSeNameAsync(forumGroup); } return(model); }
/// <summary> /// Prepare the forum breadcrumb model /// </summary> /// <param name="forumGroupId">Forum group identifier; pass null to load nothing</param> /// <param name="forumId">Forum identifier; pass null to load breadcrumbs up to forum group</param> /// <param name="forumTopicId">Forum topic identifier; pass null to load breadcrumbs up to forum</param> /// <returns>Forum breadcrumb model</returns> public virtual ForumBreadcrumbModel PrepareForumBreadcrumbModel(int?forumGroupId, int?forumId, int?forumTopicId) { var model = new ForumBreadcrumbModel(); ForumTopic forumTopic = null; if (forumTopicId.HasValue) { forumTopic = _forumService.GetTopicById(forumTopicId.Value); if (forumTopic != null) { model.ForumTopicId = forumTopic.Id; model.ForumTopicSubject = forumTopic.Subject; model.ForumTopicSeName = forumTopic.GetSeName(); } } var forum = _forumService.GetForumById(forumTopic != null ? forumTopic.ForumId : (forumId.HasValue ? forumId.Value : 0)); if (forum != null) { model.ForumId = forum.Id; model.ForumName = forum.Name; model.ForumSeName = forum.GetSeName(); } var forumGroup = _forumService.GetForumGroupById(forum != null ? forum.ForumGroupId : (forumGroupId.HasValue ? forumGroupId.Value : 0)); if (forumGroup != null) { model.ForumGroupId = forumGroup.Id; model.ForumGroupName = forumGroup.Name; model.ForumGroupSeName = forumGroup.GetSeName(); } return(model); }