public void BatchDeleteTest() { GroupDicEntity v1 = new GroupDicEntity(); GroupDicEntity v2 = new GroupDicEntity(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.Title = "IMx"; v1.Sort = 16; v2.Title = "B3HO"; v2.Sort = 53; context.Set <GroupDicEntity>().Add(v1); context.Set <GroupDicEntity>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new Guid[] { v1.ID, v2.ID }); Assert.IsInstanceOfType(rv.Model, typeof(GroupDicEntityBatchVM)); GroupDicEntityBatchVM vm = rv.Model as GroupDicEntityBatchVM; vm.Ids = new Guid[] { v1.ID, v2.ID }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <GroupDicEntity>().Count(), 0); } }
public ActionResult DoBatchDelete(GroupDicEntityBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除")); } }