コード例 #1
0
 public ActionResult Edit(PushTasksEntityVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoEdit();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID));
         }
     }
 }
コード例 #2
0
        public void EditTest()
        {
            PushTasksEntity v = new PushTasksEntity();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.TaskTitle = "GiICb";
                v.TaskBody  = "Y9etx";
                context.Set <PushTasksEntity>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID);

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

            PushTasksEntityVM vm = rv.Model as PushTasksEntityVM;

            v    = new PushTasksEntity();
            v.ID = vm.Entity.ID;

            v.TaskTitle = "5Q9";
            v.TaskBody  = "V35xIN7N8";
            vm.Entity   = v;
            vm.FC       = new Dictionary <string, object>();

            vm.FC.Add("Entity.TaskTitle", "");
            vm.FC.Add("Entity.TaskBody", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <PushTasksEntity>().FirstOrDefault();

                Assert.AreEqual(data.TaskTitle, "5Q9");
                Assert.AreEqual(data.TaskBody, "V35xIN7N8");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
コード例 #3
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            PushTasksEntityVM vm = rv.Model as PushTasksEntityVM;
            PushTasksEntity   v  = new PushTasksEntity();

            v.TaskTitle = "GiICb";
            v.TaskBody  = "Y9etx";
            vm.Entity   = v;
            _controller.Create(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <PushTasksEntity>().FirstOrDefault();

                Assert.AreEqual(data.TaskTitle, "GiICb");
                Assert.AreEqual(data.TaskBody, "Y9etx");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }