public ActionResult Delete(DeleteManufacturerVM mDeleteManufacturerVm)
 {
     if (ModelState.IsValid)
     {
         var mdl = _svc.GetManufacturer(mDeleteManufacturerVm.ManufacturerId);
         if (mDeleteManufacturerVm.MakeObsolete)
         {
             mdl.Retired = true;
             if (ExecuteRepositoryAction(() =>
             {
                 _svc.UpdateManufacturer(mdl);
                 _svc.CommitChanges();
             }))
             {
                 return(ReturnJsonFormSuccess());
             }
         }
         if (ExecuteRepositoryAction(() =>
         {
             _svc.DeleteManufacturer(mdl);
             _svc.CommitChanges();
         }))
         {
             return(ReturnJsonFormSuccess());
         }
     }
     return(PartialView("_DeleteManufacturer", mDeleteManufacturerVm));
 }
        public ActionResult Delete(int id)
        {
            var mdl = _svc.GetManufacturer(id);
            var vm  = new DeleteManufacturerVM {
                ManufacturerId = id, MakeObsolete = false
            };

            if (_svc.GetModels().Any(m => m.ManufacturerId == id))
            {
                vm.DeleteMessage = string.Format("Manufacturer {0} is attached to existing records and can not be deleted.", mdl.Name);
                vm.Prompt        = "Do you wish to mark as retired?";
                vm.MakeObsolete  = true;
            }
            else
            {
                vm.Prompt = "Do you wish to delete Manufacturer " + mdl.Name + " ?";
            }
            return(PartialView("_DeleteManufacturer", vm));
        }