示例#1
0
 public void NullUserTriesToGetAllCustomer()
 {
     FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "roey123", "12345");
     LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
     LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;
     IList <Customer>            list   = facade.GetAllCustomers(null);
 }
示例#2
0
        public void GetAllCustomers_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "roey123", "12345");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;
            IList <Customer>            list   = facade.GetAllCustomers(token);

            Assert.AreEqual(list.Count, 2);
        }
        public void GetAllCustomers()
        {
            List <Customers> expected_customers = new List <Customers>()
            {
                new Customers(1, "cus", "tomer", "ytl2", "03-23423400234", "2131313", 5),
                new Customers(2, "cusw", "tomerw", "ytle3", "03-234546234234", "231313113", 6),
            };
            List <Customers> customers2 = (List <Customers>)loggedInAdministrator.GetAllCustomers(admin);

            CollectionAssert.AreEqual(expected_customers, customers2);
        }
        public void GetAllCustomers()
        {
            Customer expectedCustomer = new Customer("customer_first_name", "customer_last_name", "customer_address", "customer_phone_no", "customer_credit_card_no", 3);

            expectedCustomer.Id = 1;
            List <Customer> expected_list_of_customers = new List <Customer>();

            expected_list_of_customers.Add(expectedCustomer);
            List <Customer> list_of_customers = (List <Customer>)administratorFacade.GetAllCustomers(admin_token);

            CollectionAssert.AreEqual(list_of_customers, expected_list_of_customers);
        }
        public void Create_And_Get_List_Of_New_Customers()
        {
            Execute_Test(() =>
            {
                Customer[] data           = TestData.Get_Customers_Data();
                Customer[] demi_customers = { data[0], data[1], data[2] };
                for (int i = 0; i < demi_customers.Length; i++)
                {
                    long customer_id = administrator_facade.CreateNewCustomer(administrator_token, demi_customers[i]);
                    Assert.AreEqual(customer_id, i + 1);
                    Assert.AreEqual(demi_customers[i].User.Id, i + 1);
                    demi_customers[i].Id = customer_id;
                }

                IList <Customer> customers_from_db = administrator_facade.GetAllCustomers(administrator_token);
                Assert.AreEqual(demi_customers.Length, customers_from_db.Count);
                for (int i = 0; i < customers_from_db.Count; i++)
                {
                    TestData.CompareProps(customers_from_db[i], demi_customers[i]);
                }
            });
        }
示例#6
0
        public async Task <ActionResult <List <Customer> > > GetAllCustomers()
        {
            FlightsCenterSystem.GetInstance().login(GetLoginToken().Name, GetLoginToken().Password,
                                                    out LoginToken <Object> l, out FacadeBase f);
            facade      = f as LoggedInAdministratorFacade;
            token_admin = GetLoginToken();
            User u = new UserDAOPGSQL().GetAll().FirstOrDefault(_ => _.Password == token_admin.Password && _.Username == token_admin.Name);

            token_admin.User = new AdministratorDAOPGSQL().GetAll().FirstOrDefault(_ => _.User_id == u.Id);
            var result = await Task.Run(() => facade.GetAllCustomers(token_admin));

            return(StatusCode(200, result));
        }
        public void getTokenAndGetFacade(out LoginToken <Admin> tokenAdmin, out LoggedInAdministratorFacade facadeAdmin,
                                         out LoginToken <Customer> tokenCustomer, out LoggedInCustomerFacade fasadeCustomer)
        {
            ILoginService loginService = new LoginService();

            loginService.TryAdminLogin(FlightCenterConfig.ADMIN_NAME, FlightCenterConfig.ADMIN_PASSWORD, out tokenAdmin);
            facadeAdmin = FlightsCenterSystem.GetInstance().GetFacade(tokenAdmin) as LoggedInAdministratorFacade;

            facadeAdmin.CreateNewCustomer(tokenAdmin, CreateCustomerForTest());
            tokenCustomer = new LoginToken <Customer>()
            {
                User = facadeAdmin.GetAllCustomers(tokenAdmin)[0]
            };
            fasadeCustomer = FlightsCenterSystem.GetInstance().GetFacade(tokenCustomer) as LoggedInCustomerFacade;
        }
        public IHttpActionResult RemoveCustomer([FromUri] int id)
        {
            GetLoginToken();

            if (AdminToken != null)
            {
                Customer C = F.GetAllCustomers().ToList().Find(c => c.ID == id);
                if (C == null)
                {
                    return(Content(HttpStatusCode.NotFound, $"{id} was not found"));
                }
                //customer.ID = F.GetCustomerByName(AdminToken, customer.FirstName).ID;
                F.RemoveCustomer(AdminToken, C);
                return(Ok($"{C.UserName} has been Removed"));
            }

            return(NotFound());
        }
