public ActionResult ListMessages() { using (var db = new MessageDBContext()) { var records = new MessageList<MessageDBModel>(); records.Content = db.Messages.OrderBy(x => x.time).ToList(); return PartialView("ListMessages", records.Content); } }
public ActionResult Index(MessageDBModel model) { if (model != null) { using ( var db = new MessageDBContext()) { try { db.Messages.Add(model); db.SaveChanges(); } catch (DbEntityValidationException e) { Debug.WriteLine("Saving Messages into db Error 1: " + e.EntityValidationErrors); } } return View(model); } else { return Json("An Error Has occoured"); } }