Beispiel #1
0
        private void GetClassDetails(Flight flight)
        {
            IDbConnection db = GetConnection();

            db.Open();
            IDbCommand cmd2 = db.CreateCommand();

            cmd2.CommandText = "GetFlightClasses";
            cmd2.CommandType = CommandType.StoredProcedure;
            IDbDataParameter p1 = cmd2.CreateParameter();

            p1.ParameterName = "@FlightId";
            p1.Value         = flight.ID;
            cmd2.Parameters.Add(p1);
            using (IDataReader reader2 = cmd2.ExecuteReader())
            {
                try
                {
                    while (reader2.Read())
                    {
                        FlightClass _class  = new FlightClass();
                        int         classid = int.Parse(reader2["ClassId"].ToString());
                        _class.ClassInfo = (TravelClass)classid;

                        _class.NoOfSeats = int.Parse(reader2["NoOfSeats"].ToString());
                        flight.AddClass(_class);
                    }
                    db.Close();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public ActionResult Edit(Flight flight)
        {
            if (ModelState.IsValid)
            {
                flightMgr.EditFlight(flight);

                int         id          = Convert.ToInt32(Request["Business"].ToString());
                FlightClass flightclass = flightMgr.FindFlightClass(id);
                flightclass.NoOfSeats = Convert.ToInt32(Request["2"].ToString());
                flightMgr.EditFlightClass(flightclass);

                int         id1          = Convert.ToInt32(Request["Economy"].ToString());
                FlightClass flightclass1 = flightMgr.FindFlightClass(id);
                flightclass.NoOfSeats = Convert.ToInt32(Request["1"].ToString());
                flightMgr.EditFlightClass(flightclass1);

                TempData["Message"] = "Flight Details Edited sucessfully...";
                return(RedirectToAction("Index"));
            }
            ViewBag.AirlineId   = new SelectList(flightMgr.GetAllAirline(), "AirlineId", "AirlineName", flight.AirlineId);
            ViewBag.TravelClass = flightMgr.GetAllTravelClass();
            ViewBag.FlightClass = flightMgr.GetFlightClass();

            ViewBag.Message = "Something went wrong try again....";
            return(View(flight));
        }
Beispiel #3
0
 /// <summary>
 /// Update the existing flight class seats for a given flight id for the database
 /// </summary>
 /// <parameter name="flight"></parameter>
 /// <parameter name="flightClass"></parameter>
 /// <returns>Returns the number of rows affected by the insert</returns>
 public int UpdateFlightClass(Flight flight, FlightClass flightClass)
 {
     try
     {
         return(ExecuteStoredProcedure("UpdateFlightClass",
                                       new SqlParameter()
         {
             ParameterName = "@flightId", DbType = DbType.Int32, Value = flight.ID
         },
                                       new SqlParameter()
         {
             ParameterName = "@classId", DbType = DbType.Int32, Value = flightClass.ClassInfo
         },
                                       new SqlParameter()
         {
             ParameterName = "@noOfSeats", DbType = DbType.Int32, Value = flightClass.NoOfSeats
         }
                                       ));
     }
     catch (Common.ConnectToDatabaseException)
     {
         throw new FlightDAOException("Unable to update flight class");
     }
     catch (Exception)
     {
         throw new FlightDAOException("Unable to update flight class");
     }
 }
Beispiel #4
0
        /// <summary>
        /// Get a class with Google Pay API for Passes REST API
        /// See https://developers.google.com/pay/passes/reference/v1/flightclass/get
        /// </summary>
        /// <param name="id">id of the class</param>
        /// <returns>Class</returns>
        public FlightClass getFlightClass(string id)
        {
            FlightClass response = null;
            // Uses the Google Pay API for Passes C# client lib to get a Flight class
            // check the devsite for newest client lib: https://developers.google.com/pay/passes/support/libraries#libraries
            // check reference API to see the underlying REST call:
            // https://developers.google.com/pay/passes/reference/v1/flightclass/get
            WalletobjectsService service = new WalletobjectsService(new Google.Apis.Services.BaseClientService.Initializer()
            {
                HttpClientInitializer = this.credential
            });

            try
            {
                response = service.Flightclass.Get(id).Execute();
            }
            catch (Google.GoogleApiException ge)
            {
                System.Console.WriteLine(">>>> [START] Google Server Error response:");
                System.Console.WriteLine(ge.Message);
                System.Console.WriteLine(">>>> [END] Google Server Error response\n");
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.StackTrace);
            }
            return(response);
        }
        public void BindData()
        {
            try
            {
                ddlAirLine.DataSource     = new AirLineManager().GetAirLines();
                ddlAirLine.DataTextField  = "Name";
                ddlAirLine.DataValueField = "Id";
                ddlAirLine.DataBind();

                flightid = Request.QueryString["flightid"].ToString();

                FlightManager obj = new FlightManager();
                flight = obj.GetFlight(int.Parse(flightid));

                FlightClass flightclass = new FlightClass();

                txtName.Text             = flight.Name;
                ddlAirLine.SelectedValue = flight.AirlineForFlight.Id.ToString();
                GridView1.DataSource     = flight.GetClasses();
                GridView1.DataBind();
            }

            catch (FlightManagerException ex)
            {
                throw ex;
            }
            catch (AirlineManagerException exc2)
            {
                throw exc2;
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string flightName  = txtName.Text;
            int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
            string airlinename = ddlAirLine.SelectedItem.Text;
            Flight _flight     = new Flight()
            {
                Name = flightName, AirlineForFlight = new Airline()
                {
                    Id = airlineid, Name = airlinename
                }
            };
            FlightManager _flightManger = new FlightManager();

            try
            {
                foreach (RepeaterItem item in dlClass.Items)
                {
                    TextBox txtNoOfSeats = (TextBox)item.FindControl("txtNoOfSeats");
                    Label   lblClass     = (Label)item.FindControl("lblClass");

                    if (txtNoOfSeats.Text.Length == 0)
                    {
                        txtNoOfSeats.Focus();
                        lblError.Text = "No of Seats Cannot be Empty";
                        break;
                    }
                    else
                    {
                        if (txtNoOfSeats != null)
                        {
                            TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                            int         NoOfSeats   = int.Parse(txtNoOfSeats.Text);
                            FlightClass _class      = new FlightClass()
                            {
                                ClassInfo = travelClass, NoOfSeats = NoOfSeats
                            };
                            _flight.AddClass(_class);
                        }
                    }
                }
                if (_flightManger.AddFlight(_flight) == false)
                {
                    lblError.Text = "Flight Name already exists";
                }
                else
                {
                    lblError.Text = "Flight Added Successfully";
                }
            }
            catch (FlightManagerException exc)
            {
                lblError.Text = exc.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
Beispiel #7
0
 public void UpdateFlightClass(FlightClass flightClass)
 {
     using (OnlineFlightTicketBookingDBContext FlightDBContext = new OnlineFlightTicketBookingDBContext())
     {
         FlightDBContext.Entry(flightClass).State = EntityState.Modified;
         FlightDBContext.SaveChanges();
     }
 }
Beispiel #8
0
 public void AddFlightClass(FlightClass flightClass)
 {
     using (OnlineFlightTicketBookingDBContext FlightDBContext = new OnlineFlightTicketBookingDBContext())
     {
         FlightDBContext.FlightClass.Add(flightClass);
         FlightDBContext.SaveChanges();
     }
 }
Beispiel #9
0
 public void addFlightClass(FlightClass flightClass)
 {
     if (this.payload.flightClasses == null)
     {
         this.payload.flightClasses = new List <FlightClass>();
     }
     this.payload.flightClasses.Add(flightClass);
 }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row          = GridView1.Rows[e.RowIndex];
                TextBox     txtNoOfSeats = (TextBox)row.FindControl("txtNoOfSeats");
                int         intNoOfSeats = Convert.ToInt32((txtNoOfSeats.Text.ToString()));

                if ((!int.TryParse(txtNoOfSeats.Text, out intNoOfSeats)) || (intNoOfSeats <= 0))
                {
                    ctlAdminMaster.ErrorMessage = "Seat count should be a positive number";
                    txtNoOfSeats.Focus();
                }
                else
                {
                    string txtClass = ((TextBox)row.FindControl("txtClass")).Text;

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = intNoOfSeats;

                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    flightManager.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    ctlAdminMaster.ErrorMessage = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                ctlAdminMaster.ErrorMessage = ex.Message;
            }
        }
        public ActionResult EditFlightClass(int id)
        {
            FlightClass          flightClass          = flightClassBL.GetFlightClass(id);
            var                  mapAccount           = new MapperConfiguration(cfg => { cfg.CreateMap <FlightClass, FlightClassViewModel>(); });
            IMapper              mapper               = mapAccount.CreateMapper();
            FlightClassViewModel flightClassViewModel = mapper.Map <FlightClass, FlightClassViewModel>(flightClass);

            return(View(flightClassViewModel));
        }
Beispiel #12
0
 public void DeleteFlightClass(int id)
 {
     using (OnlineFlightTicketBookingDBContext FlightDBContext = new OnlineFlightTicketBookingDBContext())
     {
         FlightClass flightClass = FlightDBContext.FlightClass.Find(id);
         FlightDBContext.FlightClass.Remove(flightClass);
         FlightDBContext.SaveChanges();
     }
 }
Beispiel #13
0
        public void AddSeat(string col, int row, FlightClass flightClass)
        {
            if (Seats == null)
            {
                Seats = new List <Seat>();
            }

            Seats.Add(new Seat(col, row, flightClass));
        }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.Rows[e.RowIndex];

                if (((TextBox)row.FindControl("txtNoOfSeats")).Text.Length == 0)
                {
                    lblError.Text = "Seats Cannot be Empty";
                    ((TextBox)row.FindControl("txtNoOfSeats")).Focus();
                }
                else
                {
                    string txtClass     = ((TextBox)row.FindControl("txtClass")).Text;
                    int    txtNoOfSeats = Convert.ToInt32((((TextBox)row.FindControl("txtNoOfSeats")).Text.ToString()));

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = txtNoOfSeats;

                    FlightManager _flightManger = new FlightManager();

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    _flightManger.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    lblError.Text = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
 public ActionResult Edit([Bind(Include = "FlightClassID,FlightClassKind")] FlightClass flightClass)
 {
     if (ModelState.IsValid)
     {
         flightClassRepository.UpdateFlightClass(flightClass);
         flightClassRepository.Save();
         return(RedirectToAction("Index"));
     }
     return(View(flightClass));
 }
Beispiel #16
0
        /// <summary>
        /// Get the flight details from the database
        /// </summary>
        /// <exception cref="FlightDAOException">Thorws an exception when unable to get flights</exception>
        /// <returns>Returns the list of flights from the database</returns>
        public List <Flight> GetFlights()
        {
            List <Flight> flights = new List <Flight>();

            try
            {
                Database db = GetDatabaseConnection();

                using (IDataReader reader = db.ExecuteReader("GetFlights"))
                {
                    while (reader.Read())
                    {
                        Flight flight = new Flight();

                        flight.ID                    = long.Parse(reader["FlightId"].ToString());
                        flight.Name                  = reader["FlightName"].ToString();
                        flight.AirlineForFlight      = new Airline();
                        flight.AirlineForFlight.Id   = int.Parse(reader["AirlineId"].ToString());
                        flight.AirlineForFlight.Name = reader["AirlineName"].ToString();
                        flight.AirlineForFlight.Code = reader["AirlineCode"].ToString();

                        using (IDataReader reader2 = db.ExecuteReader("GetFlightClasses", flight.ID))
                        {
                            try
                            {
                                while (reader2.Read())
                                {
                                    FlightClass _class  = new FlightClass();
                                    int         classid = int.Parse(reader2["ClassId"].ToString());
                                    _class.ClassInfo = (TravelClass)classid;

                                    _class.NoOfSeats = int.Parse(reader2["NoOfSeats"].ToString());
                                    flight.AddClass(_class);
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                        flights.Add(flight);
                    }
                }
            }
            catch (ConnectToDatabaseException ex)
            {
                throw new FlightDAOException("Unable to connect to database", ex);
            }
            catch (Exception ex)
            {
                throw new FlightDAOException("Unable to get flights", ex);
            }

            return(flights);
        }
        public ActionResult SaveFlight(string departureTime, string status, int cityOne, int cityTwo)
        {
            FlightClass flight = new FlightClass(departureTime, status);

            flight.FlightSave();
            List <FlightClass> flights = FlightClass.GetAll();
            int flightId = flights[0].GetId();

            JoinTableClass.SaveToJoinTable(cityOne, cityTwo, flightId);
            return(RedirectToAction("NewFlight"));
        }
Beispiel #18
0
 /// <summary>
 /// Update the existing flight details along with seats and class
 /// </summary>
 /// <parameter name="flightClassInfo"></parameter>
 /// <parameter name="flightInfo"></parameter>
 /// <exception cref="FlightManagerException">Thorwn when unable to update flight class</exception>
 /// <returns>Returns the status of the update</returns>
 public int UpdateFlightClass(Flight flightInfo, FlightClass flightClassInfo)
 {
     try
     {
         return(flightDAO.UpdateFlightClass(flightInfo, flightClassInfo));
     }
     catch (FlightDAOException ex)
     {
         throw new FlightManagerException("Unable to update flight class", ex);
     }
 }
        public ActionResult NewFlight()
        {
            List <CityClass>            allCities  = CityClass.GetAll();
            List <FlightClass>          allFlights = FlightClass.GetAll();
            Dictionary <string, object> model      = new Dictionary <string, object> {
            };

            model.Add("cities", allCities);
            model.Add("flights", allFlights);
            return(View(model));
        }
Beispiel #20
0
        /// <summary>
        /// Get the flight details from the database
        /// </summary>
        /// <exception cref="FlightDAOException">Thorws an exception when unable to get flights</exception>
        /// <returns>Returns the list of flights from the database</returns>
        public List <Flight> GetFlights()
        {
            List <Flight> flights = new List <Flight>();

            try
            {
                using (IDbConnection conn = GetConnection())
                {
                    using (IDataReader reader = ExecuteStoredProcedureResults(conn, "GetFlightsAndFlightClasses"))
                    {
                        while (reader.Read())
                        {
                            Flight flight = new Flight();

                            flight.ID                    = long.Parse(reader["FlightId"].ToString());
                            flight.Name                  = reader["FlightName"].ToString();
                            flight.AirlineForFlight      = new Airline();
                            flight.AirlineForFlight.Id   = int.Parse(reader["AirlineId"].ToString());
                            flight.AirlineForFlight.Name = reader["AirlineName"].ToString();
                            flight.AirlineForFlight.Code = reader["AirlineCode"].ToString();

                            flights.Add(flight);
                        }

                        Flight CurrentFlight = new Flight();
                        reader.NextResult();
                        while (reader.Read())
                        {
                            FlightClass _class  = new FlightClass();
                            int         classid = int.Parse(reader["ClassId"].ToString());
                            _class.ClassInfo = (TravelClass)classid;
                            _class.NoOfSeats = int.Parse(reader["NoOfSeats"].ToString());

                            if (CurrentFlight.ID != (long)reader["FlightId"])
                            {
                                CurrentFlight = flights.Where(f => f.ID == (long)reader["FlightId"]).First();
                            }
                            CurrentFlight.AddClass(_class);
                        }
                    }
                }
            }
            catch (ConnectToDatabaseException ex)
            {
                throw new FlightDAOException("Unable to connect to database", ex);
            }
            catch (Exception ex)
            {
                throw new FlightDAOException("Unable to get flights", ex);
            }

            return(flights);
        }
Beispiel #21
0
 public bool DeleteFlightClass(FlightClass flightClass)
 {
     try
     {
         db.Entry(flightClass).State = EntityState.Deleted;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #22
0
 public bool InsertFlightClass(FlightClass flightClass)
 {
     try
     {
         db.FlightClasses.Add(flightClass);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #23
0
 public Flight(Location from_Location, Location to_Location, Price price, DateTime flight_Departure_Time, DateTime flight_Arrival_Time, string flight_Duration, string flight_Distance, FlightClass flightClass, string seats, List <Location> transits)
 {
     From_Location         = from_Location;
     To_Location           = to_Location;
     Price                 = price;
     Flight_Departure_Time = flight_Departure_Time;
     Flight_Arrival_Time   = flight_Arrival_Time;
     Flight_Duration       = flight_Duration;
     Flight_Distance       = flight_Distance;
     FlightClass           = flightClass;
     Seats                 = seats;
     Transits              = transits;
 }
        public ActionResult SaveFlight(string departureTime, string status, int cityOne, int cityTwo)
        {
            FlightClass flight = new FlightClass(departureTime, status);

            flight.FlightSave();
            List <FlightClass> flights = FlightClass.GetAll();
            int flightId = flight.GetId();

            // int flightId = flights[0].GetId();
            // this /\ was grabbing the first flight in the list every time and setting all entries to 1
            JoinTableClass.SaveToJoinTable(cityOne, cityTwo, flightId);
            return(RedirectToAction("NewFlight"));
        }
Beispiel #25
0
        /// <summary>
        /// Get the flights details for a given flight from the database
        /// </summary>
        /// <parameter name="FlightId"></parameter>
        /// <returns>Returns the flight for a given id from the database</returns>
        public Flight GetFlight(int flightId)
        {
            Flight flight = null;

            try
            {
                using (IDataReader Reader = GetDatabaseConnection().ExecuteReader("GetFlightsID", flightId))
                {
                    while (Reader.Read())
                    {
                        flight = new Flight();

                        flight.ID                    = long.Parse(Reader["FlightId"].ToString());
                        flight.Name                  = Reader["FlightName"].ToString();
                        flight.AirlineForFlight      = new Airline();
                        flight.AirlineForFlight.Id   = int.Parse(Reader["AirlineId"].ToString());
                        flight.AirlineForFlight.Name = Reader["AirlineName"].ToString();
                        flight.AirlineForFlight.Code = Reader["AirlineCode"].ToString();

                        using (IDataReader Reader2 = GetDatabaseConnection().ExecuteReader("GetFlightClasses", flight.ID))
                        {
                            try
                            {
                                while (Reader2.Read())
                                {
                                    FlightClass fClass  = new FlightClass();
                                    int         classId = int.Parse(Reader2["ClassId"].ToString());
                                    fClass.ClassInfo = (TravelClass)classId;

                                    fClass.NoOfSeats = int.Parse(Reader2["NoOfSeats"].ToString());
                                    flight.AddClass(fClass);
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }
                }
            }
            catch (Common.ConnectToDatabaseException)
            {
                throw new FlightDAOException("Unable to get the flight details");
            }
            catch (Exception)
            {
                throw new FlightDAOException("Unable to get the flight details");
            }
            return(flight);
        }
        public ActionResult UpdateFlightClass(FlightClassViewModel flightClassViewModel)
        {
            FlightClass flightClass = null;

            if (ModelState.IsValid)
            {
                var     mapAccount = new MapperConfiguration(cfg => { cfg.CreateMap <FlightClassViewModel, FlightClass>(); });
                IMapper mapper     = mapAccount.CreateMapper();
                flightClass = mapper.Map <FlightClassViewModel, FlightClass>(flightClassViewModel);
                flightClassBL.UpdateFlightClass(flightClass);
                return(RedirectToAction("DisplayFlightClass"));
            }
            return(View(flightClass));
        }
Beispiel #27
0
        /// <summary>
        /// Update the existing flight class seats for a given flight id for the database
        /// </summary>
        /// <param name="_flight"></param>
        /// <param name="_flightclass"></param>
        /// <returns>Returns the number of rows updated</returns>
        public int UpdateFlightClass(Flight flight, FlightClass flightClass)
        {
            IDbConnection conn1 = null;
            int           flag  = 0;

            try
            {
                conn1 = this.GetConnection();
                conn1.Open();


                IDbCommand cmd = conn1.CreateCommand();
                cmd.CommandText = "UpdateFlightClass";
                cmd.CommandType = CommandType.StoredProcedure;

                IDataParameter p1 = cmd.CreateParameter();
                p1.ParameterName = "@flightId";
                p1.Value         = flight.ID;
                cmd.Parameters.Add(p1);

                IDataParameter p2 = cmd.CreateParameter();
                p2.ParameterName = "@classId";
                p2.Value         = (int)flightClass.ClassInfo;
                cmd.Parameters.Add(p2);

                IDataParameter p3 = cmd.CreateParameter();
                p3.ParameterName = "@noOfSeats";
                p3.Value         = flightClass.NoOfSeats;
                cmd.Parameters.Add(p3);

                flag = cmd.ExecuteNonQuery();
            }
            catch (Common.ConnectToDatabaseException)
            {
                throw new FlightDAOException("Unable to update flight class");
            }
            catch (Exception)
            {
                throw new FlightDAOException("Unable to update flight class");
            }
            finally
            {
                if (conn1 != null && conn1.State == ConnectionState.Open)
                {
                    conn1.Close();
                }
            }

            return(flag);
        }
        // GET: Admin/FlightClasses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlightClass flightClass = flightClassRepository.GetFlightClassById(id.Value);

            if (flightClass == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(flightClass));
        }
Beispiel #29
0
        /// <summary>
        /// Get the flights details for a given flight from the database
        /// </summary>
        /// <parameter name="FlightId"></parameter>
        /// <returns>Returns the flight for a given id from the database</returns>
        public Flight GetFlight(int flightId)
        {
            Flight flight = null;

            try
            {
                using (IDbConnection conn = GetConnection())
                {
                    using (IDataReader Reader = ExecuteStoredProcedureResults(conn, "GetFlightAndClasses",
                                                                              new SqlParameter()
                    {
                        ParameterName = "@FlightID", DbType = DbType.Int32, Value = flightId
                    }
                                                                              ))
                    {
                        Reader.Read();

                        flight = new Flight();

                        flight.ID                    = long.Parse(Reader["FlightId"].ToString());
                        flight.Name                  = Reader["FlightName"].ToString();
                        flight.AirlineForFlight      = new Airline();
                        flight.AirlineForFlight.Id   = int.Parse(Reader["AirlineId"].ToString());
                        flight.AirlineForFlight.Name = Reader["AirlineName"].ToString();
                        flight.AirlineForFlight.Code = Reader["AirlineCode"].ToString();

                        Reader.NextResult();
                        while (Reader.Read())
                        {
                            FlightClass fClass  = new FlightClass();
                            int         classId = int.Parse(Reader["ClassId"].ToString());
                            fClass.ClassInfo = (TravelClass)classId;

                            fClass.NoOfSeats = int.Parse(Reader["NoOfSeats"].ToString());
                            flight.AddClass(fClass);
                        }
                    }
                }
            }
            catch (Common.ConnectToDatabaseException)
            {
                throw new FlightDAOException("Unable to get the flight details");
            }
            catch (Exception)
            {
                throw new FlightDAOException("Unable to get the flight details");
            }
            return(flight);
        }
Beispiel #30
0
        public static string ToString(this FlightClass flightClass)
        {
            var result = String.Empty;

            switch (flightClass)
            {
            case FlightClass.Business:
                result = "Business".ToUpper();
                break;

            case FlightClass.Econom:
                result = "Econom".ToUpper();
                break;
            }
            return(result);
        }