示例#9
0
        // 6. Create Random Ticket From API Web.
        public void ReadTicketsFromAPI(int times)
        {
            int success = 0;
            IList <Customer> customers = adminFacade.GetAllCustomers(adminToken);
            IList <Flight>   flights   = new AnonymousUserFacade().GetAllFlights();

            MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger.Add("Start Create Tickets..."))));
            User user;

            for (int i = 0; i < userNamesOfCustomers.Count; i++)
            {
                user = new User(adminFacade.GetCustomerByUserName(adminToken, userNamesOfCustomers[i]).User_Name, adminFacade.GetCustomerByUserName(adminToken, userNamesOfCustomers[i]).Password, UserType.Customer, true);
                FlyingCenterSystem.GetUserAndFacade(user, out ILogin token, out FacadeBase facade);
                LoginToken <Customer>  customerToken  = token as LoginToken <Customer>;
                LoggedInCustomerFacade customerFacade = new LoggedInCustomerFacade();
                for (int j = 0; j < times; j++)
                {
                    HttpResponseMessage response = client.GetAsync("").Result;
                    if (response.IsSuccessStatusCode)
                    {
                        APIUser ticketAPI = response.Content.ReadAsAsync <APIUser>().Result;
                        customerFacade.PurchaseTicket(customerToken, flights[j]);
                        MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger[ViewModel.Logger.Count - 1] = $"- {success+1}/{times * userNamesOfCustomers.Count} Tickets Was Generated.")));
                        success++;
                    }
                    ViewModel.HowMuchCreated++;
                }
            }
            userNamesOfCustomers = new List <string>();
            if (times > 0)
            {
                log.Info($"\n{success} Tickets Were Created And {times - success} Failed.\n");
                MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger.Add($"- Tickets Generator Is Over. ({success} Were Created And {times - success} Failed)."))));
            }
            else
            {
                MainWindow.m_Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, new ThreadStart(new Action(() => ViewModel.Logger[ViewModel.Logger.Count - 1] = $"- No Creation Request For Tickets.")));
            }
        }
        public IHttpActionResult GetAllCustomers()
        {
            IList <Customer> customers = facade.GetAllCustomers(token);

            return(Ok(customers));
        }
