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

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


            return View("Wibble", sessions);
        }
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
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");
        }