#pragma warning restore 1998

        /// <summary>
        /// Called once the form is complete. The result will have the properties selected by the user.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private async Task OnSpaceshipSelectionFormCompleteAsync(IDialogContext context, IAwaitable <Spaceship> result)
        {
            Spaceship spaceship = null;

            try
            {
                spaceship = await result;
            }
            catch (FormCanceledException e)
            {
                System.Diagnostics.Debug.WriteLine($"Form canceled: {e.Message}");
            }

            if (spaceship != null)
            {
                System.Diagnostics.Debug.WriteLine($"We've got the criteria for the ship:\n{spaceship.PropertiesAsFormattedString()}");
                SpaceshipData spaceshipData = SpaceshipData.Instance;
                _spaceshipMatches = spaceshipData.SearchForPartialMatches(spaceship);

                if (_spaceshipMatches.Count == 1)
                {
                    // Single match for the given property -> Choise is made!
                    IMessageActivity messageActivity = context.MakeMessage();
                    ThumbnailCard    thumbnailCard   = CreateSpaceshipThumbnailCard(_spaceshipMatches[0]);
                    messageActivity.Attachments = new List <Attachment>()
                    {
                        thumbnailCard.ToAttachment()
                    };
                    messageActivity.Text = $"You've chosen \"{_spaceshipMatches[0].Name}\", well done!";
                    await context.PostAsync(messageActivity);

                    context.Done(_spaceshipMatches[0]);
                }
                else if (_spaceshipMatches.Count > 1)
                {
                    // More than one match -> Show the available options
                    await ShowSelectSpaceshipPromptAsync(context);
                }
                else
                {
                    // Nothing found matching the given criteria
                    await context.PostAsync("No spaceships found with the given criteria");

                    context.Fail(new ArgumentException("No spaceships found with the given criteria"));
                }
            }
            else
            {
                context.Fail(new NullReferenceException("No spaceship :("));
            }
        }
#pragma warning disable 1998
        /// <summary>
        /// Validates the response and does a new search with the updated parameters.
        /// </summary>
        /// <param name="response">The response from the user.</param>
        /// <param name="spaceshipState">The current state of the form (what details we have gathered to our spaceship).</param>
        /// <param name="propertyName">The name of the property queried.</param>
        /// <returns>The validation result.</returns>
        private static async Task <ValidateResult> ValidateResponseAsync(
            object response, Spaceship spaceshipState, string propertyName)
        {
            Spaceship         spaceshipSearchFilter = new Spaceship(spaceshipState);
            object            value         = Spaceship.VerifyPropertyValue(response, propertyName);
            SpaceshipData     spaceshipData = SpaceshipData.Instance;
            IList <Spaceship> matches       = null;

            if (spaceshipSearchFilter.SetPropertyValue(value, propertyName))
            {
                matches = spaceshipData.SearchForPartialMatches(spaceshipSearchFilter);
            }

            bool isValid = (matches != null && matches.Count > 0);

            ValidateResult validateResult = new ValidateResult
            {
                IsValid = (isValid && value != null),
                Value   = value
            };

            string feedbackMessage = string.Empty;

            if (!isValid)
            {
                // Since this was an invalid option, undo the change
                spaceshipState.ClearPropertyValue(propertyName);

                string valueAsString = ValueToString(value);
                System.Diagnostics.Debug.WriteLine($"Value {valueAsString} for property {propertyName} is invalid");
                feedbackMessage = $"\"{valueAsString}\" is not a valid option";
            }
            else
            {
                // Store the search
                spaceshipData.LastSearchResults = matches;
            }

            if (matches != null && matches.Count > 5)
            {
                feedbackMessage = $"Still {matches.Count} options matching your criteria. Let's get some more details!";
            }

            if (!string.IsNullOrEmpty(feedbackMessage))
            {
                System.Diagnostics.Debug.WriteLine(feedbackMessage);
                validateResult.Feedback = feedbackMessage;
            }

            return(validateResult);
        }