public FlightSection(int rows, int columns, SeatClass seatClass)
 {
     this.Rows      = rows;
     this.Columns   = columns;
     this.SeatClass = seatClass;
     GenerateSeats();
 }
Ejemplo n.º 2
0
 public void BookSeat(string aName, string flightName, SeatClass s, int row, string col)
 {
     try
     {
         Airline airline = _airlineRepository.Retreive(aName);
         Flight  flight  = _flightRepository.Retreive(airline.AirlineId, flightName);
         if (airline == null)
         {
             throw new Exception(ExceptionHelper.NonExistentAirline);
         }
         if (flight == null)
         {
             throw new Exception(ExceptionHelper.NonExistentFlight);
         }
         if (!_seatRepository.BookSeat(flight, s, row, col))
         {
             throw new Exception(ExceptionHelper.SeatAlreadyBooked);
         }
         Console.WriteLine($"Succesfully booked- {aName} Seat: {row}{col}");
     }
     catch (Exception e)
     {
         Console.WriteLine($"{e.Message}- Airline: {aName} : {flightName} Seat: {row} {col}");
     }
 }
Ejemplo n.º 3
0
 public ThankYouViewModel(string bookingId, SeatClass seatClass, int selectedRow, int selectedCol)
 {
     SelectedClass      = seatClass.ToString();
     SelectedRow        = selectedRow.ToAlphabet();
     SelectedCol        = (selectedCol + 1).ToString();
     BookingSucceedText = "Congraduration! Your booking id is " + bookingId + ".";
 }
Ejemplo n.º 4
0
        public SeatClass GetClass(int airplaneID_in, string name_in)
        {
            SeatClass       seatClass  = null;
            OracleParameter result_out = new OracleParameter("result_out", OracleDbType.RefCursor);

            OpenConnection();
            using (OracleCommand oracleCommand = new OracleCommand("programmer.GetSeatClassByAirplaneAndName", Connection))
            {
                oracleCommand.CommandType = System.Data.CommandType.StoredProcedure;
                oracleCommand.Parameters.Add("id_in", airplaneID_in);
                oracleCommand.Parameters.Add("name_in", name_in);
                oracleCommand.Parameters.Add(result_out).Direction = System.Data.ParameterDirection.Output;
                OracleDataReader dt = oracleCommand.ExecuteReader();
                while (dt.Read())
                {
                    seatClass = new SeatClass()
                    {
                        Airplane        = airplaneDAL.GetAirplane(int.Parse(dt[0].ToString())),
                        Name            = dt[1].ToString(),
                        SeatingCapacity = int.Parse(dt[2].ToString())
                    };
                }
                dt.Close();
            }
            return(seatClass);
        }
Ejemplo n.º 5
0
        public void AddSeatsForFlight(Flight flight, int row, int col, SeatClass seatClass)
        {
            using (var context = new ABS())
            {
                // Gets the section for the enum seatClass
                var section = context.Sections.Where(s => s.SeatClassName == seatClass.ToString())
                              .FirstOrDefault();

                // Checks if such section is already associated with the flight
                var existingSection = context.Seats.Where(s => s.FlightId == flight.FlightId && s.SectionId == section.SectionId)
                                      .FirstOrDefault();
                if (existingSection != null)
                {
                    throw new Exception(ExceptionHelper.ExistingSection);
                }

                List <Seat> seats = new List <Seat>();
                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < col; j++)
                    {
                        Seat seatToAdd = new Seat();
                        seatToAdd.Col       = Convert.ToChar('A' + j).ToString(); //translates the integer value to alphabethical char
                        seatToAdd.Row       = i + 1;                              //because we want the rows to start at 1 not at 0
                        seatToAdd.FlightId  = flight.FlightId;
                        seatToAdd.Status    = true;
                        seatToAdd.SectionId = section.SectionId;
                        seats.Add(seatToAdd);
                    }
                }
                context.Seats.AddRange(seats);
                context.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public Ticket(IFlight flight, SeatClass seatClass, decimal price, int numberOfSeat)
        {
            Flight = flight;

            ClassOfSeat  = seatClass;
            Price        = price;
            NumberOfSeat = numberOfSeat;
        }
Ejemplo n.º 7
0
        public SeatClass GetModel()
        {
            var model = new SeatClass();

            CommonMethods.CopyObjectProperties(this, model);

            return(model);
        }
