private async Task <IEnumerable <YoutubeVideoModel> > GetItemsPageAsync(int page, int pageSize) { //TODO: network error handling var videos = await m_AnilibriaApiService.GetYoutubeVideosPage(page, pageSize); return(videos .Select( a => new YoutubeVideoModel { Id = a.Id, Comments = a.Comments, Timestamp = a.Timestamp, Views = a.Views, Title = a.Title, Image = m_AnilibriaApiService.GetUrl(a.Image), VideoUrl = new Uri("https://www.youtube.com/watch?v=" + a.VId) } )?.ToList() ?? Enumerable.Empty <YoutubeVideoModel> ()); }
/// <summary> /// Navigate to. /// </summary> /// <param name="parameter">Parameter.</param> public void NavigateTo(object parameter) { var collection = m_DataContext.GetCollection <CinemaHallReleaseEntity> (); m_ReleasesEntity = collection.FirstOrDefault(); if (m_ReleasesEntity == null) { m_ReleasesEntity = new CinemaHallReleaseEntity { Releases = new List <long> () }; collection.Add(m_ReleasesEntity); } IsEmptyList = !m_ReleasesEntity.Releases.Any(); var releasesCollection = m_DataContext.GetCollection <ReleaseEntity> (); var releases = releasesCollection.All(); var releasesDictionary = releases.ToDictionary(a => a.Id); var cinemaHallReleases = new List <CinemaHallReleaseModel> (); var iterator = -1; foreach (var releaseId in m_ReleasesEntity.Releases) { var releaseModel = releasesDictionary[releaseId]; cinemaHallReleases.Add( new CinemaHallReleaseModel { Title = releaseModel.Title, Description = releaseModel.Description, Order = iterator, Poster = m_AnilibriaApiService.GetUrl(releaseModel.Poster), ReleaseId = releaseModel.Id } ); } RefreshReleases(cinemaHallReleases); RaiseCommands(); m_AnalyticsService.TrackEvent("CinemaHallpage", "NavigatedTo", "Simple"); }
/// <summary> /// Change user session. /// </summary> public async Task ChangeUserSession() { try { if (m_AnilibriaApiService.IsAuthorized()) { var model = await m_AnilibriaApiService.GetUserData(); model.ImageUrl = m_AnilibriaApiService.GetUrl(model.Avatar); await RefreshFavorites?.Invoke(); UserModel = model; } } catch { m_AnilibriaApiService.ClearSession(); //paranoic mode: on RefreshOptions(); UserModel = null; } }
private ReleaseModel MapToReleaseModel(ReleaseEntity releaseEntity) { return(new ReleaseModel { Id = releaseEntity.Id, Title = releaseEntity.Title, CountVideoOnline = releaseEntity.Playlist?.Count() ?? 0, Poster = m_AnilibriaApiService.GetUrl(releaseEntity.Poster), OnlineVideos = releaseEntity.Playlist? .Select( a => new OnlineVideoModel { HDQuality = a.HD, Order = a.Id, SDQuality = a.SD, FullHDQuality = a.FullHD, Title = a.Title } ) .OrderBy(a => a.Order) .ToList() }); }