Exemplo n.º 1
0
    public async Task <AtriumTransactionsVM> GetTransactionsByUserId(string userId, string atriumUserId, int page)
    {
        try
        {
            using (var atrium = AtriumHttpClient())
            {
                AtriumUserGetRequest user = new AtriumUserGetRequest();
                user.user = new AtriumUserGetRequest.UserObj();
                HttpResponseMessage response = await atrium.GetAsync("/users/" + atriumUserId + "/transactions?page=" + page.ToString());

                if (response.IsSuccessStatusCode)
                {
                    var transactions = await Deserialize <AtriumTransactionsVM>(response);

                    if (transactions.Transactions != null)
                    {
                        SyncTransaction(transactions.Transactions, userId);
                    }
                    AtriumTransactionsVM transactionsFromDb = GetTransactionsFromDb(userId, page, null);
                    transactionsFromDb.Pagination = new AtriumPagination();
                    transactionsFromDb.Pagination = transactions.Pagination;
                    return(transactionsFromDb);
                }
                else
                {
                    Exception ex = new Exception(response.ReasonPhrase);
                    throw ex;
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 2
0
    private AtriumTransactionsVM GetTransactionsFromDb(string userId, int page, string bankAccountId = null)
    {
        AtriumTransactionsVM list = new AtriumTransactionsVM();

        list.Transactions = new List <TransactionObj>();
        DataProvider.ExecuteCmd(GetConnection, "dbo.AtriumTransactions_GetByUserId"
                                , inputParamMapper : delegate(SqlParameterCollection paramCollection) {
            paramCollection.AddWithValue("@UserId", userId);
            paramCollection.AddWithValue("@Page", page);
            paramCollection.AddWithValue("@BankAccountId", bankAccountId);
        }
                                , map : delegate(IDataReader reader, short set)
        {
            TransactionObj p = new TransactionObj();
            p = MapTransactions(reader);
            if (list.Transactions == null)
            {
                list.Transactions = new List <TransactionObj>();
            }
            list.Transactions.Add(p);
        }
                                );
        return(list);
    }