コード例 #1
0
        public async Task <IEnumerable <TransactionsDTO> > GetTransactionsAsync()
        {
            IEnumerable <Transactions> transactions = null;

            using (var client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    transactions = await response.Content.ReadAsAsync <IEnumerable <Transactions> >();

                    await repository.DeleteAllTransactionsAsync();

                    await repository.AddTransactionsAsync(transactions);
                }
                else
                {
                    transactions = await repository.GetTransactionsAsync();
                }
            }
            return(mapper.Map <IEnumerable <TransactionsDTO> >(transactions));
        }