Example #1
0
 //LienThong
 private async Task <LienThongInfoSettingDto> GetLienThongInfoSettingsAsync()
 {
     try
     {
         return(await _tenantSettingsDomain.GetLienThongInfoSettingsAsync(AbpSession.GetTenantId()));
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         return(null);
     }
 }
Example #2
0
        public async Task <ResultApi> CallApi(int chiCucId, string dataJson, string api, string token = "")
        {
            try
            {
                var _lienThongSettings = await _tenantSettingsr.GetLienThongInfoSettingsAsync(chiCucId);

                if (_lienThongSettings != null && !string.IsNullOrEmpty(_lienThongSettings.DomainLienThong))
                {
                    ResultApi obj = new ResultApi();
                    using (var client = new HttpClient())
                    {
                        string domain = _lienThongSettings.DomainLienThong;

                        client.BaseAddress = new Uri(domain);
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                        HttpContent content = new StringContent(dataJson, Encoding.UTF8, "application/json");
                        var         messge  = await client.PostAsync(api, content);

                        if (messge.IsSuccessStatusCode)
                        {
                            string result = await messge.Content.ReadAsStringAsync();

                            obj = JsonConvert.DeserializeObject <ResultApi>(result);
                            return(obj);
                        }
                    }
                    obj.Success = false;
                    return(obj);
                }
                return(null);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                return(null);
            }
        }