How can i get next unread thread id ?

Suppose we have thread id.I want to get next unread thread id.

How can i get it ?

  • Do you want a solution with Velocity or C#?

  • In reply to Luke D:

    Ya I want solution with c#.

    Thank you

  • In reply to mohmadraza:

    Here is what I would suggest - I am not 100% sure when the post gets flagged as "read", however the solution should be as simple as just retrieving the list of unread threads, sorting by date and grabbing the next one off the top of the list that is NOT the post the user is viewing.

    Something like this should work in C# (and easily translated to Velocity since i'm using the PublicApi) - You would need to create a velocity extension to actually call this from a widget.  It also does not cover error checking and also does not check if the user is logged-in, in which case we could not display them "unread" threads.  I also have not tested this code.

    // You will need to include these at the top of the class
    using Telligent.Evolution.Extensibility.Api.Entities.Version1;
    using Telligent.Evolution.Extensibility.Api.Version1;

    public ForumThread GetNextUnread(int groupId, int currentThreadId) { var threads = PublicApi.ForumThreads.List(new ForumThreadsListOptions { ForumThreadQueryType = "Unread", SortOrder = "Descending", SortBy = "date", IncludeSubGroups = true, GroupId = groupId }); var nextThread = (from t in threads where !t.Id.Equals(currentThreadId) select t).FirstOrDefault(); if (nextThread != null) { return nextThread; } return null; }

  • In reply to Luke D:

    Thanks for Answer but I am using Visual Studio 2005 and framework 2.0.So I cant use Linq Query in My Project. So Please give me solution as per my project Tool.  

  • In reply to mohmadraza:

    What version of the platform are you running?  Instead of using LINQ, just run through the threads with a foreach loop, check if the Ids are equal and flag the thread you want to return.  The meat of the solution is above the LINQ query - the rest should be a piece of cake.