Пример #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);
                Device.BeginInvokeOnMainThread(() =>
                {
                    Members.Remove(member);
                    RefreshCount();
                    Members = members;
                });
            });
        }
Пример #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();
                    }
                });
            }
        }
Пример #3
0
        private async Task ExecuteCheckInCommand(MemberViewModel member)
        {
            if (member.Member.MemberId == -1)
            {
                messageDialog.SendToast("New members can only 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();
        }
Пример #4
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(page, 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!");
            }
        }
Пример #5
0
        protected override async Task ExecuteLoadMoreCommand()
        {
            if (!CanLoadMore || IsBusy)
            {
                return;
            }

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


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

                foreach (var e in eventResults.RSVPs)
                {
                    var member = new MemberViewModel(e.Member, e.MemberPhoto, eventId, eventName, groupId, groupName, eventDate);

                    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 ex)
            {
                Mvx.Resolve <IMvxTrace>().Trace(MvxTraceLevel.Error, "EventViewModel", ex.ToString());
                CanLoadMore = false;
                messageDialog.SendToast("Unable to get RSVPs please refresh or log in again.");
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #6
0
        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;
            }
        }
Пример #7
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);
                    Device.BeginInvokeOnMainThread(() =>
                        {
                            Members.Remove(member);
                            RefreshCount();
                            Members = members;
                        });
                });

        }
Пример #8
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(page, 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!");
            }
        }
Пример #9
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();
                    });
            }
        }
Пример #10
0
		private void ExecuteDeleteUserCommand(MemberViewModel member)
        {
            if (member.NewUserId == 0)
                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);
					InvokeOnMainThread(()=>{
					Members.Remove(member);
                    RefreshCount();
						RaisePropertyChanged(()=>Members);
						Members = members;
					});
                });
            
        }
Пример #11
0
		private async Task ExecuteCheckInCommand(MemberViewModel member)
		{
		    if (member.Member.MemberId == -1)
		    {
                messageDialog.SendToast("New members can only 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()));
            member.CheckedIn = !member.CheckedIn;

            RefreshCount();
		}
Пример #12
0
		private async Task ExecuteLoadMoreCommand()
		{
			if (!CanLoadMore || IsBusy)
		        return;

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


			try
			{
			    var addNewMembers = Members.Count == 0;
				var eventResults = await this.meetupService.GetRSVPs(eventId, members.Count);
				foreach(var e in eventResults.RSVPs)
				{
					var member = new MemberViewModel(e.Member, e.MemberPhoto, eventId);

					member.CheckedIn = await Mvx.Resolve<IDataService> ().IsCheckedIn (eventId, member.Member.MemberId.ToString());

					members.Add(member);
				}

				CanLoadMore = eventResults.RSVPs.Count == 100;

			    if (addNewMembers)
			    {
			        var newMembers = await dataService.GetNewMembers(eventId);
			        foreach (var e in newMembers)
			        {
			            var member = new MemberViewModel(new Member {MemberId = -1, Name = e.Name},
							null, eventId);
			            member.NewUserId = e.Id;
			            member.CheckedIn = true;
			            members.Add(member);
			        }
			    }



                RefreshCount();

			}
			catch(Exception ex) {
				Mvx.Resolve<IMvxTrace> ().Trace (MvxTraceLevel.Error, "EventViewModel", ex.ToString ());
			    CanLoadMore = false;
                messageDialog.SendToast("Unable to get RSVPs please refresh or log in again.");
			}
			finally{
				IsBusy = false;
			}
		}
Пример #13
0
        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;
            }
        }