public void DeleteTest()
        {
            WxOrder v = new WxOrder();

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

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

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

            WxOrderVM vm = rv.Model as WxOrderVM;

            v         = new WxOrder();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <WxOrder>().Count(), 0);
            }
        }
Exemplo n.º 2
0
 public ActionResult Edit(WxOrderVM 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));
         }
     }
 }
Exemplo n.º 3
0
 public ActionResult Create(WxOrderVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoAdd();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGrid());
         }
     }
 }
        public void EditTest()
        {
            WxOrder v = new WxOrder();

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

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

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

            WxOrderVM vm = rv.Model as WxOrderVM;

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

            v.OrderTotal = 35;
            vm.Entity    = v;
            vm.FC        = new Dictionary <string, object>();

            vm.FC.Add("Entity.ID", "");
            vm.FC.Add("Entity.OrderTotal", "");
            vm.FC.Add("Entity.UserId", "");
            _controller.Edit(vm);

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

                Assert.AreEqual(data.OrderTotal, 35);
            }
        }
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            WxOrderVM vm = rv.Model as WxOrderVM;
            WxOrder   v  = new WxOrder();

            v.ID         = 16;
            v.OrderTotal = 12;
            v.UserId     = AddUser();
            vm.Entity    = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.ID, 16);
                Assert.AreEqual(data.OrderTotal, 12);
            }
        }