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);
        }
        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";
            }
        }
예제 #3
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";
            }
        }
 public void CreateFlight(LoginToken <AirlineCompany> token, Flight flight)
 {
     if (token != null)
     {
         _flightDAO = new FlightDAOMSSQL();
         _flightDAO.Add(flight);
     }
 }
예제 #5
0
        public void AnonymousrFacadeTest()
        {
            FlightDAOMSSQL flightsHandler = new FlightDAOMSSQL();

            flightsHandler.RemoveAll();
            #region filling the flights table
            CountryDAOMSSQL c = new CountryDAOMSSQL();
            c.RemoveAll();
            AirlineDAOMSSQL airline = new AirlineDAOMSSQL();
            airline.RemoveAll();
            Country c1 = new Country("israel");
            c.Add(c1);
            AirlineCompany airline1 = new AirlineCompany("eldal", "maher", "123", c1.Id);
            airline.Add(airline1);
            DateTime t  = new DateTime(2019, 05, 05, 21, 22, 44);
            DateTime t1 = new DateTime(2019, 08, 29, 22, 33, 22);
            Debug.WriteLine(t1.ToString("MM/dd/yy H:mm:ss"));

            Flight f1 = new Flight(airline1.Id, c1.Id, c1.Id, t, t1, 22);
            flightsHandler.Add(f1);
            #endregion
            FlyingCenterSystem   centerSystem    = new FlyingCenterSystem();
            AnonymouseUserFacade anonymusefacade = centerSystem.OpenLogInSystem();
            Assert.IsNotNull(anonymusefacade);
            IList <AirlineCompany> listcomapny = anonymusefacade.GetAllAirlineCompanies();

            IList <Flight> flightsList = anonymusefacade.GetAllFlights();
            Assert.AreEqual(f1, flightsList[0]);
            Dictionary <Flight, int> valuePairs = anonymusefacade.GetAllFlightsVacancy();
            Assert.AreEqual(f1.RemainingTickets, valuePairs[f1]);
            Flight flightsById = anonymusefacade.GetFlightById(f1.Id);
            Assert.AreEqual(f1, flightsById);
            IList <Flight> FlightsByDtime = anonymusefacade.GetFlightsByDepartureDate(f1.DepartureTime);
            Assert.AreEqual(f1, FlightsByDtime[0]);
            IList <Flight> flighsByDesCountryList = anonymusefacade.GetFlightsByDestionationCountry(f1.DistinationCountryCode);
            Assert.AreEqual(f1, flighsByDesCountryList[0]);
            IList <Flight> FlightsByLandingTimeList = anonymusefacade.GetFlightsByLandingeDate(f1.LandingTime);
            Assert.AreEqual(f1, FlightsByLandingTimeList[0]);
            IList <Flight> FlightsByOriginCountry = anonymusefacade.GetFlightsByOriginCountry(f1.OriginCountryCode);
            Assert.AreEqual(f1, FlightsByOriginCountry[0]);
        }
예제 #6
0
        public void FlightFuncsTest()
        {
            FlightDAOMSSQL flight = new FlightDAOMSSQL();

            flight.RemoveAll();
            CountryDAOMSSQL c = new CountryDAOMSSQL();

            c.RemoveAll();
            AirlineDAOMSSQL airline = new AirlineDAOMSSQL();

            airline.RemoveAll();
            Country c1 = new Country("israel");

            c.Add(c1);
            AirlineCompany airline1 = new AirlineCompany("eldal", "maher", "123", c1.Id);

            airline.Add(airline1);
            DateTime t  = DateTime.Now;
            DateTime t1 = new DateTime(2019, 8, 20, 22, 33, 22);
            Flight   f1 = new Flight(airline1.Id, c1.Id, c1.Id, t, t1, 22);

            flight.Add(f1);
            Assert.AreEqual(f1, flight.GetFlighstByOriginCountry(f1.OriginCountryCode)[0]);
        }
