Beispiel #1
0
        public ActionResult Create(FormCollection form)
        {
            using (var context = new ModelContainer())
            {
                var newsItem = new News();
                TryUpdateModel(newsItem, new[] { "Title", "Date" });
                newsItem.Text = HttpUtility.HtmlDecode(form["Text"]);
                context.AddToNews(newsItem);

                // TODO: change absolute url!!!!!
                var mailText = HttpUtility.HtmlDecode(form["Text"]).Replace("src=\"", "src=\"http://posh-net-ua.1gb.ua/");
                var mailSubject = "Posh. Рассылка новостей.";
                var subscribers = context.Subscriber.ToList();
                foreach (var subscriber in subscribers)
                {
                    new MailHelper("*****@*****.**", "POSH").SendMessage(new MailAddress(subscriber.Email), mailText, mailSubject, true);
                }

                context.SaveChanges();
            }
            return RedirectToAction("Index", "News", new { Area = "" });
        }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the News EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNews(News news)
 {
     base.AddObject("News", news);
 }
Beispiel #3
0
 /// <summary>
 /// Create a new News object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 public static News CreateNews(global::System.Int32 id, global::System.String title, global::System.DateTime date, global::System.String text)
 {
     News news = new News();
     news.Id = id;
     news.Title = title;
     news.Date = date;
     news.Text = text;
     return news;
 }