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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ElementName  = "Dd7iNP";
                v1.CheckContent = "LajPW";
                v1.CheckPoint   = "4RlPPQU";
                v1.Order        = 43;
                v2.ElementName  = "SnT";
                v2.CheckContent = "yZ45xBa";
                v2.CheckPoint   = "22imxPZz";
                v2.Order        = 48;
                context.Set <EntRegularCheckElement>().Add(v1);
                context.Set <EntRegularCheckElement>().Add(v2);
                context.SaveChanges();
            }

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

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

            EntRegularCheckElementBatchVM vm = rv.Model as EntRegularCheckElementBatchVM;

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