Пример #1
0
        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);
            }
        }
Пример #2
0
 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");
     }
 }