public static void Enable(Usr CurrentUsr, int ParentObjectK, Model.Entities.ObjectType ParentObjectType) { if (ParentObjectType.Equals(Model.Entities.ObjectType.Thread)) { Thread t = new Thread(ParentObjectK); bool changed = false; if (t.CheckPermissionRead(CurrentUsr)) { ThreadUsr tu = t.GetThreadUsr(CurrentUsr); if (!tu.IsWatching) { tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, true); changed = true; } if (changed) { UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(); job.ExecuteAsynchronously(); } } return; } try { CommentAlert c = new CommentAlert(CurrentUsr.K, ParentObjectType, ParentObjectK); } catch { CommentAlert c = new CommentAlert(); c.UsrK = CurrentUsr.K; c.ParentObjectK = ParentObjectK; c.ParentObjectType = ParentObjectType; c.Update(); } }
public void WatchTopic(bool state, string functionArgs) { string[] ids = GetIds(functionArgs); bool response = false; foreach (string id in ids) { Thread t = new Thread(int.Parse(id)); bool changed = false; if (t.CheckPermissionRead(Usr.Current)) { ThreadUsr tu = t.GetThreadUsr(Usr.Current); if (state) { if (!tu.IsWatching) { tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, true); changed = true; } } else { tu.ChangeStatus(ThreadUsr.StatusEnum.Ignore, true); changed = true; } if (changed) { UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(t); job.ExecuteAsynchronously(); } response = tu.IsWatching; } else { throw new DsiUserFriendlyException("You don't have permission to watch this thread!"); } } SendResponse(response); return; }