Esempio n. 1
0
 /// <summary>
 /// 保存用户
 /// </summary>
 /// <param name="user">用户实体</param>
 /// <returns></returns>
 public User SaveUser(User user)
 {
     Validate(user);
     if (GetUser(user.UserID) != null)
         throw new  Exception("已经存在的用户");
     return  UserDao.Save(user);
 }
Esempio n. 2
0
 public IList GetByCondition(User user)
 {
     ArrayList param = new ArrayList();
     string queryStr =  "from User t where 1=1";
     if (user.UserID != "")
     {
         queryStr += " and t.UserID=?";
         param.Add(user.UserID);
     }
     if (user.UserName != "")
     {
         queryStr += " and t.UserName like ?";
         param.Add("%"+user.UserName+"%");
     }
     if (user.Role != null)
     {
         queryStr += " and t.Role=?";
         param.Add(user.Role.RoleId);
     }
     if (user.Department != null)
     {
         queryStr += " and t.Department=?";
         param.Add(user.Department.DepartmentID);
     }
     return HibernateTemplate.Find(queryStr ,param .ToArray () );
 }
Esempio n. 3
0
 public void SaveUserTest()
 {
     User user = new User();
     user.UserID = "buyer000";
     user.Password = "******";
     user.UserName = "******";
     UserDao.Save(user);
     transactionManager.Commit(transactionStatus);
 }
Esempio n. 4
0
 public static User MapFromDTO(UserDTO dto)
 {
     User user = new User();
     user.UserID = dto.UserID;
     user.UserName = dto.UserName;
     user.Department = dto.DepartmentID == null? null:ManagerFactory.DepartmentManager.GetDepartment(dto.DepartmentID);
     user.Role = dto.RoleId == null ? null : ManagerFactory.RoleManager.GetRole(dto.RoleId);
     return user;
 }
Esempio n. 5
0
 public static UserDTO MapToDTO(User  model )
 {
     UserDTO dto = new UserDTO();
     dto.UserID = model.UserID;
     dto.UserName = model.UserName;
     dto.DepartmentID = model.Department == null ? "" : model.Department.DepartmentID;
     dto.DepartmentName = model.Department == null ? "" : model.Department.DepartmentName;
     dto.RoleId = model.Role == null ? "" : model.Role.RoleId;
     dto.RoleName = model.Role == null ? "" : model.Role.RoleName;
     return dto;
 }
Esempio n. 6
0
 public User SaveOrUpdate(User user)
 {
     HibernateTemplate.SaveOrUpdate(user);
     return user;
 }
Esempio n. 7
0
 public void Delete(User user)
 {
     HibernateTemplate.Delete(user);
 }
Esempio n. 8
0
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="user">用户实体</param>
 /// <returns></returns>
 public User UpdateUser(User user)
 {
     return UserDao.SaveOrUpdate(user);
 }
Esempio n. 9
0
        /// <summary>
        /// 创建一个用户(返回包含默认值)
        /// </summary>
        /// <returns></returns>
        public User NewUser()
        {
            var user = new User();

            return user;
        }
Esempio n. 10
0
 /// <summary>
 /// 获取用户
 /// </summary>
 /// <returns></returns>
 public IList GetByCondition(User user)
 {
     return UserDao.GetByCondition(user);
 }
Esempio n. 11
0
 private void Validate(User  user)
 {
     //TODO throw exception on error.
 }