Beispiel #1
0
        private async Task <List <SocialNetworkViewModel> > GetSocialNetwork()
        {
            if (_cache.TryGetValue($"{CacheParam.SocialNetwork}{CultureInfo.CurrentCulture.Name}", out List <SocialNetworkViewModel> socialNetwork))
            {
                return(Task.Run(() => socialNetwork).Result);
            }
            var requestUrl = _configuration.GetApiUrl();
            var apiService = _configuration.GetApiServiceInfo();

            //var result = new HttpClientService()
            //    .GetAsync<SearchResult<SocialNetworkViewModel>>($"{requestUrl.ApiGatewayUrl}/api/v1/website/social-networks/{apiService.TenantId}/alls");

            var result = await _socialNetworkService.SearchAsync(apiService.TenantId);

            var data = result.Select(x => new SocialNetworkViewModel
            {
                Icon  = x.Icon,
                Id    = x.Id,
                Image = x.Image,
                Name  = x.Name,
                Order = x.Order,
                Url   = x.Url
            }).ToList();

            _cache.Set($"{CacheParam.SocialNetwork}{CultureInfo.CurrentCulture.Name}", data, TimeSpan.FromMinutes(5));

            return(data);
        }
Beispiel #2
0
        private async Task <List <SocialNetworkViewModel> > GetSocialNetwork()
        {
            if (_cache.TryGetValue($"{CacheParam.SocialNetwork}{CultureInfo.CurrentCulture.Name}", out List <SocialNetworkViewModel> socialNetwork))
            {
                return(Task.Run(() => socialNetwork).Result);
            }

            var requestUrl = _configuration.GetApiUrl();
            var apiService = _configuration.GetApiServiceInfo();

            var result = await _socialNetworkService.SearchAsync(apiService.TenantId);

            var data = result.Select(x => new SocialNetworkViewModel
            {
                Icon  = x.Icon,
                Id    = x.Id,
                Image = x.Image,
                Name  = x.Name,
                Order = x.Order,
                Url   = x.Url
            }).ToList();

            _cache.Set($"{CacheParam.SocialNetwork}{CultureInfo.CurrentCulture.Name}", data, TimeSpan.FromHours(1));

            return(data);
        }
Beispiel #3
0
        public async Task <IActionResult> ClientSearch(string tenantId)
        {
            var result = await _socialNetworkService.SearchAsync(tenantId);

            return(Ok(result));
        }