public static void SetMessageMarked( IServiceProvider provider, MsgBase msg, bool isMarked) { using (var db = provider.CreateDBContext()) using (var tx = db.BeginTransaction()) { db .Messages(m => m.ID == msg.ID) .Set(_ => _.IsMarked, isMarked) .Update(); UpdateTopicInfo(db, msg.TopicID); tx.Commit(); } }
private static List <MsgBase> GetOldStyleTopicList( IServiceProvider provider, int forumId, SortType sort, bool loadAll, MsgBase parent) { using (var db = provider.CreateDBContext()) { var displayConfig = Config.Instance.ForumDisplayConfig; var q = AppendSortPredicate(db.TopicInfos(ti => ti.ForumID == forumId), sort); if (displayConfig.ShowUnreadThreadsOnly) { q = q.Where(ti => !ti.Message.IsRead || ti.AnswersUnread > 0); } if (!(loadAll || displayConfig.MaxTopicsPerForum <= 0)) { q = q.Take(displayConfig.MaxTopicsPerForum); } var msgs = q .Select( ti => new Msg(provider) { Parent = parent, IsChild = false, ID = ti.MessageID, ParentID = 0, ForumID = ti.ForumID, Name = ti.Message.Name, Date = ti.Message.Date, Subject = ti.Message.Subject, UserID = ti.Message.UserID, UserClass = (short)ti.Message.UserClass, UserNick = ti.Message.UserNick, IsRead = ti.Message.IsRead, IsMarked = ti.Message.IsMarked, Closed = ti.Message.Closed, ReadReplies = ti.Message.ReadReplies, LastModerated = ti.Message.LastModerated, ArticleId = ti.Message.ArticleId, Rating = ti.SelfRates, Smiles = ti.SelfSmiles, Agrees = ti.SelfAgrees, Disagrees = ti.SelfDisagrees, Moderatorials = ti.SelfModeratorials, RepliesCount = ti.AnswersCount, RepliesUnread = ti.AnswersUnread, RepliesRate = ti.AnswersRates, RepliesSmiles = ti.AnswersSmiles, RepliesAgree = ti.AnswersAgrees, RepliesDisagree = ti.AnswersDisagrees, RepliesToMeUnread = ti.AnswersToMeUnread, RepliesMarked = ti.AnswersMarked, RepliesModeratorials = ti.AnswersModeratorials }) .Cast <MsgBase>() .ToList(); foreach (var msg in msgs) { msg.EndMapping(); } return(msgs); } }