public static List<Speaker> DisplayAllSpeakers()
 {
     using (var ctx = new ConferenceContext())
     {
         return ctx.Speakers.ToList();
     }
 }
 public static Speaker GetSpeaker(int? id)
 {
     using (var ctx = new ConferenceContext())
     {
         return ctx.Speakers.Find(id);
     }
 }
        //
        // GET: /Session/

        public ActionResult Index()
        {
            ConferenceContext context = new ConferenceContext();
            List<Session> sessions = context.Sessions.ToList();


            return View("Wibble", sessions);
        }
 public static void DeleteSpeaker(int id)
 {
     using (var ctx = new ConferenceContext())
     {
         var speaker = ctx.Speakers.Find(id);
         ctx.Speakers.Remove(speaker);
         ctx.SaveChanges();
     }
 }
 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;
 }
 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;
 }
        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");
        }