예제 #7
0
        public void AirlineComapnyFacadeTest()
        {
            string username = "******";
            string password = "******";

            FlightDAOMSSQL  flight  = new FlightDAOMSSQL();
            CountryDAOMSSQL c       = new CountryDAOMSSQL();
            AirlineDAOMSSQL airline = new AirlineDAOMSSQL();

            flight.RemoveAll();
            airline.RemoveAll();
            c.RemoveAll();
            Country c1 = new Country("israel");

            c.Add(c1);
            DateTime       t        = DateTime.Now;
            DateTime       t1       = new DateTime(2019, 08, 29, 22, 33, 22);
            AirlineCompany company1 = new AirlineCompany("elal", "elel", "123", c1.Id);

            airline.Add(company1);
            Flight f1 = new Flight(company1.Id, c1.Id, c1.Id, t, t1, 22);

            flight.Add(f1);
            FlyingCenterSystem    centerSystem = new FlyingCenterSystem();
            LoggedInAirlinefacade airlinefacade;
            bool filled = false;

            centerSystem.OpenLogInSystem(username, password, out airlinefacade, ref filled);
            if (filled)
            {
                IList <AirlineCompany> airlineCompaniesList = airlinefacade.GetAllAirlineCompanies();
                Assert.AreEqual(company1, airlineCompaniesList[0]);
                IList <Flight> flightsList = airlinefacade.GetAllFlights();
                Assert.AreEqual(f1, flightsList[0]);
                Dictionary <Flight, int> reaminingTicketMapFlights = airlinefacade.GetAllFlightsVacancy();
                Assert.AreEqual(f1.RemainingTickets, reaminingTicketMapFlights[f1]);
                IList <Ticket> ticketsOfAirlineCompanyList = airlinefacade.GetAllTickets(airlinefacade.AirlineToken);

                Flight flightById = airlinefacade.GetFlightById(f1.Id);
                Assert.AreEqual(f1, flightById);
                IList <Flight> fflightsByDeparyreTimeList = airlinefacade.GetFlightsByDepartureDate(f1.DepartureTime);
                Assert.AreEqual(f1, fflightsByDeparyreTimeList[0]);
                IList <Flight> flightsBydestinationCountryList = airlinefacade.GetFlightsByDestionationCountry(c1.Id);
                Assert.AreEqual(f1, flightsBydestinationCountryList[0]);
                IList <Flight> flightsByLandingTimeList = airlinefacade.GetFlightsByLandingeDate(f1.LandingTime);
                Assert.AreEqual(f1, flightsByLandingTimeList[0]);
                IList <Flight> flightsByOriginCountryList = airlinefacade.GetFlightsByOriginCountry(c1.Id);
                Assert.AreEqual(f1, flightsByOriginCountryList[0]);
                f1.RemainingTickets = f1.RemainingTickets - 3;
                airlinefacade.UpdateFlight(airlinefacade.AirlineToken, f1);
                Dictionary <Flight, int> updatedVanacyMapFligh = airlinefacade.GetAllFlightsVacancy();
                Assert.AreEqual(f1.RemainingTickets, updatedVanacyMapFligh[f1]);
                //Assert.AreSame(f1, airlinefacade.GetFlightById(f1.Id));
                ////airlinefacade.CancelFlight(airlinefacade.AirlineToken, f1);
                ////airlinefacade.ChangeMyPassword(airlinefacade.AirlineToken, "", "");
            }
            else
            {
                Assert.AreEqual(2, 3);
            }
        }
예제 #8
0
        public void GetAllFlights()
        {
            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), 30, FlightStatus.NotDeparted));

            Assert.AreEqual(2, facade.GetAllFlights().Count);
        }
