예제 #1
0
        /// <summary>
        /// 添加学生用户
        /// </summary>
        public ServiceInvokeDTO AddUser(User user)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                // 检测电话号码
                User dbUserWithPhone = userDAL.GetByPhone(user.Phone);
                if (dbUserWithPhone == null)
                {
                    user.Password = SecurityUtil.MD5(SecurityUtil.MD5(user.Phone) + Constant.USER_SALT_KEY);
                    userDAL.Insert(user);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
                else
                {
                    result = new ServiceInvokeDTO(InvokeCode.ACCOUNT_USER_PHONE_EXIST_ERROR);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
예제 #2
0
파일: UserDTO.cs 프로젝트: yienit/KST
 public UserDTO(User user)
 {
     this.ID = user.ID;
     this.AgencyID = user.AgencyID;
     this.ChineseName = user.ChineseName;
     this.Phone = user.Phone;
     this.Email = user.Email;
     this.Avatar = user.Avatar;
     this.State = user.State;
     this.IsVip = user.IsVip;
     this.AddTime = user.AddTime;
 }
예제 #3
0
파일: UserDTO.cs 프로젝트: yienit/KST
 public UserDTO(User user, Agency agency)
     : this(user)
 {
     this.Agency = agency;
 }
예제 #4
0
        /// <summary>
        /// 更新学生用户
        /// </summary>
        public ServiceInvokeDTO UpdateUser(User user)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                User dbUserWithPhone = userDAL.GetByPhone(user.Phone);
                if (dbUserWithPhone != null && dbUserWithPhone.ID != user.ID)
                {
                    result = new ServiceInvokeDTO(InvokeCode.ACCOUNT_USER_PHONE_EXIST_ERROR);
                }
                else
                {
                    userDAL.Update(user);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
예제 #5
0
파일: UserDAL.cs 프로젝트: yienit/KST
        /// <summary>
        /// 添加实体信息,返回添加成功后的主键ID
        /// </summary>
        public int Insert(User user)
        {
            int id = 0;

            const string sql = @"INSERT INTO User(AgencyID, ChineseName, Phone, Password, IsVip, AddPerson)
                               VALUES (@AgencyID, @ChineseName, @Phone, @Password, @IsVip, @AddPerson);
                               SELECT LAST_INSERT_ID();";
            using (DbConnection connection = ConnectionManager.OpenConnection)
            {
                id = connection.Query<int>(sql, user).SingleOrDefault<int>();
            }
            return id;
        }
예제 #6
0
파일: UserDAL.cs 프로젝트: yienit/KST
 /// <summary>
 /// 更新实体信息
 /// </summary>
 public void Update(User user)
 {
     const string sql = @"UPDATE User SET ChineseName = @ChineseName, Phone= @Phone,
                        State= @State, IsVip= @IsVip WHERE IsDeleted = 0 AND ID = @ID";
     using (DbConnection connection = ConnectionManager.OpenConnection)
     {
         connection.Execute(sql, user);
     }
 }