public void BatchDeleteTest() { VOS_Shop v1 = new VOS_Shop(); VOS_Shop v2 = new VOS_Shop(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.CustomerId = AddCustomer(); v1.ShopName = "PvZ"; v2.CustomerId = v1.CustomerId; v2.ShopName = "b1Qcz"; context.Set <VOS_Shop>().Add(v1); context.Set <VOS_Shop>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(VOS_ShopBatchVM)); VOS_ShopBatchVM vm = rv.Model as VOS_ShopBatchVM; 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 <VOS_Shop>().Count(), 2); } }
public ActionResult DoBatchDelete(VOS_ShopBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"])); } }