예제 #9
0
        public void AdminFacadeTest()
        {
            // Deleting database
            FlightCenterConfig.DeleteDataBase();
            //Creating DAO'S samples to test
            long             airlineCompanyId1 = 0, airlineCompanyId2 = 0, countryId1 = 0, countryId2 = 0, flightId1 = 0, customerId1 = 0;
            AirLineDAOMSSQL  adao = new AirLineDAOMSSQL();
            FlightDAOMSSQL   fdao = new FlightDAOMSSQL();
            CustomerDAOMSSQL cdao = new CustomerDAOMSSQL();
            CountryDAOMSSQL  cydao = new CountryDAOMSSQL();
            TicketDAOMSSQL   tdao = new TicketDAOMSSQL();

            // Adding new countries
            cydao.Add(new Country {
                COUNTRY_NAME = "Israel"
            });
            countryId1 = cydao.GetCountryId("Israel");

            cydao.Add(new Country {
                COUNTRY_NAME = "Germany"
            });
            countryId2 = cydao.GetCountryId("Germany");

            // Adding new Airline companies
            adao.Add(new AirlineCompany {
                AIRLINE_NAME = "IsrLines", USER_NAME = "ISR91", PASSWORD = "******", COUNTRY_CODE = countryId1
            });
            airlineCompanyId1 = adao.GetAirlineCompanyId("ISR91");

            adao.Add(new AirlineCompany {
                AIRLINE_NAME = "British Airlines", USER_NAME = "British555", PASSWORD = "******", COUNTRY_CODE = countryId2
            });
            airlineCompanyId2 = adao.GetAirlineCompanyId("British555");

            // Adding new Flight
            fdao.Add(new Flight {
                AIRLINECOMPANY_ID = airlineCompanyId1, ORIGIN_COUNTRY_CODE = countryId1, DESTINATION_COUNTRY_CODE = countryId2, DEPARTURE_TIME = new DateTime(2019, 05, 10, 10, 30, 00), LANDING_TIME = new DateTime(2019, 05, 10, 15, 05, 00), REMAINING_TICKETS = 15, AIRLINECOMPANY_NAME = "IsrLines", FLIGHT_NAME = "555"
            });
            flightId1 = fdao.GetFlightId("555");

            // Adding new Customer
            cdao.Add(new Customer {
                FIRST_NAME = "Efrat", LAST_NAME = "Patihi", USER_NAME = "Efrat_kapara", PASSWORD = "******", ADDRESS = "Netanya , Raziel 40", PHONE_NO = "05011554875", CREDIT_CARD_NUMBER = "123456789"
            });
            customerId1 = cdao.GetCustomerId("Efrat_kapara");

            // Adding new Ticket
            tdao.Add(new Tickets {
                CUSTOMER_ID = customerId1, FLIGHT_ID = flightId1
            });
            // Testing
            FlyingCenterSystem         fcs        = FlyingCenterSystem.GetInstance();
            LoginToken <Administrator> adminLogin = new LoginToken <Administrator>();

            adminLogin.User = new Administrator();
            adminLogin.User.AdminUserName = "******";
            adminLogin.User.Password      = "******";


            // Trying to login
            fcs.login.TryAdminLogin(adminLogin.User.AdminUserName, adminLogin.User.Password, out LoginToken <Administrator> adminToken);
            fcs.login.TryAirlineLogin("ISR91", "Is789", out LoginToken <AirlineCompany> airlineToken);
            fcs.login.TryCustomerLogin("Efrat_kapara", "Efi93", out LoginToken <Customer> customerToken);


            // Testing admin facade fucntions
            LoggedInAdministratorFacade adminFacadae = fcs.GetFacade(adminLogin) as LoggedInAdministratorFacade;

            adminFacadae.CreateNewCountry(adminLogin, new Country {
                COUNTRY_NAME = "Israel"
            });
            AirlineCompany airline = new AirlineCompany()
            {
                AIRLINE_NAME = "Nassa",
                USER_NAME    = "Nassa28",
                PASSWORD     = "******",
                COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            };

            adminFacadae.CreateNewAirline(adminLogin, airline);
            Assert.AreEqual(adminFacadae.GetAirlineByUserame("Nassa28"), airline);

            Customer cust = new Customer()
            {
                FIRST_NAME         = "Tal",
                LAST_NAME          = "Rdt",
                USER_NAME          = "TalGever",
                PASSWORD           = "******",
                ADDRESS            = "Hazfira 20, Pardes hanna",
                PHONE_NO           = "0505001245",
                CREDIT_CARD_NUMBER = "456123456789"
            };

            adminFacadae.CreateNewCustomer(adminLogin, cust);
            Assert.AreEqual(cust, adminFacadae.GetCustomerByUserName("TalGever")); // works
            adminFacadae.UpdateAirlineDetails(adminLogin, new AirlineCompany {
                AIRLINE_NAME = "Nasa4Life", USER_NAME = "Nassa28", PASSWORD = "******", COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            });
            adminFacadae.UpdateCustomerDetails(adminLogin, new Customer {
                FIRST_NAME = "Tal", LAST_NAME = "Rdt", USER_NAME = "TalGever", PASSWORD = "******", ADDRESS = "Raziel 50 , Netanya", PHONE_NO = "0505001245", CREDIT_CARD_NUMBER = "456123456789"
            });
            AirlineCompany airl = new AirlineCompany()
            {
                AIRLINE_NAME = "Nasa4Life",
                USER_NAME    = "Nassa28",
                PASSWORD     = "******",
                COUNTRY_CODE = adminFacadae.GetCountryId("Israel")
            };

            adminFacadae.RemoveAirline(adminLogin, airl);
        }
