private static void CreateComments(int count, Entry entry, FeedbackStatusFlag status) { for (int i = 0; i < count; i++) { CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment, status); } }
static FeedbackItem CreateAndUpdateFeedbackWithExactStatus(Entry entry, FeedbackType type, FeedbackStatusFlag status) { var feedback = new FeedbackItem(type); feedback.Title = UnitTestHelper.GenerateUniqueString(); feedback.Body = UnitTestHelper.GenerateUniqueString(); feedback.EntryId = entry.Id; feedback.Author = "TestAuthor"; var subtextContext = new Mock <ISubtextContext>(); subtextContext.Setup(c => c.Cache).Returns(new TestCache()); subtextContext.SetupBlog(Config.CurrentBlog); subtextContext.SetupRepository(ObjectProvider.Instance()); subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable()); subtextContext.Setup(c => c.HttpContext).Returns(new HttpContextWrapper(HttpContext.Current)); var service = new CommentService(subtextContext.Object, null); int id = service.Create(feedback, true /*runFilters*/); feedback = FeedbackItem.Get(id); feedback.Status = status; FeedbackItem.Update(feedback); return(FeedbackItem.Get(id)); }
/// <summary> /// Destroys all non-active emails that meet the status. /// </summary> /// <param name="feedbackStatus">The feedback.</param> public static void Destroy(this ObjectRepository repository, FeedbackStatusFlag feedbackStatus) { if ((feedbackStatus & FeedbackStatusFlag.Approved) == FeedbackStatusFlag.Approved) { throw new InvalidOperationException(Resources.InvalidOperation_DestroyActiveComment); } repository.DestroyFeedback(feedbackStatus); }
/// <summary> /// Destroys all non-active emails that meet the status. /// </summary> /// <param name="feedbackStatus">The feedback.</param> public static void Destroy(FeedbackStatusFlag feedbackStatus) { if ((feedbackStatus & FeedbackStatusFlag.Approved) == FeedbackStatusFlag.Approved) { throw new InvalidOperationException(Resources.InvalidOperation_DestroyActiveComment); } ObjectProvider.Instance().DestroyFeedback(feedbackStatus); }
internal static string GetFeedbackItemFilter(FeedbackStatusFlag currentView) { string cookieName = COOKIES_FEEDBACK_FILTER + currentView; if (null != HttpContext.Current.Request.Cookies[cookieName]) { return(HttpContext.Current.Request.Cookies[cookieName].Value); } return(FeedbackType.None.ToString()); }
/// <summary> /// Turns the specified status bit on or off depending on the setOn value. /// </summary> /// <param name="status"></param> /// <param name="setOn"></param> protected void SetStatus(FeedbackStatusFlag status, bool setOn) { if (setOn) { Status = Status | status; } else { Status = Status & ~status; } }
public void CanCreateCommentWithStatus(FeedbackStatusFlag status, bool expectedApproved, bool expectedNeedsModeratorApproval, bool expectedDeleted, bool expectedFlaggedAsSpam) { Entry entry = SetupBlogForCommentsAndCreateEntry(); FeedbackItem comment = CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment, status); Assert.IsTrue((comment.Status & status) == status, "Expected the " + status + "bit to be set."); Assert.AreEqual(expectedApproved, comment.Approved, "We expected 'Approved' to be " + expectedApproved); Assert.AreEqual(expectedNeedsModeratorApproval, comment.NeedsModeratorApproval, "Expected 'NeedsModeratorApproval' to be " + expectedNeedsModeratorApproval); Assert.AreEqual(expectedDeleted, comment.Deleted, "Expected 'Deleted' to be " + expectedDeleted); Assert.AreEqual(expectedFlaggedAsSpam, ((comment.Status & FeedbackStatusFlag.FlaggedAsSpam) == FeedbackStatusFlag.FlaggedAsSpam), "Expected that this item was ever flagged as spam to be " + expectedFlaggedAsSpam); }
internal static void SetFeedbackItemFilter(string value, FeedbackStatusFlag currentView) { string cookieName = COOKIES_FEEDBACK_FILTER + currentView; if (Enum.IsDefined(typeof(FeedbackType), value)) { CreateCookie(cookieName, value, CookieExpiry); } else { log.Warn("Could not set FeedbackType value: " + value); } }
protected override void OnLoad(EventArgs e) { _feedbackStatusFilter = Master.FeedbackStatus; _uiState = FeedbackState.GetUiState(_feedbackStatusFilter); filterTypeDropDown.SelectedValue = Master.FeedbackType.ToString(); BindUserInterface(); if(!IsPostBack) { if(!Contact.SendContactMessageToFeedback) { filterTypeDropDown.Items.RemoveAt(3); } BindList(); } base.OnLoad(e); }
private void BindList() { noCommentsMessage.Visible = false; if (Request.QueryString[Keys.QRYSTR_PAGEINDEX] != null) { _pageIndex = Convert.ToInt32(Request.QueryString[Keys.QRYSTR_PAGEINDEX]); } resultsPager.UrlFormat = "Default.aspx?pg={0}&status=" + _feedbackStatusFilter; resultsPager.PageSize = Preferences.ListingItemCount; resultsPager.PageIndex = _pageIndex; // Deleted is a special case. If a feedback has the deleted // bit set, it is in the trash no matter what other bits are set. FeedbackStatusFlag excludeFilter = _feedbackStatusFilter == FeedbackStatusFlag.Deleted ? FeedbackStatusFlag.None : FeedbackStatusFlag.Deleted; IPagedCollection <FeedbackItem> selectionList = Repository.GetPagedFeedback(_pageIndex , resultsPager.PageSize , _feedbackStatusFilter , excludeFilter , Master.FeedbackType); if (selectionList.Count > 0) { resultsPager.Visible = true; resultsPager.ItemCount = selectionList.MaxItems; feedbackRepeater.DataSource = selectionList; feedbackRepeater.ItemCreated += FeedbackItemDataBound; feedbackRepeater.DataBind(); } else { resultsPager.Visible = false; noCommentsMessage.Text = _uiState.NoCommentsHtml; feedbackRepeater.Controls.Clear(); noCommentsMessage.Visible = true; btnEmpty.Visible = false; } Master.BindCounts(); }
public static FeedbackState GetUiState(FeedbackStatusFlag status) { //We've reduced multiple switch statements to one, //that's good enough in my book. switch (status) { case FeedbackStatusFlag.Approved: return new ApprovedFeedbackState(); case FeedbackStatusFlag.NeedsModeration: return new NeedsModerationState(); case FeedbackStatusFlag.FlaggedAsSpam: return new FlaggedAsSpamState(); case FeedbackStatusFlag.Deleted: return new DeletedState(); default: throw new InvalidOperationException("Invalid Feedback Status supplied '" + status + "'"); } }
protected IList GetFeedEntriesSimple() { if (String.IsNullOrEmpty(_rssType)) { throw new InvalidOperationException("rssType is empty or null"); } ObjectProvider repository = ObjectProvider.Instance(); switch (_rssType) { case "Comment": FeedbackStatusFlag flags = FeedbackStatusFlag.None; foreach (string filter in _filters) { if (Enum.IsDefined(typeof(FeedbackStatusFlag), filter)) { flags |= (FeedbackStatusFlag)Enum.Parse(typeof(FeedbackStatusFlag), filter, true); } } ICollection <FeedbackItem> moderatedFeedback = repository.GetPagedFeedback(0, _count, flags, FeedbackStatusFlag.None, FeedbackType.None); return((IList)moderatedFeedback); case "Referral": //TODO: Fix! ICollection <Referrer> referrers = repository.GetPagedReferrers(0, _count, NullValue.NullInt32); return((IList)referrers); case "Log": ICollection <LogEntry> entries = LoggingProvider.Instance().GetPagedLogEntries(0, _count); return((IList)entries); } return(null); }
public static FeedbackState GetUiState(FeedbackStatusFlag status) { //We've reduced multiple switch statements to one, //that's good enough in my book. switch (status) { case FeedbackStatusFlag.Approved: return(new ApprovedFeedbackState()); case FeedbackStatusFlag.NeedsModeration: return(new NeedsModerationState()); case FeedbackStatusFlag.FlaggedAsSpam: return(new FlaggedAsSpamState()); case FeedbackStatusFlag.Deleted: return(new DeletedState()); default: throw new InvalidOperationException(String.Format(Resources.InvalidOperation_InvalidFeedbackStatus, status)); } }
public ActionResult UpdateStatus(int id, FeedbackStatusFlag status) { var comment = CommentService.Get(id); string subject = string.Format("Comment by {0}", comment.Author); string predicate = null; switch(status) { case FeedbackStatusFlag.Approved: predicate = "has been approved"; break; case FeedbackStatusFlag.Deleted: predicate = "has been removed"; break; case FeedbackStatusFlag.FlaggedAsSpam: predicate = "has been flagged as spam"; break; } CommentService.UpdateStatus(comment, status); return Json(new {subject, predicate}); }
public ActionResult UpdateStatus(int id, FeedbackStatusFlag status) { var comment = CommentService.Get(id); string subject = string.Format("Comment by {0}", comment.Author); string predicate = null; switch (status) { case FeedbackStatusFlag.Approved: predicate = "has been approved"; break; case FeedbackStatusFlag.Deleted: predicate = "has been removed"; break; case FeedbackStatusFlag.FlaggedAsSpam: predicate = "has been flagged as spam"; break; } CommentService.UpdateStatus(comment, status); return(Json(new { subject, predicate })); }
public override void DestroyFeedback(FeedbackStatusFlag status) { _procedures.DeleteFeedbackByStatus(BlogId, (int)status); }
/// <summary> /// Checks to see if the specified status bit is set. /// </summary> /// <param name="status">The status.</param> /// <returns></returns> protected bool IsStatusSet(FeedbackStatusFlag status) { return (Status & status) == status; }
public void UpdateStatus(FeedbackItem comment, FeedbackStatusFlag status) { comment.Status = status; Repository.Update(comment); }
/// <summary> /// Destroys the feedback with the given status. /// </summary> /// <param name="status">The status.</param> public abstract void DestroyFeedback(FeedbackStatusFlag status);
public string ListUrl(int page, FeedbackStatusFlag status, FeedbackType type) { return "Default.aspx?" + GetCurrentQuery(page, status, type); }
public string GetCurrentQuery(int page, FeedbackStatusFlag status, FeedbackType type) { string query = "page={0}&status={1}&type={2}"; return String.Format(query, page, status, type); }
/// <summary> /// Returns a data reader (<see cref="IDataReader" />) pointing to all the comments /// ordered by ID Descending for the specified page index (0-based) and page size. /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="status">Status flag for the feedback to return.</param> /// <param name="type">Feedback Type (comment, comment api, etc..) for the feedback to return.</param> /// <returns></returns> public abstract IDataReader GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type);
public override void DestroyFeedback(FeedbackStatusFlag status) { DbProvider.Instance().DestroyFeedback(status); }
/// <summary> /// Gets the paged feedback. /// </summary> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public override IPagedCollection<FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type) { IDataReader reader = DbProvider.Instance().GetPagedFeedback(pageIndex, pageSize, status, excludeStatusMask, type); IPagedCollection<FeedbackItem> pec = new PagedCollection<FeedbackItem>(); while(reader.Read()) { pec.Add(DataHelper.LoadFeedbackItem(reader)); } reader.NextResult(); pec.MaxItems = DataHelper.GetMaxItems(reader); return pec; }
/// <summary> /// Checks to see if the specified status bit is set. /// </summary> /// <param name="status">The status.</param> /// <returns></returns> protected bool IsStatusSet(FeedbackStatusFlag status) { return((Status & status) == status); }
/// <summary> /// Gets the paged feedback. /// </summary> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public abstract IPagedCollection <FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type);
/// <summary> /// Destroys all non-active emails that meet the status. /// </summary> /// <param name="feedbackStatus">The feedback.</param> public static void Destroy(FeedbackStatusFlag feedbackStatus) { if ((feedbackStatus & FeedbackStatusFlag.Approved) == FeedbackStatusFlag.Approved) throw new InvalidOperationException("Cannot destroy an active comment."); ObjectProvider.Instance().DestroyFeedback(feedbackStatus); }
/// <summary> /// Gets the paged feedback. /// </summary> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public override IPagedCollection <FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type) { int?feedbackType = (type == FeedbackType.None ? null : (int?)type); int?excludeStatus = (excludeStatusMask == FeedbackStatusFlag.None ? null : (int?)excludeStatusMask); using (IDataReader reader = _procedures.GetPageableFeedback(BlogId, pageIndex, pageSize, (int)status, excludeStatus, feedbackType)) { return(reader.ReadPagedCollection(r => reader.ReadFeedbackItem())); } }
public string ListUrl(FeedbackStatusFlag status) { return ListUrl(PageIndex, status, FeedbackType); }
/// <summary> /// Gets the paged feedback. /// </summary> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public override IPagedCollection<FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type) { int? feedbackType = (type == FeedbackType.None ? null : (int?)type); int? excludeStatus = (excludeStatusMask == FeedbackStatusFlag.None ? null : (int?)excludeStatusMask); using (IDataReader reader = _procedures.GetPageableFeedback(BlogId, pageIndex, pageSize, (int)status, excludeStatus, feedbackType)) { return reader.ReadPagedCollection(r => reader.ReadFeedbackItem()); } }
//For master page only... protected string GetListUrl(FeedbackStatusFlag status) { return "Default.aspx?status=" + status; }
internal static string GetFeedbackItemFilter(FeedbackStatusFlag currentView) { string cookieName = COOKIES_FEEDBACK_FILTER + currentView.ToString(); if (null != HttpContext.Current.Request.Cookies[cookieName]) { return HttpContext.Current.Request.Cookies[cookieName].Value; } return FeedbackType.None.ToString(); }
/// <summary> /// Gets the paged feedback. /// </summary> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public abstract IPagedCollection<FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type);
public string ListUrl(int page, FeedbackStatusFlag status, FeedbackType type) { return("Default.aspx?" + GetCurrentQuery(page, status, type)); }
static FeedbackItem CreateAndUpdateFeedbackWithExactStatus(Entry entry, FeedbackType type, FeedbackStatusFlag status) { var repository = new DatabaseObjectProvider(); var feedback = new FeedbackItem(type); feedback.Title = UnitTestHelper.GenerateUniqueString(); feedback.Body = UnitTestHelper.GenerateUniqueString(); feedback.EntryId = entry.Id; feedback.Author = "TestAuthor"; var subtextContext = new Mock<ISubtextContext>(); subtextContext.Setup(c => c.Cache).Returns(new TestCache()); subtextContext.SetupBlog(Config.CurrentBlog); subtextContext.SetupRepository(repository); subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable()); subtextContext.Setup(c => c.HttpContext).Returns(new HttpContextWrapper(HttpContext.Current)); var service = new CommentService(subtextContext.Object, null); int id = service.Create(feedback, true/*runFilters*/); feedback = repository.Get(id); feedback.Status = status; repository.Update(feedback); return repository.Get(id); }
public string GetCurrentQuery(int page, FeedbackStatusFlag status, FeedbackType type) { const string query = "page={0}&status={1}&type={2}"; return(String.Format(query, page, status, type)); }
/// <summary> /// Turns the specified status bit on or off depending on the setOn value. /// </summary> /// <param name="status"></param> /// <param name="setOn"></param> protected internal void SetStatus(FeedbackStatusFlag status, bool setOn) { if (setOn) { Status = Status | status; } else { Status = Status & ~status; } }
public string ListUrl(FeedbackStatusFlag status, int pageIndex) { return(ListUrl(pageIndex, status, FeedbackType)); }
/// <summary> /// Returns a pageable collection of comments. /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="status">A flag for the status types to return.</param> /// <param name="excludeStatusMask">A flag for the statuses to exclude.</param> /// <param name="type">The type of feedback to return.</param> /// <returns></returns> public static IPagedCollection<FeedbackItem> GetPagedFeedback(int pageIndex, int pageSize, FeedbackStatusFlag status, FeedbackStatusFlag excludeStatusMask, FeedbackType type) { return ObjectProvider.Instance().GetPagedFeedback(pageIndex, pageSize, status, excludeStatusMask, type); }
/// <summary> /// Destroys all non-active emails that meet the status. /// </summary> /// <param name="feedbackStatus">The feedback.</param> public static void Destroy(FeedbackStatusFlag feedbackStatus) { if((feedbackStatus & FeedbackStatusFlag.Approved) == FeedbackStatusFlag.Approved) { throw new InvalidOperationException(Resources.InvalidOperation_DestroyActiveComment); } ObjectProvider.Instance().DestroyFeedback(feedbackStatus); }
/// <summary> /// Turns the specified status bit on or off depending on the setOn value. /// </summary> /// <param name="status"></param> /// <param name="setOn"></param> protected void SetStatus(FeedbackStatusFlag status, bool setOn) { if (setOn) { this.Status = Status | status; } else { this.Status = Status & ~status; } }
//For master page only... protected string GetListUrl(FeedbackStatusFlag status) { return("Default.aspx?status=" + status); }
internal static void SetFeedbackItemFilter(string value, FeedbackStatusFlag currentView) { string cookieName = COOKIES_FEEDBACK_FILTER + currentView.ToString(); if (Enum.IsDefined(typeof(FeedbackType), value)) { CreateCookie(cookieName, value, CookieExpiry); } else { log.Warn("Could not set FeedbackType value: " + value); } }
static FeedbackItem CreateAndUpdateFeedbackWithExactStatus(Entry entry, FeedbackType type, FeedbackStatusFlag status) { FeedbackItem feedback = new FeedbackItem(type); feedback.Title = UnitTestHelper.GenerateRandomString(); feedback.Body = UnitTestHelper.GenerateRandomString(); feedback.EntryId = entry.Id; int id = FeedbackItem.Create(feedback, null); feedback = FeedbackItem.Get(id); feedback.Status = status; FeedbackItem.Update(feedback); return FeedbackItem.Get(id); }