private bool Budget_CheckValueCanBeParsed(string value)
        {
            value = value.ToLower().Trim();

            if (value == "x")
            {
                Console.Clear();
                AppStart.Main();
            }

            try
            {
                int testValue = Convert.ToInt32(value);

                if (testValue < 0)
                {
                    throw new ArgumentOutOfRangeException();
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        private int PartyNumber_VerifyUserInput(string userInput)
        {
            int returnValue = 0;

            if (userInput == "x")
            {
                Console.Clear();
                AppStart.Main();
            }
            else
            {
                try
                {
                    returnValue = Convert.ToInt32(userInput);
                    if (returnValue <= 0)
                    {
                        PartyNumber_ThrowError();
                    }
                }
                catch
                {
                    PartyNumber_ThrowError();
                }
            }

            return(returnValue);
        }
        private void VerifyUserInput(string input)
        {
            input = input.ToLower().Trim();

            switch (input)
            {
            case "adventure":
                return;

            case "beach":
                return;

            case "city":
                return;

            case "cruise":
                return;

            case "x":
                Console.Clear();
                AppStart.Main();
                break;

            default:
                ;
                throw new Exception();
            }
        }
Esempio n. 4
0
        public List <Destination> RetrieveDestinationsByType(List <Destination> list, string type)
        {
            try
            {
                string connectionString = "Server=.;Database=HolidayDestinations;Trusted_Connection=True;";
                string storedProcedure  = "GetDestinationByType";

                SqlConnection connection = new SqlConnection(connectionString);
                SqlCommand    command    = new SqlCommand(storedProcedure, connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter parameter = command.Parameters.Add("@type", SqlDbType.VarChar);
                parameter.Value = type;

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Destination destination = new Destination();
                    destination.Id                    = reader.GetInt32(0);
                    destination.Name                  = reader.GetString(1);
                    destination.Description           = reader.GetString(2);
                    destination.HolidayType           = reader.GetString(3);
                    destination.Country               = reader.GetString(4);
                    destination.Cost                  = reader.GetDecimal(5);
                    destination.SuitableForSolo       = reader.GetBoolean(6);
                    destination.SuitableForCouple     = reader.GetBoolean(7);
                    destination.SuitableForFamily     = reader.GetBoolean(8);
                    destination.SuitableForLargeParty = reader.GetBoolean(9);
                    destination.Rating                = reader.GetDecimal(10);

                    list.Add(destination);
                }

                connection.Close();
            }
            catch
            {
                Console.WriteLine("I am really sorry, we are having issues finding you your dream holiday!");
                Console.WriteLine("Please try again soon!");
                AppStart.Main();
            }

            return(list);
        }