public void BatchDeleteTest()
        {
            CreditCard v1 = new CreditCard();
            CreditCard v2 = new CreditCard();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                context.Set <CreditCard>().Add(v1);
                context.Set <CreditCard>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new Guid[] { v1.ID, v2.ID });

            Assert.IsInstanceOfType(rv.Model, typeof(CreditCardBatchVM));

            CreditCardBatchVM vm = rv.Model as CreditCardBatchVM;

            vm.Ids = new Guid[] { v1.ID, v2.ID };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <CreditCard>().Count(), 0);
            }
        }
예제 #2
0
 public ActionResult DoBatchDelete(CreditCardBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().RefreshGrid().CloseDialog().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除"));
     }
 }