public void BatchDeleteTest() { dept v1 = new dept(); dept v2 = new dept(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.Index = 13; v2.Index = 56; context.Set <dept>().Add(v1); context.Set <dept>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(deptBatchVM)); deptBatchVM vm = rv.Model as deptBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <dept>().Count(), 0); } }
public ActionResult DoBatchDelete(deptBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"])); } }