Exemplo n.º 1
0
 public static void DeleteSpeaker(int id)
 {
     using (var ctx = new ConferenceContext())
     {
         var speaker = ctx.Speakers.Find(id);
         ctx.Speakers.Remove(speaker);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
        public ActionResult Create(Session session)
        {
            if(!ModelState.IsValid){
                return View(session);
            }

            try
            {
                ConferenceContext context = new ConferenceContext();
                context.Sessions.Add(session);
                context.SaveChanges();
            }
            catch (Exception ex)
            {

                ModelState.AddModelError("Error", ex.Message);
                return View(session);
            }

            TempData["Created"] = "Created" + session.Title;
            return RedirectToAction("Index");
        }