コード例 #1
0
        public void GetAllFlightsVacancy()
        {
            countryDAO.Add(new Country("Israel"));
            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));
            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 12, FlightStatus.NotDeparted));
            Flight flightOne = flightDAO.GetAll()[0];
            Flight flightTwo = flightDAO.GetAll()[1];

            Assert.AreEqual(30, facade.GetAllFlightsVacancy()[flightOne]);
            Assert.AreEqual(12, facade.GetAllFlightsVacancy()[flightTwo]);
        }
コード例 #2
0
        internal void GetRandomFlights(int number)
        {
            int counter = 0;

            try
            {
                for (int i = 0; i < _airlines.Count; i++)
                {
                    AirlineCompany a = _airlineDao.GetAirlineByUserName(_airlines[i].UserName);
                    for (int j = 0; j < number; j++)
                    {
                        Flight f = new Flight();
                        f.DepartureTime          = CreateRandomDate();
                        f.LandingTime            = CreateRandomDate();
                        _randomNum               = _random.Next(100, 350);
                        f.RemainingTickets       = _randomNum;
                        _randomNum               = _random.Next(0, _countries.Count);
                        f.DestinationCountryCode = _countries[_randomNum].Id;
                        _randomNum               = _random.Next(0, _countries.Count);
                        f.OriginCountryCode      = _countries[_randomNum].Id;
                        f.AirlineCompanyId       = a.Id;
                        _flightDao.Add(f);
                        _flights.Add(f);
                        counter++;
                        ProgressValue += Convert.ToInt32(1.0 / Total * 100);
                    }
                }
                Message += $"Created Airline Flights {counter}/{number} per airline company\n";
                _flights = _flightDao.GetAll().ToList();
            }
            catch (Exception e)
            {
                Message += $"{e.ToString()}\n";
            }
        }
コード例 #3
0
        internal void AddRandomFlights(int number)
        {
            int counter = 0;

            try
            {
                _flights.AddRange(_flightDAO.GetAll().ToList());

                for (int i = 0; i < _airlineCompanies.Count; i++)
                {
                    AirlineCompany c = _airlineDAO.GetAirLineByUserName(_airlineCompanies[i].UserName);
                    Flight         f = new Flight();
                    f.Departure_Time           = AddRandomDate();
                    f.Landing_Time             = AddRandomDate();
                    _randomNum                 = _random.Next(100, 350);
                    f.Remaining_Tickets        = _randomNum;
                    _randomNum                 = _random.Next(0, _countries.Count);
                    f.Destination_Country_Code = _countries[_randomNum].Id;
                    _randomNum                 = _random.Next(0, _countries.Count);
                    f.Origin_Country_Code      = _countries[_randomNum].Id;
                    f.AirlineCompany_Id        = c.ID;
                    _flightDAO.Add(f);
                    _flights.Add(f);
                    counter++;
                    ProgressValue += Convert.ToInt32(1.0 / Total * 100);

                    Message += $"Created Flights {counter}/{number} per airline company\n";
                }
            }
            catch (Exception e)
            {
                Message += $"{e.ToString()}\n";
            }
        }
コード例 #4
0
        public List <Flight> GetAllMyFlights(LoginToken <Customer> token)
        {
            List <Flight> flights = new List <Flight>();

            if (token != null)
            {
                _flightDAO = new FlightDAOMSSQL();
                flights    = _flightDAO.GetAll();
            }
            return(flights);
        }
コード例 #5
0
        public List <Flight> GetAllFlights(LoginToken <AirlineCompany> token)
        {
            List <Flight> resList = new List <Flight>();

            if (token != null)
            {
                _flightDAO = new FlightDAOMSSQL();
                resList    = _flightDAO.GetAll();
            }
            return(resList);
        }
コード例 #6
0
        public IList <Flight> GetAllMyFlights(LoginToken <CustomerLogin> token)
        {
            IList <Flight> list = new List <Flight>();

            _flightDAO = new FlightDAOMSSQL();
            if (token.User.GetCustomer())
            {
                list = _flightDAO.GetAll();
                return(list);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        /// <summary>
        /// method that selects the appropriate method for adding a a database member depending on the this class Generic parameter ("T")
        /// </summary>
        private void Initialize()
        {
            _countries        = _countryDAO.GetAll();
            _airlineCompanies = _airlineCompanyDAO.GetAll();
            _flights          = _flightDAO.GetAll();
            _customers        = _customerDAO.GetAll();

            _utility_user_types.Add(typeof(Administrator));
            _utility_user_types.Add(typeof(Customer));
            _utility_user_types.Add(typeof(AirlineCompany));



            _genericTypeMethodCorrelation.Add(typeof(Customer), AddCustomers);
            _genericTypeMethodCorrelation.Add(typeof(Administrator), AddAdministrators);
            _genericTypeMethodCorrelation.Add(typeof(Flight), AddFlights);
            _genericTypeMethodCorrelation.Add(typeof(Country), this.AddCountries);
            _genericTypeMethodCorrelation.Add(typeof(AirlineCompany), this.AddAirlineCompanies);
            _genericTypeMethodCorrelation.Add(typeof(Ticket), this.AddTickets);
            //add more "Add["type_name"]" functions to the dictionary when they created
        }
コード例 #8
0
 public List <Flight> GetAllFlights()
 {
     _flightDAO = new FlightDAOMSSQL();
     return(_flightDAO.GetAll());
 }
コード例 #9
0
        public void CancelTicket()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));

            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            Flight flightOne = flightDAO.GetAll()[0];

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));
            customerDAO.Add(new Customer("FIRSTNAME2", "LASTNAME2", "USERNAME2", "PASSWORD2", "ADDRESS2", "PNUMBER2", "CNUMBER2"));
            Customer customerOne = customerDAO.GetAll()[0];
            Customer customerTwo = customerDAO.GetAll()[1];

            LoginToken <Customer> customerLoggedIn = new LoginToken <Customer>();

            customerLoggedIn.user = customerOne;

            ticketDAO.Add(new Ticket(flightOne.ID, customerOne.ID));
            ticketDAO.Add(new Ticket(flightOne.ID, customerTwo.ID));
            Ticket ticketOne = ticketDAO.GetAll()[0];

            flightOne = flightDAO.GetAll()[0];

            Assert.AreEqual(28, flightOne.RemainingTickets);
            facade.CancelTicket(customerLoggedIn, ticketOne);
            flightOne = flightDAO.GetAll()[0];
            Assert.AreEqual(29, flightOne.RemainingTickets);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }
コード例 #10
0
        public void CancelFlight()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));
            airlineDAO.Add(new AirlineCompany("ARKIA", "ARKIAYSERNAME", "ARKIAPASSWORD", countryDAO.GetCountryByName("Israel").ID));

            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ARKIA").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));

            ticketDAO.Add(new Ticket(flightDAO.GetAll()[0].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));
            ticketDAO.Add(new Ticket(flightDAO.GetAll()[1].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));

            Assert.AreEqual(2, flightDAO.GetAll().Count);
            Assert.AreEqual(2, ticketDAO.GetAll().Count);

            LoginToken <AirlineCompany> airlineLoggenIn = new LoginToken <AirlineCompany>();

            airlineLoggenIn.user = airlineDAO.GetAirlineByName("ELAL");
            facade.CancelFlight(airlineLoggenIn, flightDAO.GetAll()[0]);
            Assert.AreEqual(1, flightDAO.GetAll().Count);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }