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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.CustomerId  = AddCustomer();
                v1.GoodsInfoId = AddGoodsInfo();
                v1.SaleNumber  = 25;
                v1.SalePrice   = 19;
                v2.CustomerId  = v1.CustomerId;
                v2.GoodsInfoId = v1.GoodsInfoId;
                v2.SaleNumber  = 51;
                v2.SalePrice   = 79;
                context.Set <SaleOutput>().Add(v1);
                context.Set <SaleOutput>().Add(v2);
                context.SaveChanges();
            }

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

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

            SaleOutputBatchVM vm = rv.Model as SaleOutputBatchVM;

            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 <SaleOutput>().Count(), 2);
            }
        }
Esempio n. 2
0
 public ActionResult DoBatchDelete(SaleOutputBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().CloseDialog().RefreshGrid().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除"));
     }
 }