Ejemplo n.º 8
0
        private void MapSeatData(List <FlightSeatInfo> seatInfos, SeatClass seatClass, DataGrid dataGrid)
        {
            var seats          = seatInfos.Where(s => s.SeatClass == seatClass).FirstOrDefault()?.SeatMatrix;
            var dataGridLength = new DataGridLength(seats.Length, DataGridLengthUnitType.Star);

            dataGrid.ItemsSource = GenerateDataTableForSeat(seats);
            dataGrid.ColumnWidth = dataGridLength;
        }
        public ActionResult DeleteConfirmed(string id)
        {
            SeatClass seatclass = db.SeatClasses.Find(id);

            db.SeatClasses.Remove(seatclass);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SeatingMapViewModel"/> class.
 /// </summary>
 public SeatingMapViewModel()
 {
     //Load the plane data from the XAML file. This is to illustrate merging data available from the .dbf file of Shapefile with
     //other external dta sources such as from Xaml as shown in this sample.
     PlaneData = PlaneData.Load();
     Classes   = this.PlaneData.Classes.Cast <SeatClass>().ToList();
     _allClass = this.Classes.FirstOrDefault(c => c.SeatCategory == Resources.AppStrings.All);
 }
        private static void CheckIfFlightContainsSectionAndAddNewSection(SeatClass seatClass, Flight flight, FlightSection section)
        {
            if (flight.Sections.Any(s => s.SeatClass == seatClass))
            {
                throw new ArgumentException("Section already exists");
            }

            flight.Sections.Add(section);
        }
 public ActionResult Edit(SeatClass seatclass)
 {
     if (ModelState.IsValid)
     {
         db.Entry(seatclass).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(seatclass));
 }
        public ActionResult Create(SeatClass seatclass)
        {
            if (ModelState.IsValid)
            {
                db.SeatClasses.Add(seatclass);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(seatclass));
        }
Ejemplo n.º 14
0
        private void IncrementSeatCountByClass(string seatClassName)
        {
            SeatClass seatClass = this.Classes.FirstOrDefault(x => x.SeatCategory == seatClassName);

            if (seatClass == null)
            {
                throw new ArgumentException("Seat class not found in data file.");
            }

            ++seatClass.SeatCount;
        }
Ejemplo n.º 15
0
        public SeatClassModel CreateViewModel(SeatClass model)
        {
            SeatClassModel viewModel = null;

            if (model != null)
            {
                viewModel = new SeatClassModel();
                CommonMethods.CopyObjectProperties(model, viewModel);
            }

            return(viewModel);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Updates the seat class.
        /// </summary>
        /// <param name="seat class">The seat class.</param>
        /// <returns>The updated seat class.</returns>
        public SeatClass UpdateSeatClass(SeatClass seatClass)
        {
            var existingSeatClass = this.GetSeatClass(seatClass.Id);

            if (existingSeatClass != null)
            {
                DataModelUpdater.UpdateSeatClass(seatClass, ref existingSeatClass);
                this.context.Update(existingSeatClass);
                this.context.SaveChanges();
            }

            return(existingSeatClass);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Books available seat.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        public bool BookSeat(SeatClass s, int row, char col)
        {
            bool booked = false;

            foreach (FlightSection section in sections)
            {
                if (section.SeatClass.Equals(s))
                {
                    booked = section.BookSeat(row, col);
                }
            }

            return(booked);
        }
Ejemplo n.º 18
0
        // GET: SeatClass/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SeatClass SeatClass = _SeatClassRepo.SelectById(id);

            if (SeatClass == null)
            {
                return(HttpNotFound());
            }
            return(View(SeatClass));
        }
Ejemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "SeatClassId,SeatClassName")] SeatClass SeatClass)
 {
     if (!ModelState.IsValid)
     {
         return(View(SeatClass));
     }
     try
     {
         _SeatClassRepo.Update(SeatClass);
         _SeatClassRepo.Save();
     }
     catch (Exception)
     {
         // todo
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 20
0
 public void bookSeat(String air, String fl, SeatClass s, int row, char col)
 {
     if (Airlines.ContainsKey(air))
     {
         if (Airlines[air].Flights.ContainsKey(fl))
         {
             if (!Airlines[air].Flights[fl].Sections[s].bookSeat(row, col))
             {
                 Console.WriteLine("Seat already booked.");
             }
         }
     }
     if (!Airlines.ContainsKey(air))
     {
         Console.WriteLine("Airline does not exist.");
     }
 }
Ejemplo n.º 21
0
 public void SetSeatClassAndPrice()
 {
     if (_row.Equals('A'))
     {
         _seatClass = SeatClass.Gold;
         _price     = 20;
     }
     else if (_row.Equals('B') || _row.Equals('C'))
     {
         _seatClass = SeatClass.Silver;
         _price     = 15;
     }
     else if (_row.Equals('D'))
     {
         _seatClass = SeatClass.Bronze;
         _price     = 10;
     }
 }
Ejemplo n.º 22
0
        public SeatChart(object flightInfoData, User user, SeatClass seatClass) : this()
        {
            var flightInfo = (FlightInfo)flightInfoData;

            FlightInformation = flightInfo;
            UserInput         = user;
            SeatClass         = seatClass;

            var client    = new BookingServiceClient();
            var seatInfos = client.RetrieveOccupiedSeatsMatrixFromFlightId(flightInfo.FlightId).ToList();

            var dataGrid = seatClass == SeatClass.FirstClass ? firstClassSeatChartDataGrid : economyClassSeatChartDataGrid;

            //// implement the seat selection
            MapSeatData(seatInfos, seatClass, dataGrid);
            var vm = new SeatChartViewModel(true);

            DataContext = vm;
        }
Ejemplo n.º 23
0
        public Form5(Plane destinationPlane, TicketState tstate)
        {
            InitializeComponent();
            //initializig necessary list and seat state and ticket state
            seatsettings = new List <bool>();
            ticketNumber = new List <string>();
            this.tstate  = tstate;
            searvice     = Form2.serviceClass;

            this.destinationPlane     = destinationPlane;
            this.countTicketSelection = 0;
            totalPrice = 0;
            //for not allowing more click of check box then seat number
            checkboxSelected = searvice.TotalSeat;

            //getting ticket class
            sClas = searvice.SeatClassProp;
            loadSeat(destinationPlane.planeID);
        }
Ejemplo n.º 24
0
        public ActionResult UpgradeClass(int id, string userId, SeatClass newClass)
        {
            using (var proxy = new HttpClient()
            {
                BaseAddress = new Uri(_companionService)
            })
            {
                TripDTO trip = proxy.GetAsync("Trips/" + id).Result.Content.ReadAsAsync <TripDTO>().Result;

                if ((trip.Class == SeatClass.Economy && newClass == SeatClass.Business) ||
                    (trip.Class == SeatClass.Business && newClass == SeatClass.First))
                {
                    trip.Class = newClass;

                    proxy.PutAsJsonAsync("Trips/" + id, trip).Wait();
                }
            }
            return(Redirect("/Reservations"));
        }
Ejemplo n.º 25
0
        public FlightSection(SeatClass seatClass, int rows = 1, int cols = 1)
        {
            //first we throw exception
            this.SeatClass = seatClass;
            if (rows < 1 || rows > 100 || cols < 1 || cols > 10)
            {
                throw new Exception(ExceptionHelper.FlightSectionTooBig);
            }

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    Seat seatToAdd = new Seat();
                    seatToAdd.Column = Convert.ToChar('A' + j); //translates the integer value to alphabethical char
                    seatToAdd.Row    = i + 1;                   //because we want the rows to start at 1 not at 0
                    _seats[i, j]     = seatToAdd;
                }
            }
        }
