Esempio n. 1
0
        public async void OnNavigatingTo(INavigationParameters parameters)
        {
            var data = await SpeakerService.GetAsync();

            Speakers.Clear();
            foreach (var item in data)
            {
                Speakers.Add(new Speaker
                {
                    Name          = item.Name,
                    Bio           = item.Bio,
                    HeadshotImage = item.PhotoLink,
                    Sessions      = item.Sessions.Select(x => new Session
                    {
                        Title        = x.Title,
                        Description  = x.Description,
                        IsFavorite   = false,
                        Room         = x.Room,
                        TimeSlot     = x.TimeSlot,
                        TimeSlotName = x.TimeSlotName,
                        Track        = x.Category.ToSessionTrack(),
                        Speaker      = new Speaker
                        {
                            Name          = item.Name,
                            HeadshotImage = item.PhotoLink
                        }
                    })
                });
            }
        }
        public async Task OnLoadAsync(INavigationParameters parameters, int attempt = 0)
        {
            try
            {
                var data = await SpeakerService.GetAsync();

                if (data == null)
                {
                    return;
                }

                Speakers.Clear();
                foreach (var item in data.OrderBy(x => x.Name))
                {
                    Speakers.Add(new Speaker
                    {
                        Name     = item.Name,
                        Bio      = item.Bio,
                        Headshot = ImageSource.FromStream(() => new MemoryStream(item.Photo)),
                        Sessions = item.Sessions.Select(x => new Session
                        {
                            Title        = x.Title,
                            Description  = x.Description,
                            IsFavorite   = false,
                            Room         = x.Room,
                            TimeSlot     = x.TimeSlot,
                            Day          = x.Day,
                            TimeSlotName = x.TimeSlotName,
                            Track        = x.Category.ToSessionTrack(),
                            Speakers     = x.Speakers.Select(s => new Speaker
                            {
                                Name     = s.Name,
                                Headshot = ImageSource.FromStream(() => new MemoryStream(s.Photo))
                            })
                        })
                    });
                }
            }
            catch (Exception)
            {
                await ErrorRetryManager.HandleRetryAsync(this, parameters, attempt);
            }
        }