// GET: Flights/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Flights flights = db.Flights.Find(id);

            if (flights == null)
            {
                return(HttpNotFound());
            }
            //add comment(assuming from other table)
            var comments = db.Comments.Where(m => m.FlightsId == id).Select(x => x.content).ToList();

            ViewBag.Content = comments;

            ViewBag.FlightId = flights.Id;
            return(View(flights));
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            valid = App.IsSuperUser() &&
                    App.ListBoxHasItem(lstBoxF, 'u') &&
                    App.HasCompleteInput(4, txtDepCity.Text, txtDestCity.Text, txtDepDate.Text, txtFlightTime.Text) &&
                    App.IsDouble(txtFlightTime.Text) &&
                    App.SureAction('u');

            if (valid)
            {
                Flights fRec = App.SelectedFRec(lstBoxF);
                fRec.AirlineId       = airlineID;
                fRec.DepartureCity   = txtDepCity.Text;
                fRec.DestinationCity = txtDestCity.Text;
                fRec.DepartureDate   = txtDepDate.Text;
                fRec.FlightTime      = double.Parse(txtFlightTime.Text);

                RefreshListBox(lstBoxF.SelectedIndex);
            }
        }
    //Insert flightMethod
    public int insertFlight(Flights flight)
    {
        SqlConnection con;
        SqlCommand    cmd;

        try
        {
            con = connect("DBConnectionString"); // create the connection
        }
        catch (Exception ex)
        {
            // write to log
            throw (ex);
        }

        String cStr = BuildInsertCommandFlights(flight); // helper method to build the insert string

        cmd = CreateCommand(cStr, con);                  // create the command

        try
        {
            int numEffected = cmd.ExecuteNonQuery(); // execute the command
            return(numEffected);
        }
        catch (Exception ex)
        {
            return(0);

            //Console.WriteLine("Inside catch block. Exception: {0}", ex.Message);
            throw (ex);
        }

        finally
        {
            if (con != null)
            {
                // close the db connection
                con.Close();
            }
        }
    }
        private async void LoadFlightData()
        {
            if (this._flights.Count != 0)
            {
                return;
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/FlightData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray  jsonArray  = jsonObject["Flights"].GetArray();
            double     minPrice   = 0;
            double     maxPrice   = 0;

            foreach (JsonValue flight in jsonArray)
            {
                JsonObject flightObject = flight.GetObject();
                Flights.Add(new FlightDataItem(flightObject["DepartureCity"].GetString(),
                                               flightObject["DestinationCity"].GetString(),
                                               flightObject["Price"].GetNumber(),
                                               flightObject["DepartureTime"].GetString(),
                                               flightObject["ArrivalTime"].GetString(),
                                               Convert.ToInt32(flightObject["NumberOfConnections"].GetNumber())));

                if (minPrice == 0 || flightObject["Price"].GetNumber() < minPrice)
                {
                    minPrice = flightObject["Price"].GetNumber();
                }

                if (maxPrice == 0 || flightObject["Price"].GetNumber() > maxPrice)
                {
                    maxPrice = flightObject["Price"].GetNumber();
                }
            }

            SelectedPrice = maxPrice;
        }
Exemple #5
0
        static void Main(string[] args)
        {
            // Creating a flight collection.
            Flights flights = new Flights();

            flights.Add(new Flight()
            {
                Name = "Flight-1", Company = "Company-1", AirlineCountry = "USA"
            });
            flights.Add(new Flight()
            {
                Name = "Flight-2", Company = "Company-1", AirlineCountry = "GERMANY"
            });
            flights.Add(new Flight()
            {
                Name = "Flight-3", Company = "Company-2", AirlineCountry = "INDIA"
            });
            flights.Add(new Flight()
            {
                Name = "Flight-4", Company = "Company-3", AirlineCountry = "FRANCE"
            });

            // Testing Code
            var inputData = new StringBuilder();

            // Printing Sample Data
            Console.WriteLine($"Name    Company     AirlineCountry");
            flights.Cast <Flight>().ToList().ForEach(f =>
            {
                Console.WriteLine($"{f.Name}    {f.Company}     {f.AirlineCountry}");
            });


            Test(flights, "Name");
            Test(flights, "Company");
            Test(flights, "AirlineCountry");

            Console.WriteLine("Test Completed!");
            Console.WriteLine("press any key to exit.");
            Console.ReadKey();
        }
        public async Task <ActionResult <Flights> > GetFlightById(int flightid)
        {
            AuthenticateAndGetTokenAndGetFacade(out LoginToken <Customers>
                                                token_customer, out LoggedInCustomerFacade facade);

            Flights result = null;

            try
            {
                result = await Task.Run(() => facade.GetFlightById(flightid));
            }
            catch (Exception ex)
            {
                return(StatusCode(400, $"{{ error: \"{ex.Message}\" }}"));
            }
            if (result == null)
            {
                return(StatusCode(204, "{ }"));
            }
            return(Ok(result));
        }
        public async Task <IActionResult> UpdateFlightDetails(int id, Flights flightDetails)
        {
            if (id != flightDetails.Flightid)
            {
                return(BadRequest());
            }


            try
            {
                //_log4net.Info("update tacos with id " + id + "method is invoked");

                await repo.UpdateFlight(id, flightDetails);
            }
            catch (Exception)
            {
                return(BadRequest("Update Flight details failed!"));
            }

            return(NoContent());
        }
Exemple #8
0
 public IActionResult UpdateFlight(int id, [FromBody] Flights newflight)
 {
     _log4net.Info(" Http UpdateFlight request Initiated");
     if (id == 0 || newflight == null)
     {
         return(BadRequest());
     }
     try
     {
         int res = repo.UpdateFlight(id, newflight);
         if (res == 1)
         {
             return(Ok());
         }
         return(BadRequest());
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemple #9
0
        private static void AddNewOutgoingFlightCommand(Flight obj)
        {
            var flight = new Flight
            {
                FlightNumber = CurrentOutgoingFlight.FlightNumber,
                FlightState  = FlightState.WaitingForPreparation,
                BaggageCount = CurrentOutgoingFlight.BaggageCount,
                Gate         = CurrentOutgoingFlight.Gate,
                TimeToFlightSinceSimulationStart            = CurrentOutgoingFlight.TimeToFlightSinceSimulationStart,
                TimeToFlightPreparationSinceSimulationStart = CurrentOutgoingFlight.TimeToFlightPreparationSinceSimulationStart
            };

            if (!FlightWithNumberExists(OutgoingFlights, CurrentOutgoingFlight.FlightNumber))
            {
                OutgoingFlights.Add(flight);
                Flights.Add(flight);
                return;
            }

            MessageBox.Show($"An outgoing flight with number {CurrentOutgoingFlight.FlightNumber} already exists!");
        }
Exemple #10
0
        public void CloseLane(int laneId)
        {
            ScannerFlight l2fObj = null;

            using (var ds = new DataSeed()) {
                l2fObj = ScannerFlights.FirstOrDefault(p => p.LaneId == laneId);
                if (l2fObj == null)
                {
                    return;
                }
                ds.CloseLane(l2fObj.Flight2LaneId);
                ScannerFlights.Remove(l2fObj);
                if (ScannerFlights.Where(s => s.FlightId == l2fObj.FlightId).Count() == 0)
                {
                    ds.ChangeFlightStatus(l2fObj.FlightId, (int)Enums.FlightStatus.Closed);
                    CloseFlightId = l2fObj.FlightId;
                    Flights.FirstOrDefault(f => f.Id == l2fObj.FlightId).StatusId = 2;
                }
                CloseLaneStatus = "The " + Lanes.FirstOrDefault(p => p.Id == laneId)?.Color + " Lane from Flight " + l2fObj.FlightNumber + " was closed.";
            }
        }
Exemple #11
0
        private static void AddNewIncomingFlightCommand(Flight obj)
        {
            var flight = new Flight
            {
                FlightNumber = CurrentIncomingFlight.FlightNumber,
                FlightState  = FlightState.Incoming,
                BaggageCount = CurrentIncomingFlight.BaggageCount,
                Gate         = CurrentIncomingFlight.Gate,
                PickUpArea   = CurrentIncomingFlight.PickUpArea,
                TimeToFlightSinceSimulationStart = CurrentIncomingFlight.TimeToFlightSinceSimulationStart
            };

            if (!FlightWithNumberExists(IncomingFlights, CurrentIncomingFlight.FlightNumber))
            {
                IncomingFlights.Add(flight);
                Flights.Add(flight);
                return;
            }

            MessageBox.Show($"An incoming flight with number {CurrentIncomingFlight.FlightNumber} already exists!");
        }
Exemple #12
0
        async void LoadMore()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            await Task.Delay(1000);// fake delay to see the activity

            FlightsToDisplay.AddRange(
                Flights.Skip(batchSize * currentFlightIndex).Take(batchSize)
                );
            currentFlightIndex += batchSize;


            IsBusy = false;

            Debug.WriteLine($"You now have: {FlightsToDisplay.Count}");
        }
        public static List <Flights> GetAll()
        {
            List <Flights> flights = new List <Flights>();

            try
            {
                using (var con = new MySqlConnection(connectionString))
                {
                    string       query = "SELECT * FROM  flights";
                    MySqlCommand cmd   = new MySqlCommand(query, con);

                    MySqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Flights flight = new Flights()
                                {
                                    FlightId   = int.Parse(reader["flightId"].ToString()),
                                    FlightName = reader["flightName"].ToString(),
                                    Capacity   = int.Parse(reader["capacity"].ToString())
                                };
                                flights.Add(flight);
                            }
                            reader.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                throw new Exception("Error while connecting with database, please contact site admin for more detail.");
            }

            return(flights);
        }
Exemple #14
0
        public List <Flights> FlightAvailability(string StartDate, string EndDate, int NoOfPassenger)
        {
            _logger.LogInformation("Flight Availability details send");
            List <Flights> flightList = new List <Flights>();

            try
            {
                var flight = new Flights
                {
                    StartDate    = Convert.ToDateTime(StartDate),
                    EndDate      = Convert.ToDateTime(EndDate),
                    PassCapacity = NoOfPassenger
                };
                flightList = _FlightRepository.FlightAvailability(flight).ToList();
                _logger.LogInformation("FlightAvailability list send", flightList);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Got exception.");
            }
            return(flightList);
        }
Exemple #15
0
        private static void Test(Flights inputFlights, string testColumnName)
        {
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine($"Provide flight {testColumnName} to search");

            var inputText = Console.ReadLine();

            var searchResult = new List <Flight>();

            switch (testColumnName.ToLower())
            {
            case "name":
                searchResult = inputFlights.Cast <Flight>().Filter(f => f.Name.ToLower() == inputText.ToLower()).ToList();
                break;

            case "company":
                searchResult = inputFlights.Cast <Flight>().Filter(f => f.Company.ToLower() == inputText.ToLower()).ToList();
                break;

            case "airlinecountry":
                searchResult = inputFlights.Cast <Flight>().Filter(f => f.AirlineCountry.ToLower() == inputText.ToLower()).ToList();
                break;
            }


            var result = searchResult.Cast <Flight>().ToList();

            if (result.Count == 0)
            {
                Console.WriteLine("No Record Found");
            }
            else
            {
                searchResult.Cast <Flight>().ToList().ForEach(f =>
                {
                    Console.WriteLine($"{f.Name}    {f.Company}     {f.AirlineCountry}");
                });
            }
        }
        private static List <Flights> ParserList(IEnumerable <AzulFlights> azulFlights)
        {
            var Flights = new List <Flights>();

            foreach (var azulFlight in azulFlights)
            {
                if (azulFlights.Count() > 0)
                {
                    var flight = new Flights();
                    flight.Date    = azulFlight.Data;
                    flight.Arrival = new Locality {
                        IATA = azulFlight.Destino.IATA, Name = azulFlight.Destino.Nome
                    };
                    flight.Departure = new Locality {
                        IATA = azulFlight.Origem.IATA, Name = azulFlight.Origem.Nome
                    };
                    flight.Source = azulFlight.Compania;
                    Flights.Add(flight);
                }
            }
            return(Flights);
        }
        private void CmdAnalizeNow_Execute(object obj)
        {
            var filePath = DialogTools.ShowFolderPickerDialog("Select the images folder");

            if (!string.IsNullOrEmpty(filePath))
            {
                var wdw = new AnalyzeImages()
                {
                    FilePath = filePath,
                    Owner    = this
                };
                wdw.ShowDialog();

                var missingLocations = wdw.DetectedFires.Where((f) => f.Longitude == 0 && f.Latitude == 0);
                if (missingLocations.Any())
                {
                    var imageLocation = ResolveLocation.Resolve(true);
                    if (imageLocation != null)
                    {
                        foreach (var l in missingLocations)
                        {
                            l.Latitude  = imageLocation[0];
                            l.Longitude = imageLocation[1];
                        }
                    }
                }

                var flight = new Flight(wdw.DetectedFires, wdw.CoveredArea, filePath, new MapModel(BmpPlanner));
                Flights.Add(flight);
                NotifyPropertyChanged("Flights");

                AreasOfInterest.AddToAnalizedArea(flight);
                AreasOfInterest.NotifyAllPropertyChanged("AnalizedAreaPercentage");
                NotifyPropertyChanged("AreasOfInterest");

                wdw.Close();
                RenderMap();
            }
        }
Exemple #18
0
        public static void InsertFlight(Flights flightModel)
        {
            SqlConnection cnn = new SqlConnection(cnnString);
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection  = cnn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "spInsertFlights";
            cmd.Parameters.Add("@Duration", SqlDbType.Int).Value                = flightModel.Duration;
            cmd.Parameters.Add("@LocationFrom", SqlDbType.VarChar).Value        = flightModel.LocationFrom;
            cmd.Parameters.Add("@LocationTo", SqlDbType.VarChar).Value          = flightModel.LocationTo;
            cmd.Parameters.Add("@TimeOfFlight", SqlDbType.SmallDateTime).Value  = flightModel.TimeOfFlight;
            cmd.Parameters.Add("@TimeOfArrival", SqlDbType.SmallDateTime).Value = flightModel.TimeOfArrival;
            cmd.Parameters.Add("@TypeOfPlane", SqlDbType.VarChar).Value         = flightModel.TypeOfPlane;
            cmd.Parameters.Add("@UniqueNumberOfPlane", SqlDbType.VarChar).Value = flightModel.UniqueNumberOfPlane;
            cmd.Parameters.Add("@NamePilot", SqlDbType.VarChar).Value           = flightModel.NamePilot;
            cmd.Parameters.Add("@CapacityOfPassengers", SqlDbType.Int).Value    = flightModel.CapacityOfPassengers;
            cmd.Parameters.Add("@CapacityBusinessClass", SqlDbType.Int).Value   = flightModel.CapacityBusinessClass;
            cnn.Open();
            _ = cmd.ExecuteScalar();
            cnn.Close();
        }
        private static List <Flights> ParserList(IEnumerable <AviancaFlights> aviancaFlights)
        {
            var Flights = new List <Flights>();

            foreach (var aviancaFlight in aviancaFlights)
            {
                if (aviancaFlights.Count() > 0)
                {
                    var flight = new Flights();
                    flight.Date    = aviancaFlight.Date;
                    flight.Arrival = new Locality {
                        IATA = aviancaFlight.Arrival.IATA, Name = aviancaFlight.Arrival.Name
                    };
                    flight.Departure = new Locality {
                        IATA = aviancaFlight.Departure.IATA, Name = aviancaFlight.Departure.Name
                    };
                    flight.Source = aviancaFlight.Source;
                    Flights.Add(flight);
                }
            }
            return(Flights);
        }
        /// <summary>
        /// Updates the current flight' checkpoint
        /// </summary>
        /// <param name="flight">the current flight</param>
        /// <param name="newCheckpointSerial">the next checkpoint's serial</param>
        /// <param name="lastCheckpointSerial">the last checkpoint's serial</param>
        /// <param name="isNew">indicates if the flight is not alive</param>
        public void UpdateFlight(Flight flight, int newCheckpointSerial, int lastCheckpointSerial, bool isNew)
        {
            //if the flight is new, it's alive state is modified
            if (isNew)
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).IsAlive = true;
            }

            //f the last checkpoint's serial is 8, it's the depart checkpoint
            if (lastCheckpointSerial == 8)
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
                    Checkpoints.FirstOrDefault(cp => cp.CheckpointType == CheckpointType.RunwayDeparting.ToString());
            }
            //all other checkpoints will be updated by the new checkpoint serial
            else
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
                    Checkpoints.FirstOrDefault(cp => cp.Serial == newCheckpointSerial);
            }
            SaveChanges();
        }
