示例#1
0
 public ActionResult AddShortMessage(ShortMessage msg)
 {
     msg.AddedDate = DateTime.Now;
     using (var db = new ApplicationDbContext())
     {
         db.ShortMessage.Add(msg);
         db.SaveChanges();
     }
     return View();
 }
示例#2
0
 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");
 }