public override async Task <IEnumerable <Workshop> > GetItemsAsync(bool forceRefresh = false) { var workshops = await GetWorkshops(forceRefresh); if (!workshops.Any()) { workshops = await GetWorkshops(true); } await _favoriteStore.GetItemsAsync(true).ConfigureAwait(false);//pull latest foreach (var workshop in workshops) { var isFav = await _favoriteStore.IsFavoriteWorkshop(workshop.Id).ConfigureAwait(false); workshop.IsFavorite = isFav; } return(workshops); }
public async override Task InitializeStore() { if (initialized) { return; } initialized = true; var categories = (await _categoryStore.GetItemsAsync()).ToArray(); var speakers = (await _speakerStore.GetItemsAsync().ConfigureAwait(false)).ToArray(); workshops = new List <Workshop>(); int speaker = 0; int speakerCount = 0; int room = 0; int category = 0; var day = new DateTime(2016, 4, 27, 13, 0, 0, DateTimeKind.Utc); int dayCount = 0; for (int i = 0; i < titles.Length; i++) { var workshopSpeakers = new List <Speaker>(); speakerCount++; for (int j = 0; j < speakerCount; j++) { workshopSpeakers.Add(speakers[speaker]); speaker++; if (speaker >= speakers.Length) { speaker = 0; } } if (i == 1) { workshopSpeakers.Add(workshops[0].Speakers.ElementAt(0)); } var cat = categories[category]; category++; if (category >= categories.Length) { category = 0; } var ro = rooms[room]; room++; if (room >= rooms.Length) { room = 0; } workshops.Add(new Workshop { Id = i.ToString(), Abstract = "This is an abstract that is going to tell us all about how awsome this workshop is and that you should go over there right now and get ready for awesome!.", MainCategory = cat, Room = ro, Speakers = workshopSpeakers, Title = titles[i], ShortTitle = titlesShort[i] }); workshops[i].IsFavorite = await _favoriteStore.IsFavoriteWorkshop(workshops[i].Id); workshops[i].FeedbackLeft = await _feedbackStore.LeftFeedback(workshops[i]); SetStartEnd(workshops[i], day); if (i == titles.Length / 2) { dayCount = 0; day = new DateTime(2016, 4, 28, 13, 0, 0, DateTimeKind.Utc); } else { dayCount++; if (dayCount == 2) { day = day.AddHours(1); dayCount = 0; } } if (speakerCount > 2) { speakerCount = 0; } } workshops.Add(new Workshop { Id = workshops.Count.ToString(), Abstract = "Coming soon", MainCategory = categories[0], Room = rooms[0], //Speakers = new List<Speaker>{ speakers[0] }, Title = "Something awesome!", ShortTitle = "Awesome", }); workshops[workshops.Count - 1].IsFavorite = await _favoriteStore.IsFavoriteWorkshop(workshops[workshops.Count - 1].Id); workshops[workshops.Count - 1].FeedbackLeft = await _feedbackStore.LeftFeedback(workshops[workshops.Count - 1]); workshops[workshops.Count - 1].StartTime = null; workshops[workshops.Count - 1].EndTime = null; }