GetUnreadTopics() public method

public GetUnreadTopics ( int portalId, int moduleId, int userId, string forumIds, int rowIndex, int maxRows ) : IEnumerable
portalId int
moduleId int
userId int
forumIds string
rowIndex int
maxRows int
return IEnumerable
        private XmlRpcStruct GetUnreadTopics(int startIndex, int endIndex, string searchId, object filters)
        {
            var aftContext = ActiveForumsTapatalkModuleContext.Create(Context);

            if (aftContext == null || aftContext.Module == null)
                throw new XmlRpcFaultException(100, "Invalid Context");

            Context.Response.AddHeader("Mobiquo_is_login", aftContext.UserId > 0 ? "true" : "false");

            var portalId = aftContext.Module.PortalID;
            var forumModuleId = aftContext.ModuleSettings.ForumModuleId;
            var userId = aftContext.UserId;

            // If user is not signed in, don't return any unread topics
            if (userId <= 0)
                return new XmlRpcStruct
                       {
                           {"total_topic_num", 0},
                           {"topics", new object[]{}}
                       };


            // Build a list of forums the user has access to
            var fc = new AFTForumController();
            var forumIds = fc.GetForumsForUser(aftContext.ForumUser.UserRoles, portalId, forumModuleId, "CanRead");

            var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) };

            var maxRows = endIndex + 1 - startIndex;

            var unreadTopics = fc.GetUnreadTopics(portalId, forumModuleId, userId, forumIds, startIndex, maxRows).ToList();

            return new XmlRpcStruct
                       {
                           {"total_topic_num", unreadTopics.Count > 0 ? unreadTopics[0].TopicCount : 0},
                           {"topics", unreadTopics.Select(t => new ExtendedTopicStructure{ 
                                                   TopicId = t.TopicId.ToString(),
                                                   AuthorAvatarUrl = GetAvatarUrl(t.LastReplyAuthorId),
                                                   AuthorId = t.LastReplyAuthorId.ToString(),
                                                   AuthorName = GetLastReplyAuthorName(mainSettings, t).ToBytes(),
                                                   ForumId = t.ForumId.ToString(),
                                                   ForumName = t.ForumName.ToBytes(),
                                                   HasNewPosts =  (t.LastReplyId < 0 && t.TopicId > t.UserLastTopicRead) || t.LastReplyId > t.UserLastReplyRead,
                                                   IsLocked = t.IsLocked,
                                                   IsSubscribed = t.SubscriptionType > 0,
                                                   CanSubscribe = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fc.GetForumPermissions(t.ForumId).CanSubscribe), // GetforumPermissions uses cache so it shouldn't be a performance issue
                                                   ReplyCount = t.ReplyCount,
                                                   Summary = GetSummary(null, t.LastReplyBody).ToBytes(),
                                                   ViewCount = t.ViewCount,
                                                   DateCreated = t.LastReplyDate,
                                                   Title = HttpUtility.HtmlDecode(t.Subject + string.Empty).ToBytes()
                                               }).ToArray()}
                       };
        }