Exemple #21
0
        public void Execute(object parameter)
        {
            Flights flights = null;
            string  key     = GenerateUniqueKey();

            if (!FlightsCache.ContainsKey(key))
            {
                FlightsResults flightsResults = Task.Run(() => Search()).Result;
                flights     = Result(flightsResults);
                flights.Key = key;
                FlightsCache.Add(key, flights);
            }
            else
            {
                flights = FlightsCache[key];
            }

            DisplayFlights displayFlightsWindow = new DisplayFlights();

            ((DisplayFlightsViewModel)displayFlightsWindow.DataContext).FlightResults = flights.Results;
            displayFlightsWindow.ShowDialog();
        }
Exemple #22
0
        // Get all internal Flights from the data base.
        public List <Flights> GetFlights(DateTime time)
        {
            List <Flights> flights = new List <Flights>();

            OpenConnection();
            // Get all Flights's initialLocation.
            SqliteDataReader query = GetAllInitialLocationsQuery();

            // For each location.
            while (query.Read())
            {
                // Checks if the Flight of the current location is currently flying.
                Flights flight1 = LocationIterationCurrentFlights(time, query);
                if (flight1 != null)
                {
                    flights.Add(flight1);
                }
            }
            query.Close();
            CloseConncetion();
            return(flights);
        }
