public void BatchDeleteTest() { Location v1 = new Location(); Location v2 = new Location(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.Name = "bhVtNC"; v2.Name = "GV9Ll"; context.Set <Location>().Add(v1); context.Set <Location>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(LocationBatchVM)); LocationBatchVM vm = rv.Model as LocationBatchVM; 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 <Location>().Count(), 0); } }
public ActionResult DoBatchDelete(LocationBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().RefreshGrid().CloseDialog().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除")); } }
public ActionResult DoBatchDelete(LocationBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"])); } }