Esempio n. 1
0
 public ActionResult Create(VOS_CustomerVM vm)
 {
     if (!IsSuperAdministrator)
     {
         if (GetOrganizationID == null)
         {
             return(FFResult().CloseDialog().Alert(GetMsg, "提示"));
         }
         vm.Entity.OrganizationID = GetOrganizationID;
     }
     if (!ModelState.IsValid)
     {
         ViewBag.IsShow = IsSuperAdministrator;
         return(PartialView(vm));
     }
     else
     {
         vm.DoAdd();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGrid());
         }
     }
 }
Esempio n. 2
0
        public void DeleteTest()
        {
            VOS_Customer v = new VOS_Customer();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.cust_no   = "2gSheVYN";
                v.cust_name = "NJZae6UEQ";
                context.Set <VOS_Customer>().Add(v);
                context.SaveChanges();
            }

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

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

            VOS_CustomerVM vm = rv.Model as VOS_CustomerVM;

            v         = new VOS_Customer();
            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 <VOS_Customer>().Count(), 1);
            }
        }
Esempio n. 3
0
 public ActionResult Edit(VOS_CustomerVM 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));
         }
     }
 }
Esempio n. 4
0
        public void EditTest()
        {
            VOS_Customer v = new VOS_Customer();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.cust_no   = "2gSheVYN";
                v.cust_name = "NJZae6UEQ";
                context.Set <VOS_Customer>().Add(v);
                context.SaveChanges();
            }

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

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

            VOS_CustomerVM vm = rv.Model as VOS_CustomerVM;

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

            v.cust_no   = "J3x8";
            v.cust_name = "TvA";
            vm.Entity   = v;
            vm.FC       = new Dictionary <string, object>();

            vm.FC.Add("Entity.cust_no", "");
            vm.FC.Add("Entity.cust_name", "");
            _controller.Edit(vm);

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

                Assert.AreEqual(data.cust_no, "J3x8");
                Assert.AreEqual(data.cust_name, "TvA");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
Esempio n. 5
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            VOS_CustomerVM vm = rv.Model as VOS_CustomerVM;
            VOS_Customer   v  = new VOS_Customer();

            v.cust_no   = "2gSheVYN";
            v.cust_name = "NJZae6UEQ";
            vm.Entity   = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.cust_no, "2gSheVYN");
                Assert.AreEqual(data.cust_name, "NJZae6UEQ");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }