Exemple #1
0
        private async Task RemovePendings(PendingConsultationsModel pending)
        {
            var popup = await Prism.PrismApplicationBase.Current.MainPage.DisplayAlert
                            ("Cancel consultation?", $"Would you like to cancel your pending consultation with {pending.Name} on {pending.SelectedDay}?", "Yes", "No");

            if (popup)
            {
                Pendings.Remove(pending);
                await App.RetryPolicy(async() => await App.ConnectionString.DeleteAsync(pending));

                toast.ShowToast("Successfully removed pending consultation!");

                if (await App.ConnectionString.Table <PendingConsultationsModel>().CountAsync() == 0)
                {
                    Empty = true;
                    View  = false;
                }

                Analytics.TrackEvent("Remove Consultation", new Dictionary <string, string>
                {
                    { "Registered Users", "No. of times consultation is removed" }
                });
            }
        }
        private async Task AddToPendingConsultation()
        {
            try
            {
                var pendingConsultation = new PendingConsultationsModel()
                {
                    AvailableDay   = DayAvailable.ToString(),
                    Distance       = Distance,
                    Hospital       = Hospital,
                    Name           = Doctor,
                    SelectedDay    = consultationDate,
                    Specialization = Specialization,
                    CreationDate   = DateTime.Now.ToString("MMMM dd, yyyy hh:mm tt"),
                    Latitude       = latitude,
                    Longitude      = longitude,
                    Label          = label,
                    Address        = address,
                };

                if (DayAvailable == DateTime.Parse(consultationDate).DayOfWeek&& DateTime.Parse(consultationDate) > DateTime.Now)
                {
                    await App.ConnectionString.InsertAsync(pendingConsultation);

                    toast.ShowToast("Successfully scheduled consultation!");
                    await navigationService.GoBackToRootAsync();
                }
                else
                {
                    toast.ShowToast($"{Doctor} is only available every {DayAvailable}. Please select your vacant date for every {DayAvailable} in order to schedule a consultation.");
                }
            }
            catch (Exception)
            {
                toast.ShowToast("Please select a date.");
            }
        }