Exemple #1
0
        async Task ExecuteSaveFeedbackCommand()
        {
            if (IsBusy)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(Text))
            {
                await page.DisplayAlert("Enter Feedback", "Please enter some feedback for our team.", "OK");

                return;
            }

            Track("Feedback", new Dictionary <string, string>
            {
                { nameof(Name), Name }
            });

            Message = "Submitting feedback...";
            IsBusy  = true;
            saveFeedbackCommand?.ChangeCanExecute();

            try
            {
                await dataStore.AddFeedbackAsync(new Feedback
                {
                    Text         = this.Text,
                    FeedbackDate = UtcNow,
                    VisitDate    = Date,
                    Rating       = Rating,
                    ServiceType  = ServiceType,
                    StoreName    = StoreName,
                    Name         = Name,
                    PhoneNumber  = PhoneNumber,
                    RequiresCall = RequiresCall,
                });
            }
            catch (Exception ex)
            {
                await page.DisplayAlert("Uh Oh :(", "Unable to save feedback, please try again.", "OK");

                Report(ex);
            }
            finally
            {
                IsBusy = false;
                saveFeedbackCommand?.ChangeCanExecute();
            }

            await page.Navigation.PopAsync();
        }