Exemple #23
0
        public async Task <ActionResult> Create([FromForm] Flights f)
        {
            //GET all airplanes
            var airplanes = await AirplaneRepo.GetAllAirplanesAsync();

            ViewData["Airplanes"] = new SelectList(airplanes, "Id", "Model");
            //GET all airports
            var airports = await AirportRepo.GetAllAirportsAsync();

            ViewData["Airports"] = new SelectList(airports, "Name", "Name");
            if (ModelState.IsValid)
            {
                try
                {
                    Flights flight = new Flights
                    {
                        Id                   = new Guid(),
                        FlightNumber         = f.FlightNumber,
                        AirportDepartureName = f.AirportDepartureName,
                        AirportArrivalName   = f.AirportArrivalName,
                        DepartureTime        = f.DepartureTime,
                        ArrivalTime          = f.ArrivalTime,
                        AirplaneId           = f.AirplaneId
                    };
                    // TODO: Add insert logic here
                    await FlightsRepo.Add(flight);

                    return(RedirectToAction(nameof(Index)));
                }
                catch
                {
                    return(View(f));
                }
            }
            else
            {
                return(View(f));
            }
        }
        private static List <Flights> ParserList(IEnumerable <PassaredoFlights> passaredoFlights)
        {
            var Flights = new List <Flights>();

            foreach (var passaredoFlight in passaredoFlights)
            {
                if (passaredoFlights.Count() > 0)
                {
                    var flight = new Flights();
                    flight.Date    = passaredoFlight.Dates;
                    flight.Arrival = new Locality {
                        IATA = passaredoFlight.Origine.IATA, Name = passaredoFlight.Origine.Nom
                    };
                    flight.Departure = new Locality {
                        IATA = passaredoFlight.Destination.IATA, Name = passaredoFlight.Destination.Nom
                    };
                    flight.Source = passaredoFlight.Compagnie;
                    Flights.Add(flight);
                }
            }
            return(Flights);
        }
