/// <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 news /// </summary> private async Task SearchNewsAsync() { IsLoading = true; IList <News> news = await _modelNews.SearchAsync(Keywords); if (news != null && news.Count > 0) { IMapper <News> mapper = new GenericNewsMapper(); IList <VisualGenericItem> genericNews = mapper.Map(news); Results.Groups.Insert(Results.Groups.Count, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_NEWS"), Items = new ObservableCollection <VisualGenericItem>(genericNews), IsFullyLoaded = true }); } IsLoading = false; }
/// <summary> /// Load the news list from the model /// </summary> private async Task LoadNewsAsync() { IsLoading = true; IEnumerable <News> news = await _modelNews.GetAsync(0, 8); if (news != null) { IMapper <News> mapper = new GenericNewsMapper(); IList <VisualGenericItem> genericNews = mapper.Map(news); Menu.Groups.RemoveAt(0); Menu.Groups.Insert(0, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_NEWS"), Items = new ObservableCollection <VisualGenericItem>(genericNews), IsFullyLoaded = genericNews.Count < 8 }); } IsLoading = false; }
/// <summary> /// Search in news /// </summary> private async Task SearchNewsAsync() { IsLoading = true; IList<News> news = await _modelNews.SearchAsync(Keywords); if (news != null && news.Count > 0) { IMapper<News> mapper = new GenericNewsMapper(); IList<VisualGenericItem> genericNews = mapper.Map(news); Results.Groups.Insert(Results.Groups.Count, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_NEWS"), Items = new ObservableCollection<VisualGenericItem>(genericNews), 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 news list from the model /// </summary> private async Task LoadNewsAsync() { IsLoading = true; IEnumerable<News> news = await _modelNews.GetAsync(0, 8); if (news != null) { IMapper<News> mapper = new GenericNewsMapper(); IList<VisualGenericItem> genericNews = mapper.Map(news); Menu.Groups.RemoveAt(0); Menu.Groups.Insert(0, new VisualGenericGroup { Title = AppResourcesHelper.GetString("LBL_NEWS"), Items = new ObservableCollection<VisualGenericItem>(genericNews), IsFullyLoaded = genericNews.Count < 8 }); } IsLoading = false; }