public ActionResult Edit(int id, VMBook data)
 {
     try
     {
         // context on outside because both sides of modelstate
         // need context (then needs to update, and else needs to repopulate)
         using (Context ctx = new Context())
         {
             if (ModelState.IsValid)
             {
                 ctx.BookUpdateJust(id, data);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 data.PopulateGenreItems(ctx.GenreGetAll());
                 return(View(data));
             }
         }
     }
     catch (Exception ex)
     {
         return(View("Exception", ex));
     }
 }
 public ActionResult Create()
 {
     try
     {
         using (Context ctx = new Context())
         {
             var data = new VMBook();
             data.PopulateGenreItems(ctx.GenreGetAll());
             return(View(data));
         }
     }
     catch (Exception ex)
     {
         return(View("Exception", ex));
     }
 }
 public ActionResult Create(VMBook data)
 {
     try
     {
         using (Context ctx = new Context())
         {
             if (ModelState.IsValid)
             {
                 ctx.BookCreate(data);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 data.PopulateGenreItems(ctx.GenreGetAll());
                 return(View(data));
             }
         }
     }
     catch (Exception ex)
     {
         return(View("Exception", ex));
     }
 }