public UserRelationWindow(UserInfoModel entity, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
 public void TestUserInfoModelCreateTable()
 {
     var entity = new UserInfoModel { UserName = "******", UserDisplayName = "UserDisplayName", Password = "******", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     UserInfoModel result;
     using (var session = sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         result = session.Get<UserInfoModel>(entity.Id);
     }
     Assert.AreEqual(entity.UserName, result.UserName);
 }
 public void TestUserInfoModelQueryAll()
 {
     var insertEntity = new UserInfoModel { UserName = "******", UserDisplayName = "UserDisplayName", Password = "******", 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(UserInfoModel));
         var entityList = crit.List();
         var resultList = session.CreateQuery("from UserInfoModel ").List<UserInfoModel>();
         Assert.AreEqual(entityList.Count, resultList.Count);
     }
 }
 public void TestUserInfoModelDelete()
 {
     var insertEntity = new UserInfoModel { UserName = "******", UserDisplayName = "UserDisplayName", Password = "******", 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(UserInfoModel));
         var entity = crit.List<UserInfoModel>().First();
         session.Delete(entity);
         session.Flush();
         var result = session.Get<UserInfoModel>(entity.Id);
         Assert.IsNull(result);
     }
 }
 public void TestUserInfoModelModify()
 {
     var entity = new UserInfoModel { UserName = "******", UserDisplayName = "UserDisplayName", Password = "******", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     UserInfoModel queryEntity;
     using (var session = sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         queryEntity = session.Get<UserInfoModel>(entity.Id);
         queryEntity.UserName = "******";
         session.SaveOrUpdate(queryEntity);
         session.Flush();
         var result = session.Get<UserInfoModel>(entity.Id);
         Assert.AreEqual(queryEntity.UserName, result.UserName);
     }
 }
 private void InitData(UserInfoModel entity)
 {
     Id = entity.Id;
     CreateDateTime = entity.CreateDateTime;
     IsDelete = entity.IsDelete;
     PbPassword.Password = entity.Password;
     TxtUserName.Text = entity.UserName;
     TxtUserDisplayName.Text = entity.UserDisplayName;
     ClearDataBinding();
     ExistUserGroupList = UserOperationDAL.QueryAllUserGroupByUserId(entity.Id);
     LvUserGroupName.ItemsSource = ExistUserGroupList.DeepCopy();
     ExistRoleInfoList = UserOperationDAL.QueryAllUserRoleByUserId(entity.Id);
     LvUserRole.ItemsSource = ExistRoleInfoList.DeepCopy();
     var reportToUserEntity = UserOperationDAL.QueryReportUserInfoByUserId(entity.Id);
     if (reportToUserEntity != null)
     {
         TxtReportUserName.Text = reportToUserEntity.UserDisplayName;
         ReportToId = reportToUserEntity.Id;
         ReportRelationId = reportToUserEntity.Id;
     }
 }
 public void TestUserInfoModelByRoleName()
 {
     var insertEntity = new UserInfoModel { UserName = "******", UserDisplayName = "UserDisplayName",Password = "******",CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     using (var session = sessions.OpenSession())
     {
         session.Save(insertEntity);
         session.Flush();
         UserInfoModel entity = null;
         var resultList = session.CreateQuery("from UserInfoModel ").List<UserInfoModel>();
         if (resultList.Count > 0)
             entity = resultList.FirstOrDefault();
         ICriteria crit = session.CreateCriteria(typeof(UserInfoModel)).Add(Restrictions.Eq("UserName", entity.UserName));
         var result = crit.List<UserInfoModel>().First();
         Assert.AreEqual(result.UserName, entity.UserName);
     }
 }
        private UserInfoModel GetEntity()
        {
            var entity = new UserInfoModel
            {
                CreateDateTime = CreateDateTime,
                IsDelete = IsDelete,
                UserName = TxtUserName.Text,
                UserDisplayName = TxtUserDisplayName.Text,
                Password = PbPassword.Password,
                Id = Id,
                LastUpdateDateTime = DateTime.Now
            };

            return entity;
        }