示例#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);
     }
 }