コード例 #1
0
        protected override async Task ExecuteLoadMoreCommand()
        {
            if (!CanLoadMore || IsBusy)
            {
                return;
            }

            IsBusy = true;

            var index = Groups.Count == 0 ? 0 : Groups.Count - 1;

            try
            {
                var groupResults = await meetupService.GetGroups(Settings.UserId, groups.Count);

                foreach (var group in groupResults.Groups)
                {
                    if (group.GroupPhoto == null)
                    {
                        group.GroupPhoto = new GroupPhoto
                        {
                            PhotoId     = 0,
                            HighResLink = "http://refractored.com/default.png",
                            PhotoLink   = "http://refractored.com/default.png",
                            ThumbLink   = "http://refractored.com/default.png"
                        };
                    }
                    Groups.Add(group);
                }

                OnPropertyChanged("Groups");
                CanLoadMore = groupResults.Groups.Count == 100;

                if (Groups.Count == 0)
                {
                    messageDialog.SendToast("You do not have any groups.");
                }
            }
            catch (Exception e)
            {
                if (Settings.Insights)
                {
                    Xamarin.Insights.Report(e);
                }
            } finally
            {
                FinishedFirstLoad?.Invoke(index);
                FinishedLoad?.Invoke();
                IsBusy = false;
            }
        }
コード例 #2
0
        protected override async Task ExecuteLoadMoreCommand()
        {
            if (!CanLoadMore || IsBusy)
            {
                return;
            }

            IsBusy = true;
            var index = Events.Count == 0 ? 0 : Events.Count - 1;

            try
            {
                var eventResults = await meetupService.GetEvents(groupId, Events.Count);

                foreach (var e in eventResults.Events)
                {
                    Events.Add(e);
                }

                CanLoadMore = eventResults.Events.Count == 100;

                if (Events.Count == 0)
                {
                    messageDialog.SendToast("There are no events for this group.");
                }

                Sort();
            }
            catch (Exception e)
            {
                if (Settings.Insights)
                {
                    Xamarin.Insights.Report(e);
                }
            }
            finally
            {
                FinishedLoad?.Invoke();
                FinishedFirstLoad?.Invoke(index);
                IsBusy = false;
            }
        }
コード例 #3
0
ファイル: EventViewModel.cs プロジェクト: sk8tz/MeetupManager
        protected override async Task ExecuteLoadMoreCommand()
        {
            if (!CanLoadMore || IsBusy)
            {
                return;
            }

            //Go to database and check this user in.
            IsBusy = true;

            var index = Members.Count == 0 ? 0 : Members.Count - 1;

            try
            {
                var addNewMembers = Members.Count == 0;
                var eventResults  = await meetupService.GetRSVPs(eventId, members.Count);

                foreach (var e in eventResults.RSVPs)
                {
                    var member = new MemberViewModel(page, e.Member, e.MemberPhoto, eventId, eventName, groupId, GroupName, EventDate, e.Guests);

                    member.CheckedIn = await dataService.IsCheckedIn(eventId, member.Member.MemberId.ToString(), eventName, groupId, GroupName, EventDate);

                    members.Add(member);
                }

                CanLoadMore = eventResults.RSVPs.Count == 100;

                if (addNewMembers)
                {
                    var newMembers = await dataService.GetNewMembers(eventId);

                    foreach (var e in newMembers)
                    {
                        if (string.IsNullOrEmpty(e.GroupId))
                        {
                            e.GroupId   = groupId;
                            e.GroupName = GroupName;
                            e.EventName = eventName;
                            e.EventDate = EventDate;
                            e.EventId   = eventId;
                        }
                        var member = new MemberViewModel(page, new Member {
                            MemberId = -1, Name = e.Name
                        },
                                                         null, eventId, eventName, groupId, GroupName, EventDate);
                        member.NewUserId = e.Id;
                        member.CheckedIn = true;
                        members.Add(member);
                    }
                }



                RefreshCount();

                if (members.Count == 0)
                {
                    messageDialog.SendToast("No one has checked in yet.");
                }
            }
            catch (Exception ex)
            {
                if (Settings.Insights)
                {
                    Xamarin.Insights.Report(ex);
                }
                CanLoadMore = false;
                messageDialog.SendToast("Unable to get RSVPs please refresh or log in again.");
            }
            finally
            {
                FinishedFirstLoad?.Invoke(index);
                IsBusy = false;
            }
        }