コード例 #1
0
 public JsonResult Edit(Event e)
 {
     if (ModelState.IsValid)
     {
         db.Entry(e).State = EntityState.Modified;
         db.SaveChanges();
         return Json(e);
     } else {
         throw new Exception("Could not model bind event.");
     }
 }
コード例 #2
0
        public JsonResult Create(Event e)
        {
            if (ModelState.IsValid)
            {
                db.Events.Add(e);
                db.SaveChanges();

                Response.AppendCookie(new HttpCookie("event", e.ID.ToString()));

                return Json(e);
            } else {
                throw new Exception("Could not model bind event.");
            }
        }