/// <summary> /// Initializes a new instance of the WantedMoviesViewModel class. /// </summary> public ShowsViewModel(IShowService showsService) { // The data service _showsService = showsService; // Get all the movies and add them to the Movies collection Shows = new ObservableCollection<ShowViewModel>(); _showsService.GetShows((result, error) => { if (error != null) { MessageBox.Show(error.Message); return; } if (result == null) { MessageBox.Show("Nothing found"); return; } foreach (var show in result) { Shows.Add(new ShowViewModel(show)); } }); }
/// <summary> /// Метод получения списка избранных сериалов из базы даннных /// </summary> private async void GetFavoriteShows() { try { BusyIndicatorValue = true; IEnumerable <ShowDTO> favoriteShowsFromDb = _showService.GetShows(); List <int> showsId = new List <int>(); foreach (var item in favoriteShowsFromDb) { showsId.Add(item.ExternalId); } List <Show> favoriteShowsFromSite = new List <Show>(); foreach (var item in showsId) { Show show = await _dataService.GetDirectShowData(item); favoriteShowsFromSite.Add(show); } Shows = new ObservableCollection <Show>(favoriteShowsFromSite); BusyIndicatorValue = false; } catch (ServiceRequestException) { RaiseNotification(); } catch (Exception e) { _logger.ErrorException(ForExceptions, e); } }
public async Task <ActionResult <ICollection <ShowDto> > > Get(int page = 0, int pageSize = 25, CancellationToken cancellationToken = default(CancellationToken)) { try { // Prevent some odd numbers and set default if (page < 0) { page = 0; } if (pageSize < 1 || pageSize > 100) { pageSize = 25; } var shows = await _showService.GetShows(page, pageSize, cancellationToken); var mappedShows = _mapper.Map <ICollection <Show>, List <ShowDto> >(shows); // Order shows by birthday descending mappedShows?.ForEach(s => s.Cast = s.Cast.OrderByDescending(cast => cast.Birthday).ToList()); return(Ok(mappedShows)); } catch (Exception ex) { _logger.LogError(ex, "Could not read Shows from storage."); throw new Exception("Internal server error while trying to get the Shows."); } }
public IActionResult Get(ShowsStage stage, ShowsDay day, bool blipFormat = true) { List <Show> showList = _showService.GetShows(stage.GetDescription(), day.ToString()); if (blipFormat) { return(Ok(_carouselService.CreateCarouselWithAllShows(showList))); } else { return(Ok(showList)); } }
public IEnumerable <Show> GetShows([FromQuery] int pageNumber, [FromQuery] int pageSize) { return(_showService.GetShows(pageNumber, pageSize)); }
public IActionResult Home([FromQuery] int?page, [FromQuery] int?perPage) { var result = ShowService.GetShows(page ?? 0, perPage ?? 10); return(Ok(result)); }
public IEnumerable <Show> GetShows() { return(Show.GetShows()); }