public async Task <ArtistWorkInfo> GetArtistWorkAsync(int id)
        {
            string         localStorageKey = LOCALSTORAGEKEY_ARTISTWORK_INFO + id;
            ArtistWorkInfo result          = await _localStorageService.GetItemAsync <ArtistWorkInfo>(localStorageKey);

            if (result == null)
            {
                ArtistWorkInfosRequest request = new ArtistWorkInfosRequest()
                {
                    ArtistWorkIds = new List <int>()
                    {
                        id
                    }
                };

                HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(_endpointAddress + "ArtistWorkInfos", request);

                string responseBody = await responseMessage.Content.ReadAsStringAsync();

                ArtistWorkInfoSource temp = JsonConvert.DeserializeObject <List <ArtistWorkInfoSource> >(responseBody)?.FirstOrDefault();
                result = new ArtistWorkInfo()
                {
                    ArtistInfo = await _radiocomArtistRepository.GetArtistAsync(temp.ArtistId),
                    Id         = temp.Id,
                    Name       = temp.Title
                };
                await _localStorageService.SetItemAsync <ArtistWorkInfo>(localStorageKey, result);
            }
            return(result);
        }
        public async Task <IEnumerable <IArtistWorkInfo> > GetArtistWorkInfosAsync(IEnumerable <int> ids)
        {
            List <IArtistWorkInfo> result = new List <IArtistWorkInfo>();

            using IDbConnection conn = await _dbConnectionFactory.GetConnection(_sqlRadiocomArtistWorkInfoRepositoryOptions.ConnectionString);

            foreach (int id in ids)
            {
                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.Add("ArtistWorkId", id, DbType.Int32);
                ArtistWorkInfo ArtistWorkInfo =
                    conn.QuerySingleOrDefault <ArtistWorkInfo>("SELECT * FROM dbo.ArtistWork WHERE Id = @ArtistWorkId;", dynamicParameters);
                if (ArtistWorkInfo != null)
                {
                    result.Add(ArtistWorkInfo);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
 public ArtistWorkDisplay(ArtistWorkInfo artistWorkInfo)
 {
     _artistWorkInfo = artistWorkInfo;
 }