public ActionResult Edit(Speaker speaker)
 {
     if (ModelState.IsValid)
     {
         db.Entry(speaker).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(speaker);
 }
        public ActionResult Create(Speaker speaker)
        {
            if (ModelState.IsValid)
            {
                db.Speakers.Add(speaker);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(speaker);
        }
Пример #3
0
 public static bool Edit(Speaker speaker, ModelStateDictionary msd)
 {
     if (msd.IsValid)
     {
         using (var ctx = new ConferenceContext())
         {
             ctx.Entry(speaker).State = System.Data.Entity.EntityState.Modified;
             ctx.SaveChanges();
             return true;
         }
     }
     return false;
 }
Пример #4
0
 public static bool Create(Speaker speaker, ModelStateDictionary msd)
 {
     if (msd.IsValid)
     {
         using (var ctx = new ConferenceContext())
         {
             ctx.Speakers.Add(speaker);
             ctx.SaveChanges();
             return true;
         }
     }
     return false;
 }