public async Task <GetListTransactionResponse> GetListTransactionAsync() { var response = new GetListTransactionResponse(); try { var listTransaction = await _context.Transactions.Take(20).OrderByDescending(t => t.TransDate).ToListAsync(); foreach (var transaction in listTransaction) { var acountItem = new ItemTransaction() { TransType = transaction.TransType, Amount = transaction.Amount, TransactionDate = transaction.TransDate, Status = transaction.Status, Fee = transaction.Fee }; response.Data.ListTransaction.Add(acountItem); } } catch (Exception ex) { response.Code = ErrorCode.GetError(ErrorCode.SystemError).Key; response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value; Logger.Error(ex); } return(await Task.FromResult(response)); }
public async Task <IActionResult> GetListTransaction() { var response = new GetListTransactionResponse(); try { response = await _accountQueries.GetListTransactionAsync(); } catch (Exception ex) { response.Code = ErrorCode.GetError(ErrorCode.SystemError).Key; response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value; Logger.Error($"Exception: {ex} , Method:getListtransaction"); } return(Ok(response)); }