public int SearchFlightStart(FlightSearch flightSearch)
        {
            int newRow;
            using (var conn = new SqlConnection(connectionString))
            {
                using (var cmd = new SqlCommand("SearchFlightStart", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@SearchType", SqlDbType.VarChar, 50).Value = DateTime.Now;
                    cmd.Parameters.Add("@IsPackage", SqlDbType.Bit).Value = flightSearch.IsPackage;

                    cmd.Parameters.Add("@SearchFlightId", SqlDbType.Int).Direction = ParameterDirection.Output;

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    newRow = (int)cmd.Parameters["@SearchFlightId"].Value;

                }
            }
            return newRow;
        }
 public FlightSearchResult StartSearch(FlightSearch flightSearch)
 {
     return search.StartSearch(flightSearch);
 }
 public FlightSearchResult PerformSearch(FlightSearch flightSearch, int id)
 {
     return search.PerformSearch(flightSearch, id);
 }
        public FlightSearchResult PerformSearch(FlightSearch flightSearch, int searchId)
        {
            FlightSearchResult flightSearchResult = new FlightSearchResult();
            AirServiceSoapClient airServiceSoapClient = new AirServiceSoapClient();

            var authenticateResponse = gatewayService.GetToken();

            if (!authenticateResponse.Success)
            {
                flightSearchResult.Success = false;
                flightSearchResult.ErrorMessage = "Could not get token";
                return flightSearchResult;
            }

            // now lets try a search
            var JourneyDetails = new JourneyDetail[]
            {
                new JourneyDetail
                {
                    DepartureDateTime = DateTime.Now.Date.AddDays(30).AddHours(9),
                    DeparturePoint = "LON",
                    DeparturePointIsCity = true,
                    DestinationPoint = "DXB",
                    DestinationPointIsCity = false
                },
                new JourneyDetail {
                     DepartureDateTime = DateTime.Now.Date.AddDays(37).AddHours(9),
                    DeparturePoint = "DXB",
                    DeparturePointIsCity = false,
                    DestinationPoint = "LON",
                    DestinationPointIsCity = true
                }
            };

            var airSearchResult = airServiceSoapClient.Search(new AirService.AuthHeader
            {
                Token = authenticateResponse.Token.Value
            },
            new AirSearch
            {
                CabinClass = CabinClasses.All,
                FareType = FareTypes.All,
                FlexiDays = 0,
                SelectedAirlines = null,
                SessionID = "FlightSearch" + searchId,
                MultipleCabinClasses = new CabinClasses[] { CabinClasses.All }, // change this if we want business etc...
                AdultPaxCount = 2,
                ChildPaxCount = 0,
                ChildAges = null,
                InfantPaxCount = 0,
                JourneyDetails = JourneyDetails,
                SearchType = SearchTypes.Availability,
                SortOrder = SortOrders.Price,
                DirectFlightsOnly = false
            });

            // check if we have results

            // process them into our object

            // apply markup to the flights

            flightSearchResult.Success = true;
            flightSearchResult.ErrorMessage = "There was " + airSearchResult.Results.Result.Length + " results starting at £" + airSearchResult.Results.Result[0].AdultTotal;
            return flightSearchResult;
        }
 private bool validateFlightSearch(FlightSearch flightSearch)
 {
     // string error = "";
     if (flightSearch.DepartureDate <= DateTime.Now)
     {
        // error += "Please select a valid departure date";
         return false;
     }
     if (flightSearch.ReturnDate <= flightSearch.DepartureDate)
     {
        // error += "Please select a valid return date";
         return false;
     }
     // add other validation if necessary
     return true;
 }
        public FlightSearchResult StartSearch(FlightSearch flightSearch)
        {
            // Validate the search
            if (validateFlightSearch(flightSearch))
            {
                //alert user of the error
                return null;
            }
            // save all to the database that is needed this included what the customer searched for so we can report on it later
            var searchId = searchRepository.SearchFlightStart(flightSearch);

            // create our object to return
            FlightSearchResult flightSearchResult = new FlightSearchResult
            {
                FlightSearchId = searchId,
                FlightSearch = flightSearch
            };

            // return anything we need for the please wait page - currently unknown apart from the search id

            // return as we are done here
            return flightSearchResult;
        }