public ActionResult AddShortMessage(ShortMessage msg) { msg.AddedDate = DateTime.Now; using (var db = new ApplicationDbContext()) { db.ShortMessage.Add(msg); db.SaveChanges(); } return View(); }
public ActionResult EditShortMessage(ShortMessage msg) { using (var db = new ApplicationDbContext()) { var message = db.ShortMessage.FirstOrDefault(m => m.ShortMessageId == msg.ShortMessageId); message.Title = msg.Title; message.Content = msg.Content; db.SaveChanges(); } return RedirectToAction("ShortMessageList"); }