Пример #1
0
        public Task <GetListAccountResponse> GetListAccount()
        {
            var response = new GetListAccountResponse();

            try
            {
                var listAccount = (from p in _context.WalletType
                                   join c in _context.Wallets
                                   on p.WalletTypeId equals c.WalletTypeId
                                   select new
                {
                    AccountType = p.WalletTypeName,
                    Balance = c.Balance,
                }).ToListAsync().Result;
                foreach (var account in listAccount)
                {
                    var acountItem = new AcountItem()
                    {
                        AccountType = account.AccountType,
                        Balance     = account.Balance
                    };

                    response.Data.ListAccount.Add(acountItem);
                }
            }
            catch (Exception ex)
            {
                response.Code    = ErrorCode.GetError(ErrorCode.SystemError).Key;
                response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value;
                Logger.Error(ex);
            }
            return(Task.FromResult(response));
        }
Пример #2
0
        public async Task <IActionResult> GetListAccount()
        {
            var response = new GetListAccountResponse();

            try
            {
                response = await _accountQueries.GetListAccount();
            }
            catch (Exception ex)
            {
                response.Code    = ErrorCode.GetError(ErrorCode.SystemError).Key;
                response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value;
                Logger.Error($"Exception: {ex} , Method:GetListAccount");
            }
            return(Ok(response));
        }