Esempio n. 1
0
        void ExecuteDeleteUserCommand(MemberViewModel member)
        {
            if (member.NewUserId == 0)
            {
                messageDialog.SendToast("RSVPs can't be removed.");
                return;
            }
            var id    = member.NewUserId;
            var index = Members.FirstOrDefault(m => m.NewUserId == id);

            if (index == null)
            {
                return;
            }

            messageDialog.SendConfirmation("Are you sure you want to remove: " + member.Name, "Remove?",
                                           confirmation =>
            {
                if (!confirmation)
                {
                    return;
                }

                dataService.RemoveNewMember(id);

                //TODO: Begin Invoke On Main Thread
                Members.Remove(member);
                RefreshCount();
                Members = members;
            });
        }
Esempio n. 2
0
        async Task ExecuteCheckInCommand(MemberViewModel member)
        {
            if (member.Member.MemberId == -1)
            {
                messageDialog.SendToast("Only new members can be removed.");
                return;
            }
            if (member.CheckedIn)
            {
                await dataService.CheckOutMember(eventId, member.Member.MemberId.ToString());
            }
            else
            {
                await dataService.CheckInMember(new EventRSVP(eventId, member.Member.MemberId.ToString(), eventName, groupId, GroupName, EventDate));
            }

            member.CheckedIn = !member.CheckedIn;

            RefreshCount();

            if (member.CheckedIn && !string.IsNullOrWhiteSpace(member.Guests))
            {
                messageDialog.SendConfirmation("Would you like to check in your guests now? You can always check them in later by hitting the add button above.",
                                               "Check-in guests",
                                               (yes) =>
                {
                    if (yes)
                    {
                        ExecuteAddNewUserCommand();
                    }
                });
            }
        }
Esempio n. 3
0
        async Task ExecuteSaveUserCommand(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                messageDialog.SendToast("Please enter a valid name to check-in.");
            }
            else
            {
                var newMember = new NewMember(eventId, name, eventName, groupId, GroupName, EventDate);
                await dataService.AddNewMember(newMember);

                var member = new MemberViewModel(new Member {
                    MemberId = -1, Name = name
                },
                                                 null, eventId, eventName, groupId, GroupName, EventDate);

                member.CheckedIn = true;
                member.NewUserId = newMember.Id;
                Members.Add(member);
                RefreshCount();
                messageDialog.SendMessage(name + " you are all set!");
            }
        }
Esempio n. 4
0
        protected override async Task ExecuteLoadMoreCommand()
        {
            if (!CanLoadMore || IsBusy)
            {
                return;
            }

            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(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(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 e)
            {
                if (Settings.Insights)
                {
                    Xamarin.Insights.Report(e);
                }
                CanLoadMore = false;
                messageDialog.SendToast("Unable to get RSVPs please refresh or log in again.");
            }
            finally
            {
                FinishedLoad?.Invoke();
                FinishedFirstLoad?.Invoke(index);
                IsBusy = false;
            }
        }