Exemple #25
0
        private Flights[] SortByOpp(Flights[] fs, string oper)
        {
            Flights[] sorted = new Flights[] { };
            if (fs.Length > 0)
            {
                switch (oper)
                {
                case "maincabin_asc":
                    sorted = Services.SortFlights.CabinAsc(fs);
                    break;

                case "maincabin_dsc":
                    sorted = Services.SortFlights.CabinDsc(fs);
                    break;

                case "firstclass_asc":
                    sorted = Services.SortFlights.FirstClassAsc(fs);
                    break;

                case "firstclass_dsc":
                    sorted = Services.SortFlights.FirstClassDsc(fs);
                    break;

                case "departs_asc":
                    sorted = Services.SortFlights.DepartAsc(fs);
                    break;

                case "departs_dsc":
                    sorted = Services.SortFlights.DepartDsc(fs);
                    break;

                default:
                    sorted = fs;
                    break;
                }
            }
            return(sorted);
        }
Exemple #26
0
 // Function that checks if the givven flight is proper.
 public static bool CheckFlights(Flights flight)
 {
     if (flight == null)
     {
         return(false);
     }
     if (flight.Company_name == default ||
         flight.Date_time == default ||
         flight.Flight_id == default ||
         flight.Passengers <= 0)
     {
         return(false);
     }
     if (!CheckLatitude(flight.Latitude))
     {
         return(false);
     }
     if (!CheckLongitude(flight.Longitude))
     {
         return(false);
     }
     return(true);
 }
        private static List <Flights> ParserList(IEnumerable <LatamFlights> latamFlights)
        {
            var Flights = new List <Flights>();

            foreach (var latamFlight in latamFlights)
            {
                if (latamFlights.Count() > 0)
                {
                    var flight = new Flights();
                    flight.Date    = latamFlight.Fecha;
                    flight.Arrival = new Locality {
                        IATA = latamFlight.Destinos.IATA, Name = latamFlight.Destinos.Nombre
                    };
                    flight.Departure = new Locality {
                        IATA = latamFlight.Origen.IATA, Name = latamFlight.Origen.Nombre
                    };
                    flight.Source = latamFlight.Empresa;
                    Flights.Add(flight);
                }
            }

            return(Flights);
        }
