public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, CharacterVM viewModel)
 {
     try
     {
         if (viewModel != null)
         {
             ModelState.Clear();
             Character delviewModel = db.Characters.Find(viewModel.CharacterId);
             if (delviewModel != null)
             {
                 db.Characters.Remove(delviewModel);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateException dbUpdEx)
     {
         ModelState.AddModelError("showerror", "Delete failed.  This is most likely due to related child information that needs to be deleted first.");
         Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Delete failed.  This is most likely due to related child information that needs to be deleted first."));
         Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdEx);
     }
     catch (DataException dataEx)
     {
         ModelState.AddModelError("hideerror", "Data error");
         Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
     }
     return Json(ModelState.IsValid ? new object() : ModelState.ToDataSourceResult());
 }
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, CharacterVM viewModel)
        {
            try
            {
                if (viewModel != null && ModelState.IsValid)
                {
                    Character newviewModel = new Character();

                    newviewModel.Name = viewModel.Name;
                    newviewModel.UserUserId = viewModel.PlayerId;
                    newviewModel.CampaignCampaignId = viewModel.CampaignId;

                    db.Characters.Add(newviewModel);
                    db.SaveChanges();
                    viewModel.CharacterId = newviewModel.CharacterId;
                    viewModel.Campaign = db.Campaigns.Find(viewModel.CampaignId).Name;
                    viewModel.Player = db.Users.Find(viewModel.PlayerId).Name;
                }
            }
            catch (DataException dataEx)
            {
                ModelState.AddModelError(string.Empty, "Data error");
                Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
            }

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }