public void BatchDeleteTest() { pop v1 = new pop(); pop v2 = new pop(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.GroupID = AddGroup(); v1.PopIndex = 55; v1.PopName = "lUMJoD"; v1.Weight = 54; v2.GroupID = v1.GroupID; v2.PopIndex = 14; v2.PopName = "vYtO"; v2.Weight = 71; context.Set <pop>().Add(v1); context.Set <pop>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(popBatchVM)); popBatchVM vm = rv.Model as 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 <pop>().Count(), 0); } }
public ActionResult DoBatchDelete(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"])); } }