Esempio n. 1
0
        public override async Task <IEnumerable <Session> > GetItemsAsync(bool forceRefresh = false)
        {
            var sessions = await GetSessions(forceRefresh);

            if (!sessions.Any())
            {
                sessions = await GetSessions(true);
            }
            await _favoriteStore.GetItemsAsync(true).ConfigureAwait(false);//pull latest

            foreach (var session in sessions)
            {
                var isFav = await _favoriteStore.IsFavorite(session.Id).ConfigureAwait(false);

                session.IsFavorite = isFav;
            }

            return(sessions);
        }
Esempio n. 2
0
        public async override Task InitializeStore()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;
            var categories = (await categoryStore.GetItemsAsync()).ToArray();
            await speakerStore.InitializeStore();

            var speakers = (await speakerStore.GetItemsAsync().ConfigureAwait(false)).ToArray();

            sessions = new List <Session>();
            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 sessionSpeakers = new List <Speaker>();
                speakerCount++;

                for (int j = 0; j < speakerCount; j++)
                {
                    sessionSpeakers.Add(speakers[speaker]);
                    speaker++;
                    if (speaker >= speakers.Length)
                    {
                        speaker = 0;
                    }
                }

                if (i == 1)
                {
                    sessionSpeakers.Add(sessions[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;
                }

                sessions.Add(new Session
                {
                    Id           = i.ToString(),
                    Abstract     = "This is an abstract that is going to tell us all about how awsome this session is and that you should go over there right now and get ready for awesome!.",
                    MainCategory = cat,
                    Room         = ro,
                    Speakers     = sessionSpeakers,
                    Title        = titles[i],
                    ShortTitle   = titlesShort[i],
                    RemoteId     = i.ToString()
                });

                sessions[i].IsFavorite = await favoriteStore.IsFavorite(sessions[i].Id);

                sessions[i].FeedbackLeft = await feedbackStore.LeftFeedback(sessions[i]);

                SetStartEnd(sessions[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;
                }
            }


            sessions.Add(new Session
            {
                Id           = sessions.Count.ToString(),
                Abstract     = "Coming soon",
                MainCategory = categories[0],
                Room         = rooms[0],
                //Speakers = new List<Speaker>{ speakers[0] },
                Title      = "http://rdgw.kaizen.massopencloud.org/swift/v1/Harry/pics/16602385_1413398652043672_4820266781039836011_o.jpg",
                ShortTitle = "Awesome",
            });
            sessions[sessions.Count - 1].IsFavorite = await favoriteStore.IsFavorite(sessions[sessions.Count - 1].Id);

            sessions[sessions.Count - 1].FeedbackLeft = await feedbackStore.LeftFeedback(sessions[sessions.Count - 1]);

            sessions[sessions.Count - 1].StartTime = null;
            sessions[sessions.Count - 1].EndTime   = null;
        }