Ejemplo n.º 1
0
        public void BatchDeleteTest()
        {
            Category v1 = new Category();
            Category v2 = new Category();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name = "ttbc6G";
                v2.Name = "sEXfPP9s";
                context.Set <Category>().Add(v1);
                context.Set <Category>().Add(v2);
                context.SaveChanges();
            }

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

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

            CategoryBatchVM vm = rv.Model as CategoryBatchVM;

            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 <Category>().Count(), 2);
            }
        }
Ejemplo n.º 2
0
 public ActionResult DoBatchDelete(CategoryBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"]));
     }
 }