Ejemplo n.º 26
0
        public void BookSeat(string airlineName, string flightId, SeatClass seatClass, string row, string col)
        {
            try
            {
                int  parsedRow;
                char parsedCol;

                if (!int.TryParse(row, out parsedRow) || !char.TryParse(col, out parsedCol))
                {
                    throw new ArgumentException("Invalid row or col");
                }

                this.sectionService.BookSeat(airlineName, flightId, seatClass, parsedRow, parsedCol);
                Console.WriteLine("Seat booked successfully");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 27
0
 //set passenger seat according to adult , child infant set class of seat
 public void setPassengers(Byte adult, Byte child, Byte infant, Byte seat, String clas)
 {
     this.adult  = adult;
     this.child  = child;
     this.infant = infant;
     totalSeat   = seat;
     this.sClas  = clas;
     if (clas == "Business")
     {
         seatClass = SeatClass.Business;
     }
     else if (clas == "Economic")
     {
         seatClass = SeatClass.Economics;
     }
     else
     {
         seatClass = SeatClass.Delux;
     }
 }
Ejemplo n.º 28
0
 public void createSection(string air, string flID, int rows, int cols, SeatClass s)
 {
     if (rows <= 100 && cols <= 10)
     {
         if (Airlines.ContainsKey(air))
         {
             if (!Airlines[air].Flights[flID].Sections.TryAdd(s, new FlightSection(air, flID, rows, cols, s)))
             {
                 Console.WriteLine("Invalid Operation: Seat class already exists.");
             }
         }
     }
     if (rows >= 100 && cols >= 10)
     {
         Console.WriteLine("Section must have no more than 100 rows and 10 columns.");
     }
     if (!Airlines.ContainsKey(air))
     {
         Console.WriteLine("Airline does not exist.");
     }
 }
Ejemplo n.º 29
0
        public bool BookSeat(Flight flight, SeatClass seatClass, int row, string col)
        {
            using (var context = new ABS())
            {
                var section = context.Sections.Where(s => s.SeatClassName == seatClass.ToString())
                              .FirstOrDefault();
                var seatToBook = context.Seats.Where(s => s.FlightId == flight.FlightId &&
                                                     s.SectionId == section.SectionId &&
                                                     s.Row == row &&
                                                     s.Col == col)
                                 .FirstOrDefault();

                if (seatToBook.Status == false)
                {
                    return(false);
                }
                seatToBook.Status = false;
                context.SaveChanges();

                return(true);
            }
        }
Ejemplo n.º 30
0
 public void CreateSection(string aName, string flightId, int rows, int cols, SeatClass s)
 {
     try
     {
         Airline       airline = _airlineRepository.Retreive(aName);
         Flight        flight  = airline.Flights.Retreive(flightId);
         FlightSection section = new FlightSection(s, rows, cols);
         if (airline == null)
         {
             throw new Exception(ExceptionHelper.NonExistentAirline);
         }
         if (flight == null)
         {
             throw new Exception(ExceptionHelper.FlightNotFound);
         }
         flight.AddFlightSection(section);
     }
     catch (Exception e)
     {
         Console.WriteLine($"{e.Message} - {aName}");
     }
 }