コード例 #1
0
        public ResponseData AccountrRegirst(AccountRegirstDto accountRegirstDto)
        {
            AccountModel accountModel = accountRepository.FindEntity(c => c.AccountName == accountRegirstDto.AccountName);

            if (accountModel != null)
            {
                return(new ResponseData {
                    MsgCode = 400, Message = "账号已注册"
                });
            }
            else
            {
                IdentityUser identityUser = mapper.Map <AccountRegirstDto, IdentityUser>(accountRegirstDto);
                accountModel = this.mapper.Map <AccountRegirstDto, AccountModel>(accountRegirstDto);
                accountModel.AccountPasswdEncrypt = Md5Helper.MD5Encrypt64(accountRegirstDto.AccountPasswd);
                IDbContextTransaction dbContextTransaction = null;
                try
                {
                    using (dbContextTransaction = unitwork.BeginTransaction())
                    {
                        userRepository.Insert(identityUser);
                        accountRepository.Insert(accountModel);
                        dbContextTransaction.Commit();
                    }
                    return(new ResponseData {
                        MsgCode = 200, Message = "账号注册成功"
                    });
                }
                //aop异常日志记录
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                }
            }
            return(new ResponseData {
                MsgCode = 400, Message = "账号注册失败"
            });
        }
コード例 #2
0
 public ResponseData AccountRegirst([FromBody] AccountRegirstDto accountRegirstDto)
 {
     return(accountService.AccountrRegirst(accountRegirstDto));
 }