Ejemplo n.º 1
0
 public ActionResult Create(VOS_UserVM vm)
 {
     vm.Entity.IsValid = true;
     if (!IsSuperAdministrator)
     {
         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());
         }
     }
 }
Ejemplo n.º 2
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            VOS_UserVM vm = rv.Model as VOS_UserVM;
            VOS_User   v  = new VOS_User();

            v.ITCode   = "lAoh1Z";
            v.Password = "******";
            v.Name     = "fhOE1";
            vm.Entity  = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.ITCode, "lAoh1Z");
                Assert.AreEqual(data.Password, "4JkIz");
                Assert.AreEqual(data.Name, "fhOE1");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
Ejemplo n.º 3
0
        public void DeleteTest()
        {
            VOS_User v = new VOS_User();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ITCode   = "lAoh1Z";
                v.Password = "******";
                v.Name     = "fhOE1";
                context.Set <VOS_User>().Add(v);
                context.SaveChanges();
            }

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

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

            VOS_UserVM vm = rv.Model as VOS_UserVM;

            v         = new VOS_User();
            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_User>().Count(), 0);
            }
        }
Ejemplo n.º 4
0
 public ActionResult EditPassword1(VOS_UserVM vm)
 {
     try
     {
         var _User = DC.Set <VOS_User>().Where(x => x.ID == vm.Entity.ID).SingleOrDefault();
         _User.Password = Utils.GetMD5String(vm.Entity.Password);
         DC.Set <VOS_User>().Update(_User).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         DC.SaveChanges();
         return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID));
     }
     catch (Exception)
     {
         return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID).Alert("修改密码失败"));
     }
 }
Ejemplo n.º 5
0
        public void EditTest()
        {
            VOS_User v = new VOS_User();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ITCode   = "lAoh1Z";
                v.Password = "******";
                v.Name     = "fhOE1";
                context.Set <VOS_User>().Add(v);
                context.SaveChanges();
            }

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

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

            VOS_UserVM vm = rv.Model as VOS_UserVM;

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

            v.ITCode   = "QUFpT7";
            v.Password = "******";
            v.Name     = "U4OiX";
            vm.Entity  = v;
            vm.FC      = new Dictionary <string, object>();

            vm.FC.Add("Entity.ITCode", "");
            vm.FC.Add("Entity.Password", "");
            vm.FC.Add("Entity.Name", "");
            _controller.Edit(vm);

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

                Assert.AreEqual(data.ITCode, "QUFpT7");
                Assert.AreEqual(data.Password, "UUcPnSe");
                Assert.AreEqual(data.Name, "U4OiX");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
Ejemplo n.º 6
0
 public ActionResult Edit(VOS_UserVM 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));
         }
     }
 }