Example #1
0
        public void InsertData()
        {
            LoginToken <Administrator> admin = new LoginToken <Administrator>()
            {
                User = new Administrator(0, "Admin", "Test", 3, 0, new Users(0, "admin", "Test", "@", 1))
            };

            LoggedInAdministrator.CreateNewUser(admin, new Users(1, "admin1", "pass", "*****@*****.**", 1));
            LoggedInAdministrator.CreateNewUser(admin, new Users(2, "admin2", "pass", "*****@*****.**", 1));
            LoggedInAdministrator.CreateNewUser(admin, new Users(3, "airline1", "pass", "*****@*****.**", 2));
            LoggedInAdministrator.CreateNewUser(admin, new Users(4, "airline2", "pass", "*****@*****.**", 2));
            LoggedInAdministrator.CreateNewUser(admin, new Users(5, "customer1", "pass", "*****@*****.**", 3));
            LoggedInAdministrator.CreateNewUser(admin, new Users(6, "customer2", "pass", "*****@*****.**", 3));

            LoggedInAdministrator.CreateAdmin(admin, new Administrator(1, "simi", "simi", 2, 1));
            LoggedInAdministrator.CreateAdmin(admin, new Administrator(2, "bibi", "simi", 3, 2));
            LoggedInAdministrator.CreateNewAirline(admin, new AirlineCompanies(1, "airone", 3, 3));
            LoggedInAdministrator.CreateNewAirline(admin, new AirlineCompanies(2, "airtwo", 5, 4));
            LoggedInAdministrator.CreateNewCustomer(admin, new Customers(1, "cus", "tomer", "ytl2", "03-23423400234", "2131313", 5));
            LoggedInAdministrator.CreateNewCustomer(admin, new Customers(2, "cusw", "tomerw", "ytle3", "03-234546234234", "231313113", 6));

            loggedInAirline.CreateFlight(new LoginToken <AirlineCompanies>(), new Flights(1, 1, 3, 6, new DateTime(2021, 03, 26), new DateTime(2021, 04, 26), 10));
            loggedInAirline.CreateFlight(new LoginToken <AirlineCompanies>(), new Flights(2, 2, 5, 2, new DateTime(2021, 01, 17), new DateTime(2021, 04, 17), 23));
            LoggedInAdministrator.CreateNewTicket(admin, new Tickets(1, 1));
            LoggedInAdministrator.CreateNewTicket(admin, new Tickets(2, 2));
        }
        public void CreateAdmin()
        {
            Administrator a = new Administrator("Daniel", "Daniel", 3, 1);

            loggedInAdministrator.CreateAdmin(admin, a);
            Administrator a_expected = loggedInAdministrator.GetAdministratorById(admin, 3);

            Assert.AreEqual(a_expected, a);
        }
        public void CreateAdmin()
        {
            Administrator additionalAdmin = new Administrator("adminfirst_name", "admin_last_name", 1, 1);

            additionalAdmin.Id = 1;
            administratorFacade.CreateAdmin(admin_token, additionalAdmin);
            Administrator second_admin = administratorFacade.GetAdminById(1);

            Assert.AreEqual(additionalAdmin, second_admin);
        }
Example #4
0
        public async Task <ActionResult <Administrator> > CreateAdmin([FromBody] Administrator admin)
        {
            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);
            await Task.Run(() => facade.CreateAdmin(token_admin, admin));

            return(StatusCode(200, admin));
        }
Example #5
0
        public void NullUserTriesToCreateNewAdmin()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "roey123", "12345");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;
            Administrator administrator        = new Administrator
            {
                First_Name = "Shlomi",
                Last_Name  = "Banai",
                Level      = 3,
                User_Id    = 17,
                User       = new User()
            };

            facade.CreateAdmin(null, administrator);
        }
Example #6
0
        public void HighesAdminTriesToAddHighestAdminException()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "danny121121", "fdsaa23");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;

            Administrator administrator = new Administrator
            {
                First_Name = "Shlomi",
                Last_Name  = "Banai",
                Level      = 3,
                User_Id    = 17,
                User       = new User()
            };

            facade.CreateAdmin(token, administrator);
        }
        public void InsertData()
        {
            LoginToken <Administrator> adminToken = new LoginToken <Administrator>()
            {
                User = new Administrator("admin", "monro", 3, 500)
            };

            administratorFacade.CreateUser(adminToken, new User("admin_username", "admin_password", "admin_email", 1));
            administratorFacade.CreateUser(adminToken, new User("airline_username", "airline_passsword", "airline_email", 2));
            administratorFacade.CreateUser(adminToken, new User("customer_username", "customer_password", "customer_email", 3));

            administratorFacade.CreateAdmin(adminToken, new Administrator("adminfirst_name", "admin_last_name", 3, 1));
            administratorFacade.CreateNewAirline(adminToken, new AirlineCompany("airline_name", 3, 2));
            administratorFacade.CreateNewCustomer(adminToken, new Customer("customer_first_name", "customer_last_name", "customer_address", "customer_phone_no", "customer_credit_card_no", 3));

            airlineFacade.CreateFlight(new LoginToken <AirlineCompany>(), new Flight(1, 1, 1, new DateTime(2000, 01, 01), new DateTime(2000, 01, 01), 1));
            administratorFacade.CreateTicket(adminToken, new Ticket(1, 1));
        }
Example #8
0
        public void MainAdminAddLevelThreeAdmin()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "admin", "9999");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;

            User user = new User
            {
                User_Name = "Shlomi5431",
                Password  = "******",
                Email     = "*****@*****.**",
                User_Role = 1
            };
            Administrator administrator = new Administrator
            {
                First_Name = "Shlomi",
                Last_Name  = "Banai",
                Level      = 3,
                User       = user
            };

            facade.CreateAdmin(token, administrator);
            Assert.AreEqual(_adminDAO.GetAll().Count, 5);
        }
Example #9
0
        public void CreateAdmin_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadeBase, out ILoginToken loginToken, "danny121121", "fdsaa23");
            LoginToken <Administrator>  token  = (LoginToken <Administrator>)loginToken;
            LoggedInAdministratorFacade facade = (LoggedInAdministratorFacade)facadeBase;

            User user = new User
            {
                User_Name = "Bar_36",
                Password  = "******",
                Email     = "*****@*****.**",
                User_Role = 1
            };
            Administrator administrator = new Administrator
            {
                First_Name = "Bar",
                Last_Name  = "Cohen",
                Level      = 2,
                User       = user
            };

            facade.CreateAdmin(token, administrator);
            Assert.AreEqual(_adminDAO.GetAll().Count, 4);
        }