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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ID         = 16;
                v1.OrderTotal = 12;
                v1.UserId     = AddUser();
                v2.OrderTotal = 35;
                v2.UserId     = v1.UserId;
                context.Set <WxOrder>().Add(v1);
                context.Set <WxOrder>().Add(v2);
                context.SaveChanges();
            }

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

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

            WxOrderBatchVM vm = rv.Model as WxOrderBatchVM;

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