Пример #1
0
        public async Task <IEnumerable <T> > GetAllAsync()
        {
            SetupApiAddress();
            var result = await _httpClientManager.GetAsync <IEnumerable <T> >(ApiEndPoint);

            return(result);
        }
Пример #2
0
        public async Task <(List <PlayerRespM>, ModelStateDictionary)> GetAllAsync(ModelStateDictionary modelStateDictionary)
        {
            (List <PlayerRespM> playerRespMs, string errorMessage) = await httpClientManager.GetAsync <List <PlayerRespM> >($"{endpointOptions?.Value.Endpoint}");

            if (!string.IsNullOrEmpty(errorMessage))
            {
                modelStateDictionary.AddModelError("Player", _Failed_ToGetPlayer);
            }

            return(playerRespMs, modelStateDictionary);
        }
Пример #3
0
        public async Task <(PaymentRespModel, ModelStateDictionary)> GetAsync(Guid paymentId, ModelStateDictionary modelStateDictionary)
        {
            (PaymentRespModel paymentRespModel, string errorMessage) = await httpClientManager.GetAsync <PaymentRespModel>($"{endpointOptions?.Value.Endpoint}{paymentId}");

            if (!string.IsNullOrEmpty(errorMessage))
            {
                modelStateDictionary.AddModelError("Payment", _Failed_ToGetPayment);
            }

            return(paymentRespModel, modelStateDictionary);
        }
Пример #4
0
        public async Task <IEnumerable <T> > GetAllAsync()
        {
            SetApiEndpointAddress();
            if (string.IsNullOrEmpty(ApiEndPoint))
            {
                throw new ApplicationException($"No endpoint is provided.");
            }
            var result = await _httpClientManager.GetAsync <IEnumerable <T> >(ApiEndPoint);

            return(result);
        }
        //{
        //    throw new NotImplementedException();
        //}

        public virtual IEnumerable <T> GetAll()
        {
            SetApiEndpointAddress();
            if (string.IsNullOrEmpty(ApiEndPoint))
            {
                throw new ApplicationException($"No endpoint is provided.");
            }

            var result = Task.Run(async() => await _httpClientManager.GetAsync <List <T> >(ApiEndPoint)).Result;

            return(result);
        }
Пример #6
0
        public async Task <UserRoleDTO> Get(EntityDto <Guid> input)
        {
            //string url = _config.GetValue<string>("App:IdentityServerAddress") + "api/users/";

            string url = _config["App:IdentityServerAddress"] + "api/users/";
            HttpResponseMessage response = await _client.GetAsync(new Uri(url + input.Id.ToString()));

            if (response.IsSuccessStatusCode)
            {
                using (HttpContent result = response.Content)
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    var createdUser = JsonConvert.DeserializeObject <UserRoleDTO>(responseBody);
                    return(createdUser);
                }
            }
            else
            {
                var result = response.Content.ReadAsStringAsync().Result;
                throw new UserFriendlyException(result);
            }
        }