/// <summary> /// Deprecated Method for adding a new object to the BlogFeedbackAuthors EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBlogFeedbackAuthors(BlogFeedbackAuthor blogFeedbackAuthor) { base.AddObject("BlogFeedbackAuthors", blogFeedbackAuthor); }
public void SaveAndProcessFeedback() { //Save Feedback to database #region SaveFeedback //Update blog entry's feedback count if we the blog doesn't require feedback approval if (!this.blogConfig.FeedbackRequiresApproval) this.BlogEntryScreen.BlogEntry.FeedbackCount++; //See if this feedback author already exists var feedbackAuthor = repo.GetBlogFeedbackAuthorByNameEmailWebsite(this.blogConfig.BlogConfigId, this.Name, this.Email, this.WebSite); //If feedback author doesn't already exist, create it if (feedbackAuthor == null) { feedbackAuthor = new BlogFeedbackAuthor(); feedbackAuthor.Url = this.WebSite; feedbackAuthor.Name = this.Name; feedbackAuthor.LastUpdateDate = DateTime.Now; feedbackAuthor.Email = this.Email; feedbackAuthor.CreateDate = DateTime.Now; feedbackAuthor.FeedbackTotal = 1; feedbackAuthor.BlogConfigId = this.blogConfig.BlogConfigId; repo.Add(feedbackAuthor); } //Otherwise, update the existing author else { feedbackAuthor.FeedbackTotal++; feedbackAuthor.LastUpdateDate = DateTime.Now; } //Save our feedback author repo.Save(); //Create our blog feedback BlogFeedback blogFeedback = new BlogFeedback() { BlogFeedbackAuthorId = feedbackAuthor.BlogFeedbackAuthorId, BlogConfigId = this.blogConfig.BlogConfigId, BlogEntryId = this.BlogEntryScreen.BlogEntry.BlogEntryId, Body = this.FeedbackText, CreateDate = DateTime.Now, IpAddress = HttpContext.Current.Request.UserHostAddress, //blogFeedback.IsBlogAuthor = isUserLoggedIn; LastUpdateDate = DateTime.Now, NotifyAuthorOnFeedback = this.NotifyMeOnFeedback, Title = "re: " + this.BlogEntryScreen.BlogEntry.Title, UserAgent = HttpContext.Current.Request.UserAgent }; //Check if we should require approval for this feedback or not if (this.blogConfig.FeedbackRequiresApproval) { blogFeedback.Status = (int)FeedbackStatus.PendingApproval; } else { blogFeedback.Status = (int)FeedbackStatus.Approved; } repo.Add(blogFeedback); //Save our blog feedback repo.Save(); #endregion //Notify authors / admins of feedback #region Notify Authors / Admins of Feedback List<string> recipients = new List<string>(); if (this.BlogEntryScreen.BlogEntry.BlogUser.NotifyForFeedback) recipients.Add(this.BlogEntryScreen.BlogEntry.BlogUser.EmailAddress); if (this.blogConfig.NotifyAdminsForFeedback) { var admins = repo.GetBlogUsersInRoles(this.blogConfig.BlogConfigId, "Admin").Where(p => p.NotifyForFeedback).ToArray(); foreach (var admin in admins) if (!recipients.Contains(admin.EmailAddress)) recipients.Add(admin.EmailAddress); } if (recipients.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("The following comment was received from entry: "); sb.Append("http://"); sb.Append(this.blogConfig.Host); sb.Append("/"); sb.Append(this.BlogEntryScreen.BlogEntry.EntryName); sb.Append("<br />"); sb.Append(this.BlogEntryScreen.BlogEntry.Title); sb.Append("<br /><br />Status: "); sb.Append(((FeedbackStatus)blogFeedback.Status).ToString()); sb.Append("<br />Author: "); sb.Append(blogFeedback.BlogFeedbackAuthor.Name); sb.Append("<br />Author Email: "); sb.Append(blogFeedback.BlogFeedbackAuthor.Email); sb.Append("<br />Author Website: "); sb.Append(blogFeedback.BlogFeedbackAuthor.Url); sb.Append("<br /><br /><strong>Comment:</strong><br />"); sb.Append(blogFeedback.Body); EmailHandler.SendEmail(_feedbackSenderAddress, sb.ToString(), string.Join(";", recipients), "New Comment: " + this.BlogEntryScreen.BlogEntry.Title, true); LoggingHandler.Log("Email Sent for Feedback to admin", "Email sent to " + string.Join(";", recipients), "Info", "ArchiveScreen"); } #endregion //store creds into a cookie #region store creds in cookies HttpContext.Current.Response.Cookies["userName"].Value = this.Name; HttpContext.Current.Response.Cookies["userName"].Expires = DateTime.Now.AddMonths(3); HttpContext.Current.Response.Cookies["email"].Value = this.Email; HttpContext.Current.Response.Cookies["email"].Expires = DateTime.Now.AddMonths(3); HttpContext.Current.Response.Cookies["website"].Value = this.WebSite; HttpContext.Current.Response.Cookies["website"].Expires = DateTime.Now.AddMonths(3); HttpContext.Current.Response.Cookies["NotifyMeOnFeedback"].Value = this.NotifyMeOnFeedback.ToString(); HttpContext.Current.Response.Cookies["NotifyMeOnFeedback"].Expires = DateTime.Now.AddMonths(3); #endregion //Notify other commenters #region Notify Other Commentors if (this.blogConfig.EnableFeedbackAuthorNotifications) { recipients = new List<string>(); var feedbacks = this.BlogEntryScreen.BlogEntry.BlogFeedbacks.Where(p => p.NotifyAuthorOnFeedback).ToArray(); foreach (var notifyFeedback in feedbacks) { //Try and find a newer blog entry by this author where they don't want to be notified var negFeedback = feedbacks.Where(p => p.BlogFeedbackAuthor.Email == notifyFeedback.BlogFeedbackAuthor.Email) .Where(p => p.NotifyAuthorOnFeedback == false) .Where(p => p.CreateDate > notifyFeedback.CreateDate).SingleOrDefault(); if (negFeedback == null && !recipients.Contains(notifyFeedback.BlogFeedbackAuthor.Email) && notifyFeedback.BlogFeedbackAuthor.Email != Email) recipients.Add(notifyFeedback.BlogFeedbackAuthor.Email); } //Check the blacklist Blacklist[] blacklistedAddresses = repo.GetBlacklistsForEmailAddresses(this.blogConfig.BlogConfigId, recipients.ToArray()).ToArray(); if (blacklistedAddresses.Count() > 0) { foreach (var item in blacklistedAddresses) recipients.Remove(item.EmailAddress); } //Send email if (recipients.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("A comment was made on an entry you asked to be notified on.<br /> The entry is "); sb.Append("http://"); sb.Append(this.blogConfig.Host); sb.Append("/"); sb.Append(this.BlogEntryScreen.BlogEntry.EntryName); sb.Append("<br />Title: "); sb.Append(this.BlogEntryScreen.BlogEntry.Title); sb.Append("<br />Author: "); sb.Append(blogFeedback.BlogFeedbackAuthor.Name); sb.Append("<br /><br /><strong>Comment:</strong><br />"); sb.Append(blogFeedback.Body); sb.Append("<br /><br /><br /><br /><br />"); sb.Append("To opt out of receiving any emails from this site in the future, please click here: "); //Send individual email out to each person so we can customize the optout link foreach (string recip in recipients) { string recipient = recip; if (ConfigurationManager.AppSettings["environment"] == "dev") recipient = ConfigurationManager.AppSettings["TestEmailAddress"]; string emailBody = sb.ToString() + "http://" + this.blogConfig.Host + "/home/optout/" + recipient; EmailHandler.SendEmail(_feedbackSenderAddress, emailBody, recipient, this.BlogEntryScreen.BlogEntry.Title, true); LoggingHandler.Log("Email Sent for Feedback to commentors", "Email sent to " + recipient, "Info", "ArchiveScreen"); } } } #endregion }
/// <summary> /// Create a new BlogFeedbackAuthor object. /// </summary> /// <param name="blogFeedbackAuthorId">Initial value of the BlogFeedbackAuthorId property.</param> /// <param name="blogConfigId">Initial value of the BlogConfigId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="feedbackTotal">Initial value of the FeedbackTotal property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> /// <param name="lastUpdateDate">Initial value of the LastUpdateDate property.</param> public static BlogFeedbackAuthor CreateBlogFeedbackAuthor(global::System.Int64 blogFeedbackAuthorId, global::System.Int32 blogConfigId, global::System.String name, global::System.String email, global::System.Int32 feedbackTotal, global::System.DateTime createDate, global::System.DateTime lastUpdateDate) { BlogFeedbackAuthor blogFeedbackAuthor = new BlogFeedbackAuthor(); blogFeedbackAuthor.BlogFeedbackAuthorId = blogFeedbackAuthorId; blogFeedbackAuthor.BlogConfigId = blogConfigId; blogFeedbackAuthor.Name = name; blogFeedbackAuthor.Email = email; blogFeedbackAuthor.FeedbackTotal = feedbackTotal; blogFeedbackAuthor.CreateDate = createDate; blogFeedbackAuthor.LastUpdateDate = lastUpdateDate; return blogFeedbackAuthor; }
public static BlogFeedbackAuthor GetFakeBlogFeedbackAuthor(int blogConfigId) { var blogAuthor = new BlogFeedbackAuthor() { BlogConfigId = blogConfigId, CreateDate = DateTime.Now, Email = "*****@*****.**", FeedbackTotal = 0, LastUpdateDate = DateTime.Now, Name = "test", Url = "test" }; return blogAuthor; }
public BlogFeedback SaveFeedback(string entryName, string name, string email, string webSite, string message, string requestUserHostAddress, bool isUserLoggedIn, string requestUserAgent, int blogConfigId, bool notifyAuthorOnFeedback) { throw new Exception("Move this to the business layer."); BlogEntry entry = db.BlogEntries.Where(p => p.BlogConfigId == blogConfigId).Where(p => p.EntryName == entryName).SingleOrDefault(); if (entry != null) { entry.FeedbackCount++; BlogFeedbackAuthor blogFeedbackAuthor = db.BlogFeedbackAuthors.Where(p => p.Name == name) .Where(p => p.Email == email).Where(p => p.Url == webSite).SingleOrDefault(); if (blogFeedbackAuthor == null) { blogFeedbackAuthor = new BlogFeedbackAuthor(); blogFeedbackAuthor.Url = webSite; blogFeedbackAuthor.Name = name; blogFeedbackAuthor.LastUpdateDate = DateTime.Now; blogFeedbackAuthor.Email = email; blogFeedbackAuthor.CreateDate = DateTime.Now; blogFeedbackAuthor.FeedbackTotal = 1; blogFeedbackAuthor.BlogConfigId = entry.BlogConfigId; db.BlogFeedbackAuthors.AddObject(blogFeedbackAuthor); } else { blogFeedbackAuthor.FeedbackTotal++; blogFeedbackAuthor.LastUpdateDate = DateTime.Now; } this.Save(); BlogConfig config = this.GetBlogConfigByBlogConfigId(blogConfigId); BlogFeedback blogFeedback = new BlogFeedback(); //blogFeedback. = name; blogFeedback.BlogFeedbackAuthorId = blogFeedbackAuthor.BlogFeedbackAuthorId; blogFeedback.BlogConfigId = entry.BlogConfigId; blogFeedback.BlogEntryId = entry.BlogEntryId; blogFeedback.Body = message; blogFeedback.CreateDate = DateTime.Now; blogFeedback.FeedbackType = (int)FeedbackStatus.PendingApproval; blogFeedback.IpAddress = requestUserHostAddress; blogFeedback.IsBlogAuthor = isUserLoggedIn; blogFeedback.LastUpdateDate = DateTime.Now; blogFeedback.NotifyAuthorOnFeedback = notifyAuthorOnFeedback; //if (config.CommentsRequireApproval) if (false) { blogFeedback.Status = (int)FeedbackStatus.PendingApproval; } else { blogFeedback.Status = (int)FeedbackStatus.Approved; //config++; } blogFeedback.Title = "re: " + entry.Title; //blogFeedback.ur = webSite; blogFeedback.UserAgent = requestUserAgent; db.BlogFeedbacks.AddObject(blogFeedback); this.Save(); return blogFeedback; } else { throw new Exception("Couldn't find entry name to save comment. EntryName = " + entryName); } }
public void Delete(BlogFeedbackAuthor blogFeedbackAuthor) { db.BlogFeedbackAuthors.DeleteObject(blogFeedbackAuthor); }
public void Add(BlogFeedbackAuthor blogFeedbackAuthor) { db.BlogFeedbackAuthors.AddObject(blogFeedbackAuthor); }