/// <summary> /// Load and add more items for a category (News, Projects, Conferences or Shows) /// </summary> /// <param name="category">Category name</param> private async Task LoadMoreItemsAsync(string category) { IsLoading = true; int i = Menu.Groups.TakeWhile(g => g.Title != category).Count(); IList <VisualGenericItem> alreadyLoaded = Menu.Groups[i].Items; IList <VisualGenericItem> newElements = new ObservableCollection <VisualGenericItem>(); switch (i) { case 0: IEnumerable <News> news = await _modelNews.GetAsync(alreadyLoaded.Count, 8); IMapper <News> mapperNews = new GenericNewsMapper(); newElements = mapperNews.Map(news); break; case 2: IEnumerable <Project> projets = await _modelProject.GetAsync(alreadyLoaded.Count, 8); IMapper <Project> mapperProjects = new GenericProjectMapper(); newElements = mapperProjects.Map(projets); break; case 3: IEnumerable <Conference> conferences = await _modelConference.GetAsync(alreadyLoaded.Count, 8); IMapper <Conference> mapperConferences = new GenericConferenceMapper(); newElements = mapperConferences.Map(conferences); break; case 4: IEnumerable <Show> salons = await _modelShow.GetAsync(alreadyLoaded.Count, 8); IMapper <Show> mapperShows = new GenericShowMapper(); newElements = mapperShows.Map(salons); break; } // If the list contains less of 8 items, so the list is fully loaded if (newElements.Count < 8) { Menu.Groups[i].IsFullyLoaded = true; } // Concatenation of new elements and old elements Menu.Groups[i].Items = new ObservableCollection <VisualGenericItem>(alreadyLoaded.Concat(newElements)); IsLoading = false; }
/// <summary> /// Search in shows /// </summary> private async Task SearchShowsAsync() { IsLoading = true; IList <Show> salons = await _modelShows.SearchAsync(Keywords); if (salons != null && salons.Count > 0) { IMapper <Show> mapper = new GenericShowMapper(); IList <VisualGenericItem> genericShow = mapper.Map(salons); Results.Groups.Insert(Results.Groups.Count, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_SALONS"), Items = new ObservableCollection <VisualGenericItem>(genericShow), IsFullyLoaded = true }); } IsLoading = false; }
/// <summary> /// Load the shows list from the model /// </summary> private async Task LoadShowsAsync() { IsLoading = true; IEnumerable <Show> salons = await _modelShow.GetAsync(0, 8); if (salons != null) { IMapper <Show> mapper = new GenericShowMapper(); IList <VisualGenericItem> genericShows = mapper.Map(salons); Menu.Groups.RemoveAt(4); Menu.Groups.Insert(4, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_SALONS"), Items = new ObservableCollection <VisualGenericItem>(genericShows), IsFullyLoaded = genericShows.Count < 8 }); } IsLoading = false; }
/// <summary> /// Search in shows /// </summary> private async Task SearchShowsAsync() { IsLoading = true; IList<Show> salons = await _modelShows.SearchAsync(Keywords); if (salons != null && salons.Count > 0) { IMapper<Show> mapper = new GenericShowMapper(); IList<VisualGenericItem> genericShow = mapper.Map(salons); Results.Groups.Insert(Results.Groups.Count, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_SALONS"), Items = new ObservableCollection<VisualGenericItem>(genericShow), IsFullyLoaded = true }); } IsLoading = false; }
/// <summary> /// Load and add more items for a category (News, Projects, Conferences or Shows) /// </summary> /// <param name="category">Category name</param> private async Task LoadMoreItemsAsync(string category) { IsLoading = true; int i = Menu.Groups.TakeWhile(g => g.Title != category).Count(); IList<VisualGenericItem> alreadyLoaded = Menu.Groups[i].Items; IList<VisualGenericItem> newElements = new ObservableCollection<VisualGenericItem>(); switch (i) { case 0: IEnumerable<News> news = await _modelNews.GetAsync(alreadyLoaded.Count, 8); IMapper<News> mapperNews = new GenericNewsMapper(); newElements = mapperNews.Map(news); break; case 2: IEnumerable<Project> projets = await _modelProject.GetAsync(alreadyLoaded.Count, 8); IMapper<Project> mapperProjects = new GenericProjectMapper(); newElements = mapperProjects.Map(projets); break; case 3: IEnumerable<Conference> conferences = await _modelConference.GetAsync(alreadyLoaded.Count, 8); IMapper<Conference> mapperConferences = new GenericConferenceMapper(); newElements = mapperConferences.Map(conferences); break; case 4: IEnumerable<Show> salons = await _modelShow.GetAsync(alreadyLoaded.Count, 8); IMapper<Show> mapperShows = new GenericShowMapper(); newElements = mapperShows.Map(salons); break; } // If the list contains less of 8 items, so the list is fully loaded if (newElements.Count < 8) { Menu.Groups[i].IsFullyLoaded = true; } // Concatenation of new elements and old elements Menu.Groups[i].Items = new ObservableCollection<VisualGenericItem>(alreadyLoaded.Concat(newElements)); IsLoading = false; }
/// <summary> /// Load the shows list from the model /// </summary> private async Task LoadShowsAsync() { IsLoading = true; IEnumerable<Show> salons = await _modelShow.GetAsync(0, 8); if (salons != null) { IMapper<Show> mapper = new GenericShowMapper(); IList<VisualGenericItem> genericShows = mapper.Map(salons); Menu.Groups.RemoveAt(4); Menu.Groups.Insert(4, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_SALONS"), Items = new ObservableCollection<VisualGenericItem>(genericShows), IsFullyLoaded = genericShows.Count < 8 }); } IsLoading = false; }