Exemple #28
0
        private static void DeleteFlight(string flightNumber)
        {
            var flight = Flights.FirstOrDefault(x => x.FlightNumber == flightNumber);

            if (flight == null)
            {
                MessageBox.Show("Flight could not be found!");
                return;
            }

            Flights.Remove(flight);

            switch (flight.FlightState)
            {
            case FlightState.Incoming:
                IncomingFlights.Remove(flight);
                break;

            case FlightState.WaitingForPreparation:
                OutgoingFlights.Remove(flight);
                break;
            }
        }
Exemple #29
0
        public ActionResult ReservationInsert(Reservations reservationsModel)
        {
            int     id         = reservationsModel.Id;
            Flights passangers = Procedures.Procedures.SelectColumnPassangers(id);

            if (reservationsModel.TypeOfTicket == "First class" && passangers.CapacityBusinessClass > 0)
            {
                Procedures.Procedures.ChangeCapacityBusinessClass(id);
                Procedures.Procedures.Reservation(reservationsModel);
                SendEmail(reservationsModel, "Successfully made reservation!", $"We wish you wonderful trip! You're flight is {reservationsModel.NameOfFlight} and you're type of ticket is {reservationsModel.TypeOfTicket}.");
            }
            else if (reservationsModel.TypeOfTicket == "Second class" && passangers.CapacityOfPassengers > 0)
            {
                Procedures.Procedures.ChangeCapacityOfPassengers(id);
                Procedures.Procedures.Reservation(reservationsModel);
                SendEmail(reservationsModel, "Successfully made reservation!", $"We wish you wonderful trip! You're flight is {reservationsModel.NameOfFlight} and you're type of ticket is {reservationsModel.TypeOfTicket}.");
            }
            else
            {
                SendEmail(reservationsModel, "Unsuccessfully made reservation!", $"Sorry out of space for the fligth {reservationsModel.NameOfFlight}!");
            }
            return(View("Index"));
        }
        private static List <Flights> ParserList(IEnumerable <GolFlights> golFlights)
        {
            var Flights = new List <Flights>();

            foreach (var golFlight in golFlights)
            {
                if (golFlights.Count() > 0)
                {
                    var flight = new Flights();
                    flight.Date    = golFlight.Datum;
                    flight.Arrival = new Locality {
                        IATA = golFlight.Ziel.IATA, Name = golFlight.Ziel.Name
                    };
                    flight.Departure = new Locality {
                        IATA = golFlight.Herkunft.IATA, Name = golFlight.Herkunft.Name
                    };
                    flight.Source = golFlight.Firma;
                    Flights.Add(flight);
                }
            }

            return(Flights);
        }