示例#11
0
        public void AdministratorFacadeTest()
        {
            new TestFacade().DeleteAllTables();

            FlightCenterSystem fcs = FlightCenterSystem.GetInstance();

            LoginToken <Administrator> loginToken = new LoginToken <Administrator>()
            {
                User = new Administrator()
            };

            LoggedInAdministratorFacade facade = fcs.GetFacade <Administrator>(loginToken) as LoggedInAdministratorFacade;

            #region Create New Airline

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateNewAirline(null, new AirlineCompany("name", "username", "*****@*****.**", "123", 1));
                // Token is null, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidAirlineCompanyException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("", "username", "*****@*****.**", "123", 1));
                // No name, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidAirlineCompanyException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "", "*****@*****.**", "123", 1));
                // No user name, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidAirlineCompanyException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "username", "", "123", 1));
                // No email, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidAirlineCompanyException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "username", "*****@*****.**", "", 1));
                // No password, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidAirlineCompanyException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "username", "*****@*****.**", "123", 0));
                // Origin country ID cannot be zero (null), should cause an exception to be thrown
            });

            Assert.ThrowsException <CountryNotFoundException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "username", "*****@*****.**", "123", 500));
                // Origin country ID does not exist, should cause an exception to be thrown
            });


            Assert.ThrowsException <UserNameAlreadyExistException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("name", "admin", "*****@*****.**", "123", 1));
                // User name is taken by the admin, should cause an exception to be thrown
            });

            Assert.ThrowsException <UserNameAlreadyExistException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("Sky Team", "skt", "*****@*****.**", "666", 1));
                facade.CreateNewAirline(loginToken, new AirlineCompany("Sky Tour", "skt", "*****@*****.**", "777", 1));
                // User name is taken, should cause an exception to be thrown
            });

            Assert.ThrowsException <AirlineCompanyNameAlreadyExistException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("Air One", "airone", "*****@*****.**", "555", 1));
                facade.CreateNewAirline(loginToken, new AirlineCompany("Air One", "airy", "*****@*****.**", "333", 1));
                // Company name already exist, should cause an exception to be thrown
            });

            new TestFacade().DeleteAllTables();

            facade.CreateNewAirline(loginToken, new AirlineCompany("One World", "one", "*****@*****.**", "777", 1));
            IList <AirlineCompany> airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines[0].Name, "One World");
            Assert.AreEqual(airlines[0].UserName, "one");
            Assert.AreEqual(airlines[0].Email, "*****@*****.**");
            Assert.AreEqual(airlines[0].Password, "777");
            Assert.AreEqual(airlines[0].CountryCode, 1);

            #endregion

            #region Create New Customer

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateNewCustomer(null, new Customer("John", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
                // Token is null, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidCustomerException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
                // No first name, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidCustomerException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
                // No last name, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidCustomerException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "", "*****@*****.**", "j123", "unknown", "555", "4580"));
                // No user name, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidCustomerException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "", "j123", "unknown", "555", "4580"));
                // No email, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidCustomerException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "*****@*****.**", "", "unknown", "555", "4580"));
                // No password, should cause an exception to be thrown
            });

            Assert.ThrowsException <UserNameAlreadyExistException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
                facade.CreateNewCustomer(loginToken, new Customer("Jane", "Dean", "jd", "*****@*****.**", "j999", "NY", "458", "4580"));
                // User name is already taken, should cause an exception to be thrown
            });

            new TestFacade().DeleteAllTables();

            facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
            IList <Customer> customers = facade.GetAllCustomers(loginToken);

            Assert.AreEqual(customers[0].FirstName, "John");
            Assert.AreEqual(customers[0].LastName, "Doe");
            Assert.AreEqual(customers[0].UserName, "jd");
            Assert.AreEqual(customers[0].Email, "*****@*****.**");
            Assert.AreEqual(customers[0].Password, "j123");
            Assert.AreEqual(customers[0].Address, "unknown");
            Assert.AreEqual(customers[0].PhoneNo, "555");
            Assert.AreEqual(customers[0].CreditCardNo, "4580");

            #endregion

            #region Update airline details

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateNewAirline(loginToken, new AirlineCompany("Air One", "airone", "*****@*****.**", "555", 1));
                airlines = facade.GetAllAirlineCompanies();

                facade.UpdateAirlineDetails(null, new AirlineCompany("Air two", "airtwo", "*****@*****.**", "555", 1)
                {
                    Id = airlines[0].Id
                });
                // Token is null, should cause an exception to be thrown
            });

            facade.UpdateAirlineDetails(loginToken, new AirlineCompany("Air two", "airtwo", "*****@*****.**", "555", 1)
            {
                Id = airlines[0].Id
            });
            airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines[0].Name, "Air two");
            Assert.AreEqual(airlines[0].UserName, "airtwo");
            Assert.AreEqual(airlines[0].Email, "*****@*****.**");
            Assert.AreEqual(airlines[0].Password, "555");
            Assert.AreEqual(airlines[0].CountryCode, 1);

            new TestFacade().DeleteAllTables();

            #endregion

            #region Update customer details

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
                customers = facade.GetAllCustomers(loginToken);

                facade.UpdateCustomerDetails(null, new Customer("Jane", "Darwin", "jd", "*****@*****.**", "j123", "CA", "255", "4580")
                {
                    Id = customers[0].Id
                });
                // Token is null, should cause an exception to be thrown
            });

            facade.UpdateCustomerDetails(loginToken, new Customer("Jane", "Darwin", "jd", "*****@*****.**", "j123", "CA", "255", "4580")
            {
                Id = customers[0].Id
            });
            customers = facade.GetAllCustomers(loginToken);

            Assert.AreEqual(customers[0].FirstName, "Jane");
            Assert.AreEqual(customers[0].LastName, "Darwin");
            Assert.AreEqual(customers[0].UserName, "jd");
            Assert.AreEqual(customers[0].Email, "*****@*****.**");
            Assert.AreEqual(customers[0].Password, "j123");
            Assert.AreEqual(customers[0].Address, "CA");
            Assert.AreEqual(customers[0].PhoneNo, "255");
            Assert.AreEqual(customers[0].CreditCardNo, "4580");

            #endregion

            new TestFacade().DeleteAllTables();

            #region Remove airline

            facade.CreateNewAirline(loginToken, new AirlineCompany("Air One", "airone", "*****@*****.**", "555", 1));
            airlines = facade.GetAllAirlineCompanies();

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.RemoveAirline(null, airlines[0]);
                // Token is null, should cause an exception to be thrown
            });

            facade.RemoveAirline(loginToken, airlines[0]);
            airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines.Count, 0);

            #endregion

            #region Remove customer

            facade.CreateNewCustomer(loginToken, new Customer("John", "Doe", "jd", "*****@*****.**", "j123", "unknown", "555", "4580"));
            customers = facade.GetAllCustomers(loginToken);

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.RemoveCustomer(null, customers[0]);
                // Token is null, should cause an exception to be thrown
            });

            facade.RemoveCustomer(loginToken, customers[0]);
            customers = facade.GetAllCustomers(loginToken);

            Assert.AreEqual(customers.Count, 0);

            #endregion

            #region Get all customers

            facade.CreateNewAirline(loginToken, new AirlineCompany("Air One", "airone", "*****@*****.**", "555", 1));
            facade.CreateNewAirline(loginToken, new AirlineCompany("Fly Far", "flyfar", "*****@*****.**", "931", 1));

            airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines[0].Name, "Air One");
            Assert.AreEqual(airlines[0].UserName, "airone");
            Assert.AreEqual(airlines[0].Email, "*****@*****.**");
            Assert.AreEqual(airlines[0].Password, "555");
            Assert.AreEqual(airlines[0].CountryCode, 1);

            Assert.AreEqual(airlines[1].Name, "Fly Far");
            Assert.AreEqual(airlines[1].UserName, "flyfar");
            Assert.AreEqual(airlines[1].Email, "*****@*****.**");
            Assert.AreEqual(airlines[1].Password, "931");
            Assert.AreEqual(airlines[1].CountryCode, 1);

            #endregion
        }
