Exemplo n.º 1
0
        private async Task <ExecutionResult <IEnumerable <TransactionModel> > > GetAllUserTransactions(Uri allUserTransactionsUrl)
        {
            var result = new ExecutionResult <IEnumerable <TransactionModel> >
            {
                IsSuccess = false
            };

            IEnumerable <TransactionData> userTransactionsData = null;

            await _executor.ExecuteWithRetryAsync((async() =>
            {
                userTransactionsData = await _queryApiService.GetAsync <IEnumerable <TransactionData> >(allUserTransactionsUrl);
            }));

            if (userTransactionsData == null)
            {
                return(result);
            }

            result.Result =
                userTransactionsData.Select(x => _mapper.ConvertTransactioDataToTransactionModel(x)).ToList();

            result.IsSuccess = true;
            return(result);
        }
Exemplo n.º 2
0
        public async Task <ExecutionResult <IEnumerable <UserModel> > > SearchUsersAsync(string query)
        {
            var result = new ExecutionResult <IEnumerable <UserModel> >
            {
                IsSuccess = false
            };

            var searchUsersUrl = _apiUrlBuilder.SearchUsers(query);

            IEnumerable <UserData> usersData = null;

            await _executor.ExecuteWithRetryAsync(async() =>
            {
                usersData = await _queryApiService.GetAsync <IEnumerable <UserData> >(searchUsersUrl);
            });

            if (usersData == null)
            {
                return(result);
            }

            return(new ExecutionResult <IEnumerable <UserModel> >
            {
                IsSuccess = true,
                Result = usersData.Select(x => _mapper.ConvertUserDataToUserModel(x)).ToList()
            });
        }
        public async Task <ExecutionResult <IEnumerable <UserModel> > > GetAllUserFriendsAsync()
        {
            var result = new ExecutionResult <IEnumerable <UserModel> >
            {
                IsSuccess = false
            };

            var allFriendsUrl = _apiUrlBuilder.AllFriends();

            IEnumerable <UserData> userFriendsData = null;

            await _executor.ExecuteWithRetryAsync(async() =>
            {
                userFriendsData = await _queryApiService.GetAsync <IEnumerable <UserData> >(allFriendsUrl);
            });

            if (userFriendsData == null)
            {
                return(result);
            }

            result.Result =
                userFriendsData.Select(x => _mapper.ConvertUserDataToUserModel(x)).ToList();

            result.IsSuccess = true;

            return(result);
        }