public void AddComment(string commentId, string commentText) { if (!HttpContext.Current.User.Identity.IsAuthenticated) return; CommentId cid = new CommentId(commentId); if (!cid.HasParsed()) return; int? result = null; CodeReviewDataContext dataContext = new CodeReviewDataContext( System.Configuration.ConfigurationManager.ConnectionStrings[Config.ConnectionString].ConnectionString); dataContext.AddComment(cid.FileVersionId, cid.Line, cid.LineStamp, commentText, ref result); dataContext.Connection.Close(); dataContext.Dispose(); }
public void DeleteComment(string commentId) { if (!HttpContext.Current.User.Identity.IsAuthenticated) return; CommentId cid = new CommentId(commentId); CodeReviewDataContext dataContext = new CodeReviewDataContext( System.Configuration.ConfigurationManager.ConnectionStrings[Config.ConnectionString].ConnectionString); var commentQuery = from cm in dataContext.Comments where cm.FileVersionId == cid.FileVersionId && cm.Line == cid.Line && cm.LineStamp == cid.LineStamp select cm.Id; if (commentQuery.Count() == 1) { int id = commentQuery.Single(); dataContext.DeleteComment(id); } dataContext.Connection.Close(); dataContext.Dispose(); }
public int GetNumberOfReviewsWhereIAmTheReviewee() { string alias = GetUserAlias(); if (alias == null) return 0; CodeReviewDataContext dataContext = new CodeReviewDataContext( System.Configuration.ConfigurationManager.ConnectionStrings[Config.ConnectionString].ConnectionString); int result = (from cc in dataContext.ChangeLists where cc.UserName == alias && cc.Stage == 0 select cc).Distinct().Count(); dataContext.Connection.Close(); dataContext.Dispose(); return result; }
public void RecordHintShowing(int hintNumber) { string alias = GetUserAlias(); if (alias == null) return; CodeReviewDataContext context = new CodeReviewDataContext( System.Configuration.ConfigurationManager.ConnectionStrings[Config.ConnectionString].ConnectionString); UserContext uc = UserContext.GetUserContext(alias, Context.Cache, context); long mask = 1 << (hintNumber - 1); uc.HintsMask = (uc.HintsMask == null ? 0 : uc.HintsMask.Value) | mask; context.SetUserContext(UserContext.HINT_MASK, uc.HintsMask.Value.ToString()); context.Connection.Close(); context.Dispose(); }
public int GetNumberOfOpenReviews() { if (!HttpContext.Current.User.Identity.IsAuthenticated) return 0; CodeReviewDataContext dataContext = new CodeReviewDataContext( System.Configuration.ConfigurationManager.ConnectionStrings[Config.ConnectionString].ConnectionString); int result = (from cc in dataContext.ChangeLists where cc.Stage == 0 select cc).Distinct().Count(); dataContext.Connection.Close(); dataContext.Dispose(); return result; }