public ActionResult Add(FormCollection form) { using (var context = new ContentStorage()) { var article = new Article(); TryUpdateModel(article, new[] { "Title", "Date" }); article.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToArticle(article); context.SaveChanges(); var mailText = article.Text.Replace("src=\"", "src=\"http://havila-travel.com/"); var customers = context.Customers.Where(c=>c.IsActive==1).ToList(); foreach (var customer in customers) { mailText += "<br/><br/> Для того, чтобы отписаться от рассылке перейдите пожалуйста по следующей ссылке <br/>"; mailText += "<a href=\"http://havila-travel.com/unsubscribe/" + customer.Id + "\">http://havila-travel.com/unsubscribe/" + customer.Id + "</a>"; MailHelper.SendMessage(new MailAddress(customer.Email), mailText, "Рассылка Havila-Travel", true); } } return RedirectToAction("Index", "Articles", new { Area = "" }); }
/// <summary> /// Create a new Article object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="date">Initial value of the Date property.</param> public static Article CreateArticle(global::System.Int64 id, global::System.DateTime date) { Article article = new Article(); article.Id = id; article.Date = date; return article; }
/// <summary> /// Deprecated Method for adding a new object to the Article EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToArticle(Article article) { base.AddObject("Article", article); }