示例#12
0
        public Customer GetCustomerForTest()
        {
            Customer c = AdminFacade.GetAllCustomers(AdminToken).ToList()[0]; //new Customer

            return(c);
        }
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            bool loggedIn = false;

            //got username + password here in server
            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Forbidden,
                                                                              "You must send user name and password in basic authentication");
                return;
            }
            string authenticationToken        = actionContext.Request.Headers.Authorization.Parameter;
            string decodedAuthenticationToken = Encoding.UTF8.GetString(
                Convert.FromBase64String(authenticationToken));

            string[] usernamePasswordArray = decodedAuthenticationToken.Split(':');
            string   username = usernamePasswordArray[0];
            string   password = usernamePasswordArray[1];

            //search the username and password in the DB (with admin user Facade):
            ILoginToken LoginUser = FlyingCenterSystem.GetFlyingCenterSystemInstance().Login("admin", "9999");
            LoginToken <Administrator>  AdminLoginToken   = (LoginToken <Administrator>)LoginUser;
            LoggedInAdministratorFacade AdminLoginIFacade = (LoggedInAdministratorFacade)FlyingCenterSystem.GetFlyingCenterSystemInstance().GetFacade(AdminLoginToken);
            IList <Customer>            customers         = new List <Customer>();

            customers = AdminLoginIFacade.GetAllCustomers(AdminLoginToken);

            //Add the request to the table in DB:
            AdminLoginIFacade.AddRequestToTableInDB(AdminLoginToken, username);

            if (!AdminLoginIFacade.IsUserBlocked(AdminLoginToken, username))
            {
                foreach (Customer c in customers)
                {
                    if (username == c.Username && password == c.Password)
                    {
                        loggedIn = true;

                        //create loginToken for Customer
                        ILoginToken CustomerLoginToken = FlyingCenterSystem.GetFlyingCenterSystemInstance().Login(username, password);
                        actionContext.Request.Properties["login-customer"]       = c;
                        actionContext.Request.Properties["customer-login-token"] = CustomerLoginToken;
                    }
                    if (username == c.Username && password != c.Password)
                    {
                        loggedIn = true;

                        //if times of login from the same user more than 3 - block the user:
                        AdminLoginIFacade.CheckIfBlockUser(AdminLoginToken, username);

                        string answerWrongpassword = "******";
                        if (AdminLoginIFacade.IsUserBlocked(AdminLoginToken, username))
                        {
                            answerWrongpassword += " Your user was blocked.";
                        }

                        actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized,
                                                                                      answerWrongpassword);
                        return;
                    }
                }

                if (!loggedIn)
                {
                    //stops the request - will not arrive to web api controller
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized,
                                                                                  "You are not authorized. Your Username is not registered.");
                }
            }
            else
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized,
                                                                              "You are not authorized. Your user was blocked.");
            }
        }
示例#14
0
        public void GenerateData()
        {
            log.Info("Creating admin user");
            MainWindowViewModel.ListForLog.Add("Creating admin user");
            //Creating admin user:
            IloginAdministrator     = FlyingCenterSystem.GetFlyingCenterSystemInstance().Login("admin", "9999");
            loginTokenAdministrator = IloginAdministrator as LoginToken <Administrator>;
            administratorFacade     = (LoggedInAdministratorFacade)FlyingCenterSystem.GetFlyingCenterSystemInstance().GetFacade(IloginAdministrator);

            //Adds the countries first (foreign key constrain considaration):
            log.Info("Adds the countries first");
            MainWindowViewModel.ListForLog.Add("Adds the countries first");
            for (int i = 0; i < _CountriesNoToAdd; i++)
            {
                administratorFacade.CreateNewCountry(loginTokenAdministrator,
                                                     new Country()
                {
                    CountryName = listOfThings.CountriesArray[rnd.Next(listOfThings.CountriesArray.Length)]
                });
                if (i >= listOfThings.CountriesArray.Length)
                {
                    administratorFacade.CreateNewCountry(loginTokenAdministrator,
                                                         new Country()
                    {
                        CountryName = RandomString(5)
                    });
                }
            }

            //Get All Countries and add country codes for filling the airline companies:
            log.Info("Adds the Airline Companies");
            MainWindowViewModel.ListForLog.Add("Adds the Airline Companies");
            IList <Country> countries = new List <Country>();

            countries = administratorFacade.GetAllCountries(loginTokenAdministrator);

            //Adds the Airline Companies:
            for (int i = 0; i < _AirlineCompaniesNo; i++)
            {
                administratorFacade.CreateNewAirline(loginTokenAdministrator, new AirlineCompany()
                {
                    AirLineName = RandomString(5),
                    CountryCode = countries[rnd.Next(0, countries.Count)].CountyID,
                    Password    = RandomString(6),
                    UserName    = RandomString(4)
                });
            }

            //Adds the Customers:
            log.Info("Adds the Customers");
            MainWindowViewModel.ListForLog.Add("Adds the Customers");
            //FillCustomerTableFromUserApi(CustomersNo); - will not use, site is down (although it's working)
            FillCustomerTableRandomly(rnd, _CustomersNo);

            //Get All AirlineCompanies for the id:
            IList <AirlineCompany> airlineCompanies = administratorFacade.GetAllAirLineCompanies();

            //Adds the Flights Per Company:
            log.Info("Adds the Flights Per Company");
            MainWindowViewModel.ListForLog.Add("Adds the Flights Per Company");
            for (int i = 0; i < _FlightsPerCompany; i++)
            {
                administratorFacade.CreateFlight(loginTokenAdministrator, new Flight()
                {
                    AirLineCompany_ID        = airlineCompanies[rnd.Next(0, airlineCompanies.Count)].Airline_ID,
                    Origin_Country_Code      = countries[rnd.Next(0, countries.Count)].CountyID,
                    Destination_Country_Code = countries[rnd.Next(0, countries.Count)].CountyID,
                    DepartureTime            = createRandomDate(),
                    LandingTime       = createRandomDate(),
                    Remaining_Tickets = rnd.Next(5, 51)
                });
            }

            log.Info("Adds the Tickets per Customer");
            MainWindowViewModel.ListForLog.Add("Adds the Tickets per Customer");
            //Get All customers:
            IList <Customer> customers = new List <Customer>();

            customers = administratorFacade.GetAllCustomers(loginTokenAdministrator);

            //Get All flights :
            IList <Flight> flights = new List <Flight>();

            flights = administratorFacade.GetAllFlights();

            //Adds the Tickets per Customer:
            for (int i = 0; i < _TicketsPerCustomer; i++)
            {
                administratorFacade.AddTicketsToCustomer(loginTokenAdministrator,
                                                         customers[rnd.Next(0, customers.Count)].Customer_ID,
                                                         flights[rnd.Next(0, flights.Count)].FlightID);
            }

            log.Info("Finished puting data in DB!");
            MainWindowViewModel.ListForLog.Add("Finished puting data in DB!");
        }