Example #1
0
        private async void Switch_Toggled(object sender, ToggledEventArgs e)
        {
            bool isToggled = e.Value;

            if (isToggled)
            {
                try
                {
                    var att = new Attendance()
                    {
                        AttendeeId = App.user.Id,
                        PostId     = viewModel.Postselected.Id
                    };

                    var result = await Attendance.AttendAsync(att);

                    viewModel.IsAttending = isToggled = await Post.PostAttend(viewModel.Postselected.Id, App.user.Id);
                }
                catch (Exception ex)
                {
                    var m = ex.Message;
                }
            }

            else
            {
                try
                {
                    var att = new Attendance()
                    {
                        AttendeeId = App.user.Id,
                        PostId     = viewModel.Postselected.Id
                    };

                    var result = await Attendance.DeleteAsync(att);
                }
                catch (Exception ex)
                {
                    var m = ex.Message;
                    throw;
                }
            }
        }