Exemple #31
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Database db = new Database();
        string fromCity = Request.QueryString["from"];
        string toCity = Request.QueryString["to"];
        string start = Request.QueryString["start"];
        string company = Request.QueryString["company"];
        string direct = Request.QueryString["direct"];
        string filter = Request.QueryString["filter"];
        string end = "-1";
        string addon = "";
        if (company != "Any")
        {
            addon += " and companyname='" + company + "'";

        }
        if (filter == "cost")
        {
            addon += " order by price";
        }
        else
        {
            addon += " order by lengthminutes";
        }
        if (!String.IsNullOrEmpty(Request.QueryString["end"]))
        {
            end = Request.QueryString["end"];
        }
        else
        {
            Session.Remove("end");
        }

        if (direct == true.ToString())
        {
            foreach (LinkedList<string> row in db.query("select fromcity, tocity, starttime, lengthminutes, price, companyname, flightid from (" + Database.flightTable + " where fromCity='" + fromCity + "' and toCity='" + toCity + "' and starttime>to_timestamp('" + start + "', 'DD MON, YYYY')-1 and starttime>current_timestamp and availableseats>0" + addon + ") where rownum<4"))
            {
                string back = "";
                string times = "";
                string timee = "";
                string cost = "";
                string id = "";
                DateTime li = DateTime.Parse(row.ElementAt(2));
                li.AddMinutes(Int32.Parse(row.ElementAt(3)));
                if (end != "-1")
                {
                    back = "<div class='crta'>-</div>" + "<div class='from'>" + row.ElementAt(0) + "</div>";
                    foreach (LinkedList<string> row2 in db.query("select fromcity, tocity, starttime, lengthminutes, price, companyname, flightid from (" + Database.flightTable + " where fromCity='" + toCity + "' and toCity='" + fromCity + "' and starttime>to_timestamp('" + end + "', 'DD MON, YYYY')-1 and starttime>to_timestamp('" + row.ElementAt(2) + "', 'DD.MM.YYYY HH24:MI:SS') and starttime>current_timestamp and availableseats>0" + addon + ") where rownum<2"))
                    {
                        DateTime li2 = DateTime.Parse(row2.ElementAt(2));
                        li2.AddMinutes(Int32.Parse(row2.ElementAt(3)));
                        times = "<div class='od' style='margin-left: 20px;'>Време на полетување:</div>" + "<div class='fromtime'>" + row2.ElementAt(2) + "</div>";
                        timee = "<div class='od' style='margin-left: 20px;'>Време на слетување:</div>" + "<div class='fromtime'>" + li2.ToString("d.MM.yyyy HH:MM:s") + "</div>";
                        cost = "<div class='text'>Цена:</div>" + "<div class='cena'>" + row2.ElementAt(4) + " &euro;</div>" + "<div class='text'>&nbsp;&nbsp;&nbsp;Компанија:</div>" + "<div class='cena'>" + row2.ElementAt(5) + "</div>";
                        id = "-" + row2.ElementAt(6);
                    }
                }
                holder.InnerHtml += "<div class='result1' onclick='window.location.href=\"Bagage.aspx?q=" + row.ElementAt(6) + id + "\"'>" +
            "<div class='from'>" + row.ElementAt(0) + "</div>" +
            "<div class='crta'>-</div>" +
            "<div class='to'>" + row.ElementAt(1) + "</div>" + back +
            "<div class='time'>" +
                "<div class='eden'>" +
                    "<div class='od' style='width:20%; text-align:left'>Време на полетување:</div>" +
                    "<div class='fromtime' style='width:20%; text-align:left'>" + row.ElementAt(2) + "</div>" + times +
                "</div>" +
                "<div class='dva'>" +
                    "<div class='do' style='width:20%; text-align:left'>Време на слетување:</div>" +
                    "<div class='totime' style='width:20%; text-align:left'>" + li.ToString("d.MM.yyyy HH:MM:s") + "</div>" + timee +
                "</div>" +
                "<div class='tri'>" +
                    "<div class='text'>Цена:</div>" +
                    "<div class='cena' style='width:10%; text-align:left'>" + row.ElementAt(4) + " &euro;</div>" +
                    "<div class='text' style='width:10%; text-align:left'>Компанија:</div>" +
                    "<div class='cena' style='width:15%; text-align:left'>" + row.ElementAt(5) + "</div>" + cost +
                "</div>" +
            "</div>" +
        "</div>";
            }
        }
        else
        {
            Flights flights = new Flights(db.query("select fromcity, tocity, starttime, lengthminutes, price, flightid from (" + Database.flightTable + " where starttime>to_timestamp('" + start + "', 'DD MON, YYYY')-1 and starttime>current_timestamp and availableseats>0 order by starttime asc)"));

            LinkedList<Path> res1 = flights.getAllPaths(fromCity, toCity);
            if (res1 == null)
            {
                holder.InnerHtml = "<span style='color: black; font-size: 14px;'><a href='Default.aspx'>Нема таков лет</a></span>";
                return;
            }
            foreach (Path p in res1)
            {
                if (p.path == null) break;
                string back = "";
                string times = "";
                string timee = "";
                int cost = 0;
                int cost2 = 0;
                string costaddon = "";
                string id = "";
                foreach (Flight f in p.path)
                {
                    id += f.id + "-";
                    cost += f.price;
                }
                if (end != "-1")
                {
                    Flights flights2 = new Flights(db.query("select fromcity, tocity, starttime, lengthminutes, price, flightid from (" + Database.flightTable + " where starttime>to_timestamp('" + start + "', 'DD MON, YYYY')-1 and starttime>current_timestamp and starttime>to_timestamp('" + p.path.Last().end().ToString("dd.MM.yyyy HH:mm:ss") + "', 'DD.MM.YYYY HH24:MI:SS') and availableseats>0 order by starttime asc)"));
                    LinkedList<Path> res2 = flights2.getAllPaths(fromCity, toCity);
                    if (res2 == null)
                    {
                        holder.InnerHtml = "<span style='color: black; font-size: 14px;'><a href='Default.aspx'>Нема таков лет</a></span>";
                        return;
                    }
                    foreach (Path p2 in res2)
                    {
                        if (p2.path == null)
                        {
                            continue;
                        }
                        times = "<div class='od' style='margin-left: 20px;'>Време на полетување:</div>" + "<div class='fromtime'>" + p2.path.First().at.ToString("d.MM.yyyy HH:MM:s") + "</div>";
                        timee = "<div class='od' style='margin-left: 20px;'>Време на слетување:</div>" + "<div class='fromtime'>" + p2.path.Last().end().ToString("d.MM.yyyy HH:MM:s") + "</div>";

                        foreach (Flight f in p2.path)
                        {
                            id += f.id + "-";
                            cost2 += f.price;
                        }
                        costaddon = "<div class='cena' style='width:10%; text-align:left'>" + cost2.ToString() + " &euro;</div>";
                    }
                    back = "<div class='crta'>-</div>" + "<div class='from'>" + fromCity + "</div>";
                }
                id = id.Substring(0, id.Length - 1);
                holder.InnerHtml += "<div class='result1' onclick='window.location.href=\"Bagage.aspx?q=" + id + "\"'>" +
            "<div class='from'>" + fromCity + "</div>" +
            "<div class='crta'>-</div>" +
            "<div class='to'>" + toCity + "</div>" + back +
            "<div class='time'>" +
                "<div class='eden'>" +
                    "<div class='od' style='width:20%; text-align:left'>Време на полетување:</div>" +
                    "<div class='fromtime' style='width:20%; text-align:left'>" + p.path.First().at.ToString("d.MM.yyyy HH:MM:s") + "</div>" + times +
                "</div>" +
                "<div class='dva'>" +
                    "<div class='do' style='width:20%; text-align:left'>Време на слетување:</div>" +
                    "<div class='totime' style='width:20%; text-align:left'>" + p.path.Last().end().ToString("d.MM.yyyy HH:MM:s") + "</div>" + timee +
                "</div>" +
                "<div class='tri'>" +
                    "<div class='text'>Цена:</div>" +
                    "<div class='cena' style='width:10%; text-align:left'>" + cost.ToString() + " &euro;</div>" +
                    costaddon +
                "</div>" +
            "</div>" +
        "</div>";
            }
        }
        if (holder.InnerHtml.Length < 1)
        {
            holder.InnerHtml = "<span style='color: black; font-size: 14px;'><a href='Default.aspx'>Нема таков лет</a></span>";
        }
    }