public void BatchDeleteTest() { ship_pop v1 = new ship_pop(); ship_pop v2 = new ship_pop(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.UserID = AddUser(); v1.PopID = AddPop(); v1.OrderQty = 38; v2.UserID = v1.UserID; v2.PopID = v1.PopID; v2.OrderQty = 97; context.Set <ship_pop>().Add(v1); context.Set <ship_pop>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(ship_popBatchVM)); ship_popBatchVM vm = rv.Model as ship_popBatchVM; 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 <ship_pop>().Count(), 0); } }
public ActionResult DoBatchDelete(ship_popBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"])); } }