예제 #1
0
        protected async override Task <HandleResult> HandleCoreAsync(AddRelAccountRequest reqObj)
        {
            var account = new RelAccount();

            account.AccountName = reqObj.AccountName;
            account.AccountNo   = reqObj.AccountNo;
            account.Platform    = reqObj.Platform;
            account.UID         = reqObj.UserId;

            int rowAffected = await _userRepo.AddRelAccountAsync(account);

            if (rowAffected > 0)
            {
                return(new HandleResult <long>
                {
                    Data = account.ID,
                    Msg = string.Empty,
                    State = HandleStates.Success
                });
            }

            return(new HandleResult
            {
                State = HandleStates.NoDataFound,
                Msg = "出了点问题,请稍后重试"
            });
        }
예제 #2
0
        public async Task <int> AddRelAccountAsync(RelAccount account)
        {
            using (var conn = _connProvider.GetConnection())
            {
                var sql = @"INSERT INTO RelAccounts (UID,Platform,AccountNo,AccountName)
                    VALUES (@UID,@Platform,@AccountNo,@AccountName);
                    select @@IDENTITY";

                var id = await conn.QueryFirstOrDefaultAsync <long>(sql, account);

                if (id != 0)
                {
                    account.ID = id;
                    return(1);
                }

                return(0);
            }
        }