Exemplo n.º 1
0
        public void GeByNametTest()
        {
            var    target = new RoleDao();
            string id     = "role1";
            Role   actual;

            actual = target.GetByName(id);
            Assert.AreEqual(id, actual.Name);
        }
Exemplo n.º 2
0
 public ActionResult Index(AdminModel entity)
 {
     if (ModelState.IsValid)
     {
         var  RoleName = entity.RoleName;
         long RoleId   = 0;
         var  Role     = Dao.GetByName(RoleName);
         if (Role != null)
         {
             RoleId = Role.Id;
             var User = new tb_Users();
             User.Date         = DateTime.Now;
             User.Modified     = DateTime.Now;
             User.RoleId       = RoleId;
             User.Status       = true;
             User.UserEmail    = entity.UserEmail;
             User.UserName     = entity.UserName;
             User.UserPassword = mhPass.MahoaMD5(entity.UserPassword);
             UDao.Insert(User);
         }
         else
         {
             Role                 = new tb_Roles();
             Role.RoleName        = RoleName;
             Role.RoleDescription = "Người quản trị cao nhất!";
             Role.RoleAction      = 7;
             Dao.Insert(Role);
             RoleId = Role.Id;
             var User = new tb_Users();
             User.Date         = DateTime.Now;
             User.Modified     = DateTime.Now;
             User.RoleId       = RoleId;
             User.Status       = true;
             User.UserEmail    = entity.UserEmail;
             User.UserName     = entity.UserName;
             User.UserPassword = mhPass.MahoaMD5(entity.UserPassword);
             UDao.Insert(User);
         }
         return(RedirectToAction("Index"));
     }
     return(View(entity));
 }
Exemplo n.º 3
0
 public void GeByNametTest()
 {
     var target = new RoleDao();
     string id = "role1";
     Role actual;
     actual = target.GetByName(id);
     Assert.AreEqual(id, actual.Name);
 }