예제 #1
0
        public TourCompany Post([FromBody] siginRequest requestData)
        {
            TourCompany currCompany = requestData.signin();

            HttpContext.Current.Session["companyName"] = currCompany.CompanyName;
            return(currCompany);
        }
예제 #2
0
        public List <TourCompany> getCompanies()
        {
            List <TourCompany> tourCompanyList = new List <TourCompany>();
            SqlConnection      con             = null;

            try
            {
                con = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file

                String     selectSTR = "SELECT * FROM TourCompaniesUsers_CS";
                SqlCommand cmd       = new SqlCommand(selectSTR, con);

                // get a reader
                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end

                while (dr.Read())
                {   // Read till the end of the data into a row
                    TourCompany currTourCompany = new TourCompany();
                    currTourCompany.CompanyUserName = (string)dr["CompanyUserName"];
                    currTourCompany.CompanyPassword = (string)dr["CompanyPassword"];
                    currTourCompany.CompanyName     = (string)dr["CompanyName"];
                    currTourCompany.CompanyEmail    = (string)dr["CompanyEmail"];
                    tourCompanyList.Add(currTourCompany);
                }
                return(tourCompanyList);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
예제 #3
0
 public IEnumerable <TourCompany> getTourCompany()
 {
     return(TourCompany.getTourCompanies());
 }
예제 #4
0
 // POST api/<controller>
 public IEnumerable <TourCompany> Post([FromBody] TourCompany tourCompany)
 {
     tourCompany.insertTourCompanies();
     return(TourCompany.getTourCompanies());
 }
예제 #5
0
        //--------------------------------------------------------------------
        // Build the Insert command String
        //--------------------------------------------------------------------
        private String BuildInsertCommand(object currobject)
        {
            String command;
            // use a string builder to create the dynamic string
            StringBuilder sb = new StringBuilder();

            // checks which object
            if (currobject is Airline)
            {
                Airline airlineObj = currobject as Airline;
                sb.AppendFormat("Values('{0}', '{1}')", airlineObj.AirlineId, airlineObj.AirlineName);
                String prefix = "INSERT INTO Airlines_CS " + "(AirlineId, AirlineName) ";
                command = prefix + sb.ToString();
                return(command);
            }
            else if (currobject is Airport)
            {
                Airport airpotObj = currobject as Airport;
                sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", airpotObj.AirportId, airpotObj.AirportName, airpotObj.AirportCity, airpotObj.AirportState, airpotObj.AirportLong.ToString(), airpotObj.AirportLat.ToString());
                String prefix = "INSERT INTO Airports_CS " + "(AirportId, AirportName, AirportCity, AirportState, AirportLong, AirportLat) ";
                command = prefix + sb.ToString();

                return(command);
            }
            else if (currobject is Flight)
            {
                Flight flightObj = currobject as Flight;
                sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", flightObj.FlightId, flightObj.From, flightObj.To, flightObj.StartDate.ToString("MM/dd/yyyy HH:mm:ss"), flightObj.EndDate.ToString("MM/dd/yyyy HH:mm:ss"), flightObj.Price.ToString(), flightObj.Stops, flightObj.TravelTime);
                String prefix = "INSERT INTO MyFlights_CS " + "(FlightId, DepartureAirportId, ArivalAirportId, DepartureTime, ArivalTime, Price, StopsNo, TravelTime) ";
                command = prefix + sb.ToString();

                return(command);
            }
            else if (currobject is Leg)
            {
                Leg legObj = currobject as Leg;
                sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}')", legObj.LegId, legObj.LegFlightId, legObj.LegNum, legObj.LegFlightNo.ToString(), legObj.LegDepartureAirport, legObj.LegArivalAirport, legObj.LegAirlineId, legObj.LegDepartureTime.ToString("MM/dd/yyyy HH:mm:ss"), legObj.LegArivalTime.ToString("MM/dd/yyyy HH:mm:ss"), legObj.LegFlightLength);
                String prefix = "INSERT INTO Legs_CS " + "(LegId, LegFlightId, LegNo, LegFlightNo, LegDepartureAirportId, LegArivalAirportId, LegAirlineId, LegDepartureTime, LegArivalTime, LegFlightTime) ";
                command = prefix + sb.ToString();

                return(command);
            }
            else if (currobject is Discount)
            {
                Discount discountObj = currobject as Discount;
                sb.AppendFormat("Values('{0}', '{1}', '{2}','{3}','{4}','{5}','{6}')", discountObj.DiscountId, discountObj.AirlineCode, discountObj.AirportFrom, discountObj.AirportTo, discountObj.DateFrom.ToString("MM/dd/yyyy HH:mm:ss"), discountObj.DateTo.ToString("MM/dd/yyyy HH:mm:ss"), discountObj.DiscountValue);
                String prefix = "INSERT INTO  Discount_CS " + "(DiscountId, AirlineCode, AirportFrom, AirportTo, DateFrom, DateTo, DiscountValue) ";
                command = prefix + sb.ToString();
                return(command);
            }
            else if (currobject is Order)
            {
                Order orderObj = currobject as Order;
                sb.AppendFormat("Values('{0}', '{1}', '{2}')", orderObj.PassengersNames, orderObj.PassengerEmail, orderObj.OrderDate.ToString("MM/dd/yyyy HH:mm:ss"));
                String prefix = "INSERT INTO Orders_CS " + "(PassengersNames, PassengerEmail, OrderDate) ";
                command = prefix + sb.ToString();
                return(command);
            }
            else if (currobject is TourCompany)
            {
                TourCompany tourCompanyObj = currobject as TourCompany;
                sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}')", tourCompanyObj.CompanyUserName, tourCompanyObj.CompanyPassword, tourCompanyObj.CompanyName, tourCompanyObj.CompanyEmail);
                String prefix = "INSERT INTO TourCompaniesUsers_CS " + "(CompanyUserName, CompanyPassword , CompanyName, CompanyEmail) ";
                command = prefix + sb.ToString();
                return(command);
            }
            else if (currobject is Tour)
            {
                Tour tourObj = currobject as Tour;
                sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", tourObj.TourSupplier, tourObj.TourLength, tourObj.TourPrice, tourObj.Country, tourObj.City, tourObj.TourTitle, tourObj.TourDescription, tourObj.ImgURL);
                String prefix = "INSERT INTO Tour_CS " + "(TourSupplier, TourLength, TourPrice, Country, City, TourTitle ,TourDescription , TourImgURL) ";
                command = prefix + sb.ToString();
                return(command);
            }
            else
            {
                return("0");
            }
        }