public void BatchDeleteTest() { WxVenue v1 = new WxVenue(); WxVenue v2 = new WxVenue(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.ID = 85; v1.Name = "2U5j0WVaf"; v1.Description = "JmD"; v2.Name = "w0t"; v2.Description = "FPoq8CN"; context.Set <WxVenue>().Add(v1); context.Set <WxVenue>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(WxVenueBatchVM)); WxVenueBatchVM vm = rv.Model as WxVenueBatchVM; 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 <WxVenue>().Count(), 2); } }
public ActionResult DoBatchDelete(WxVenueBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除")); } }