public async Task<List<string>> GetTrackUrl(TrackSocialInfo tracks, string provider) { string accessToken; if (AzimuthIdentity.Current == null || AzimuthIdentity.Current.UserCredential.SocialNetworkName != "Vkontakte") { using (var unitOfWork = _unitOfWorkFactory.NewUnitOfWork()) { var id = unitOfWork.UserRepository.Get(user => user.ScreenName == "id268940215" && user.Name.FirstName == "Azimuth" && user.Name.LastName == "Azimuth").FirstOrDefault().Id; var admin = unitOfWork.UserRepository.GetFullUserData(id); accessToken = admin.SocialNetworks.FirstOrDefault(sn => sn.SocialNetwork.Name == "Vkontakte").AccessToken; unitOfWork.Commit(); } } else { using (var unitOfWork = _unitOfWorkFactory.NewUnitOfWork()) { accessToken = GetSocialNetworkData(unitOfWork, provider).AccessToken; unitOfWork.Commit(); } } _socialNetworkApi = SocialNetworkApiFactory.GetSocialNetworkApi(provider); return await _socialNetworkApi.GetTrackUrl(tracks, accessToken); }
public async Task<List<string>> GetTrackUrl(TrackSocialInfo tracks, string accessToken) { var url = tracks.Tracks.Aggregate(BaseUri + "audio.getById?audios=", (current, trackSocialInfo) => current + (trackSocialInfo.OwnerId + "_" + trackSocialInfo.ThirdPartId + ",")); url = url.Remove(url.Length - 1); url += "&access_token=" + accessToken; var trackJson = await _webClient.GetWebData(url); var track = JsonConvert.DeserializeObject<VkTrackResponse>(trackJson).Response.Select(list => list.Url).ToList(); return track; }