public void BatchDeleteTest() { TableCheckHistory v1 = new TableCheckHistory(); TableCheckHistory v2 = new TableCheckHistory(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.TableID = AddTable(); v1.GroupValue = "7NLWrRZHS"; v1.GroupCount = 37; v1.ID = 88; v2.TableID = v1.TableID; v2.GroupValue = "MjpLS6w1w"; v2.GroupCount = 96; context.Set <TableCheckHistory>().Add(v1); context.Set <TableCheckHistory>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(TableCheckHistoryBatchVM)); TableCheckHistoryBatchVM vm = rv.Model as TableCheckHistoryBatchVM; 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 <TableCheckHistory>().Count(), 0); } }
public ActionResult DoBatchDelete(TableCheckHistoryBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除")); } }