public ActionResult AddEnew(Enew enew, DateTime ngayxuatban, DateTime ngayketthuc) { if (ModelState.IsValid) { //int dem = db.EmailSubcribeEnews.Count(); //EmailSubcribeEnew[] list = db.EmailSubcribeEnews.ToArray(); //for (int i = 0; i < dem; i++) //{ // if (list[i] != null) // { // var smtp = new SmtpClient("smtp.gmail.com", 25); // smtp.Credentials = new NetworkCredential("*****@*****.**", "songlong"); // smtp.EnableSsl = true; // MailMessage mail = new MailMessage(); // mail.From = new MailAddress("*****@*****.**", "*****@*****.**"); // mail.ReplyToList.Add("*****@*****.**"); // mail.To.Add(list[i].EmailSubcribe); // mail.Subject = enew.EnewsTitle; // mail.SubjectEncoding = Encoding.UTF8; // mail.Body = enew.EnewsContent; // mail.BodyEncoding = Encoding.UTF8; // mail.IsBodyHtml = true; // smtp.Send(mail); // } // else // { // ViewBag.thongbao = "gui that bai!"; // return View(); // } //} enew.PublishDate = ngayxuatban; enew.EndDate = ngayketthuc; db.Enews.Add(enew); db.SaveChanges(); } return View(); }
public ActionResult SuaEnew(Enew enew,DateTime ngayxuatban,DateTime ngayketthuc) { Enew enew2 = db.Enews.Single(n => n.EnewsID == enew.EnewsID); enew2.PublishDate = ngayxuatban; enew2.EndDate = ngayketthuc; enew2.EnewsTitle = enew.EnewsTitle; enew2.EnewsContent = enew.EnewsContent; enew2.EnewsTitleM = enew.EnewsTitleM; enew2.EnewsContentM = enew.EnewsContentM; db.SaveChanges(); return View(); }