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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name = "Ig1N37FOm";
                v1.Age  = 20;
                v2.Name = "fQFq";
                v2.Age  = 92;
                context.Set <Student>().Add(v1);
                context.Set <Student>().Add(v2);
                context.SaveChanges();
            }

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

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

            StudentBatchVM vm = rv.Model as StudentBatchVM;

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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data1 = context.Set <Student>().Find(v1.ID);
                var data2 = context.Set <Student>().Find(v2.ID);
                Assert.AreEqual(data1, null);
                Assert.AreEqual(data2, null);
            }
        }
        public void BatchDeleteTest()
        {
            Student v1 = new Student();
            Student v2 = new Student();

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

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

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

            StudentBatchVM vm = rv.Model as StudentBatchVM;

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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <Student>().Count(), 0);
            }
        }
Exemple #3
0
 public ActionResult DoBatchDelete(StudentBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().RefreshGrid().CloseDialog().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除"));
     }
 }
Exemple #4
0
 public ActionResult DoBatchDelete(StudentBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"]));
     }
 }
Exemple #5
0
 public ActionResult DoBatchDelete(StudentBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]));
     }
 }
        public void BatchEditTest()
        {
            Student v1 = new Student();
            Student v2 = new Student();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name = "Ig1N37FOm";
                v1.Age  = 20;
                v2.Name = "fQFq";
                v2.Age  = 92;
                context.Set <Student>().Add(v1);
                context.Set <Student>().Add(v2);
                context.SaveChanges();
            }

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

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

            StudentBatchVM vm = rv.Model as StudentBatchVM;

            vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };

            vm.LinkedVM.Name = "QSln";
            vm.LinkedVM.Age  = 13;
            vm.FC            = new Dictionary <string, object>();

            vm.FC.Add("LinkedVM.Name", "");
            vm.FC.Add("LinkedVM.Age", "");
            _controller.DoBatchEdit(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data1 = context.Set <Student>().Find(v1.ID);
                var data2 = context.Set <Student>().Find(v2.ID);

                Assert.AreEqual(data1.Name, "QSln");
                Assert.AreEqual(data2.Name, "QSln");
                Assert.AreEqual(data1.Age, 13);
                Assert.AreEqual(data2.Age, 13);
                Assert.AreEqual(data1.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data1.UpdateTime.Value).Seconds < 10);
                Assert.AreEqual(data2.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data2.UpdateTime.Value).Seconds < 10);
            }
        }