예제 #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);
        }
예제 #11
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            // Creating new customer.
            Customer newCustomer = new Customer
            {
                FIRST_NAME         = "Iliya",
                LAST_NAME          = "Tsvibel",
                USER_NAME          = "Iliya",
                PASSWORD           = "******",
                ADDRESS            = "Rishon",
                PHONE_NO           = "0546800559",
                CREDIT_CARD_NUMBER = "12345"
            };

            adminFacade.CreateNewCustomer(defaultToken, newCustomer);

            // Creating new country.
            Country country = null;

            country = new Country();
            for (int i = 0; i < ListOfCountries.CountryNames.Length; i++)
            {
                country = countryDAO.GetByName(ListOfCountries.CountryNames[i]);

                if (country == null)
                {
                    Country newCountry = new Country {
                        COUNTRY_NAME = ListOfCountries.CountryNames[i]
                    };
                    adminFacade.CreateNewCountry(defaultToken, newCountry);
                }
            }

            // Creating new administrator.
            Administrator newAdmin = new Administrator {
                FIRST_NAME = "Iliya", LAST_NAME = "Tsvibel", USER_NAME = "Admin", PASSWORD = "******"
            };

            adminFacade.CreateNewAdmin(defaultToken, newAdmin);

            //Creating new airline.
            //AirlineCompany newAirline = new AirlineCompany
            //{
            //    AIRLINE_NAME = "Aeroflot",
            //    USER_NAME = "Vladimir",
            //    COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID,
            //    PASSWORD = "******"
            //};
            //adminFacade.CreateNewAirline(defaultToken, newAirline);

            AirlineCompany airline = null;

            airline = new AirlineCompany();
            long countryStartID = 0;

            countryStartID = countryDAO.GetByName(ListOfCountries.CountryNames[0]).ID;
            for (int i = 0; i < ListOfAirlinesCompanies.AirlineNames.Length; i++)
            {
                airline = airlineDAO.GetAirlineByName(ListOfAirlinesCompanies.AirlineNames[i]);

                if (airline == null)
                {
                    AirlineCompany newAirline = new AirlineCompany {
                        AIRLINE_NAME = ListOfAirlinesCompanies.AirlineNames[i], USER_NAME = "UserName-" + ListOfAirlinesCompanies.AirlineNames[i], PASSWORD = random.Next(1000, 10000).ToString(), COUNTRY_CODE = random.Next(Convert.ToInt32(countryStartID), (Convert.ToInt32(countryStartID) + ListOfCountries.CountryNames.Length))
                    };
                    adminFacade.CreateNewAirline(defaultToken, newAirline);
                }
            }

            // Creating new flight.
            Flight flight = new Flight {
                AIRLINECOMPANY_ID = adminFacade.GetAirlineByName(adminToken, "SOLAR CARGO, C.A.").ID, DEPARTURE_TIME = DateTime.Now, LANDING_TIME = DateTime.Now + TimeSpan.FromHours(1), ORIGIN_COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID, DESTINATION_COUNTRY_CODE = adminFacade.GetCountryByName("Germany").ID, REMAINING_TICKETS = 250
            };

            //airlineFacade.CreateFlight(defaultAirlioneToken, flight);
            flightDAO.Add(flight);

            // Creating new ticket.
            Ticket tickets = new Ticket {
                FLIGHT_ID = anonFacade.GetFlightsByDestinationCountryForTest(adminFacade.GetCountryByName("Germany").ID).ID, CUSTOMER_ID = adminFacade.GetCustomerByUserName(adminToken, "Iliya").ID
            };

            //customerFacade.PurchaseTicket(defaultCustomerToken, tickets);
            ticketDAO.Add(tickets);
            MessageBox.Show($"All data successfully added");
        }