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