public UserGroupRelationWindow(UserGroupModel entity, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
示例#2
0
 public void TestUserGroupModelCreateTable()
 {
     var entity = new UserGroupModel { GroupName = "GroupName", GroupDisplayName = "GroupDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     UserGroupModel result;
     using (var session = sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         result = session.Get<UserGroupModel>(entity.Id);
     }
     Assert.AreEqual(entity.GroupName, result.GroupName);
 }
示例#3
0
 public void TestUserGroupModelQueryAll()
 {
     var insertEntity = new UserGroupModel { GroupName = "RoleName", GroupDisplayName = "RoleDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     using (var session = sessions.OpenSession())
     {
         session.Save(insertEntity);
         session.Flush();
         ICriteria crit = session.CreateCriteria(typeof(UserGroupModel));
         var entityList = crit.List();
         var resultList = session.CreateQuery("from UserGroupModel ").List<UserGroupModel>();
         Assert.AreEqual(entityList.Count, resultList.Count);
     }
 }
        private void InitData(UserGroupModel entity)
        {
            TxtGroupName.Text = entity.GroupName;
            TxtGroupDisplayName.Text = entity.GroupDisplayName;
            ClearItems();
            ExistRoleInfoList = UserOperationDAL.QueryAllUserRoleByUserGroupId(entity.Id);
            ExistUserInfoList = UserOperationDAL.QueryAllUserInfoByUserGroupId(entity.Id);
            LvGroupRole.ItemsSource = ExistRoleInfoList.DeepCopy();
            LvUserName.ItemsSource = ExistUserInfoList.DeepCopy();
            Id = entity.Id;
            CreateDateTime = entity.CreateDateTime;
            IsDelete = entity.IsDelete;

        }
示例#5
0
 public void TestUserGroupModelDelete()
 {
     var insertEntity = new UserGroupModel { GroupName = "RoleName", GroupDisplayName = "RoleDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     using (var session = sessions.OpenSession())
     {
         session.Save(insertEntity);
         session.Flush();
         ICriteria crit = session.CreateCriteria(typeof(UserGroupModel));
         var entity = crit.List<UserGroupModel>().First();
         session.Delete(entity);
         session.Flush();
         var result = session.Get<UserGroupModel>(entity.Id);
         Assert.IsNull(result);
     }
 }
示例#6
0
 public void TestUserGroupModelModify()
 {
     var entity = new UserGroupModel { GroupName = "GroupName", GroupDisplayName = "GroupDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     UserGroupModel queryEntity;
     using (var session = sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         queryEntity = session.Get<UserGroupModel>(entity.Id);
         queryEntity.GroupName = "Modified";
         session.SaveOrUpdate(queryEntity);
         session.Flush();
         var result = session.Get<UserGroupModel>(entity.Id);
         Assert.AreEqual(queryEntity.GroupName, result.GroupName);
     }
 }
示例#7
0
        public void TestUserGroupModelByRoleName()
        {
            var insertEntity = new UserGroupModel { GroupName = "RoleName", GroupDisplayName = "RoleDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
            using (var session = sessions.OpenSession())
            {
                session.Save(insertEntity);
                session.Flush();
                UserGroupModel entity = null;
                var resultList = session.CreateQuery("from UserGroupModel ").List<UserGroupModel>();
                if (resultList.Count > 0)
                    entity = resultList.FirstOrDefault();
                ICriteria crit = session.CreateCriteria(typeof(UserGroupModel)).Add(Restrictions.Eq("GroupName", entity.GroupName));
                var result = crit.List<UserGroupModel>().First();

                Assert.AreEqual(result.GroupName, entity.GroupName);
            }
        }