コード例 #1
0
ファイル: ErpStaffService.cs プロジェクト: xman086/SoaProJect
        /// <summary>
        /// 修改登录密码
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > ModifyLoginPwdAsync(StaffModifyPwdParm parm)
        {
            var res = new ApiResult <string>()
            {
                data = "1", statusCode = (int)ApiEnum.ParameterError
            };

            try
            {
                //判断原密码是否正确
                parm.HistoryPwd = DES3Encrypt.EncryptString(parm.HistoryPwd);
                var isExt = ErpStaffDb.IsAny(m => m.LoginPwd == parm.HistoryPwd && m.Guid == parm.Guid);
                if (!isExt)
                {
                    res.message = "原密码输入错误~";
                    return(await Task.Run(() => res));
                }
                //开始修改新密码
                parm.NewPwd = DES3Encrypt.EncryptString(parm.NewPwd);
                ErpStaffDb.Update(m => new ErpStaff()
                {
                    LoginPwd = parm.NewPwd
                }, m => m.Guid == parm.Guid);
                res.statusCode = (int)ApiEnum.Status;
            }
            catch (Exception ex)
            {
                res.statusCode = (int)ApiEnum.Error;
                res.message    = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }
コード例 #2
0
ファイル: ErpStaffService.cs プロジェクト: xman086/SoaProJect
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > AddAsync(ErpStaff parm)
        {
            var res = new ApiResult <string>()
            {
                data = "1", statusCode = 200
            };

            try
            {
                //判断登录账号
                var isExt = ErpStaffDb.IsAny(m => m.LoginName == parm.LoginName);
                if (isExt)
                {
                    res.statusCode = (int)ApiEnum.ParameterError;
                    res.message    = "该登录账号已存在~";
                }
                else
                {
                    parm.LoginPwd = DES3Encrypt.EncryptString(parm.LoginPwd);
                    parm.Guid     = Guid.NewGuid().ToString();
                    var dbres = ErpStaffDb.Insert(parm);
                    if (!dbres)
                    {
                        res.statusCode = (int)ApiEnum.Error;
                        res.message    = "插入数据失败~";
                    }
                }
            }
            catch (Exception ex)
            {
                res.statusCode = (int)ApiEnum.Error;
                res.message    = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }