//[ExpectedException()]
 public void CheckNullToken()
 {
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.CancelFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.GetAllTickets(null);
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.CreateFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.UpdateFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.ChangeMyPassword(null, "old_password", "new_password");
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.MofidyAirlineDetails(null, new AirlineCompany());
     });
 }
        public IHttpActionResult MofidyAirlineDetails([FromBody] AirlineCompany airline)
        {
            bool   isAuthorized = false;
            bool   isModified   = false;
            Action act          = () =>
            {
                isAuthorized = GetInternalLoginTokenInternal <AirlineCompany>(out LoginToken <AirlineCompany> loginTokenAirline);

                if (isAuthorized)
                {
                    isModified = _loggedInAirlineFacade.MofidyAirlineDetails(loginTokenAirline, airline);
                }
            };

            ProcessExceptions(act);
            if (!isAuthorized)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, $"Sorry, but you're not an Airline Company. Your accsess is denied.")));
            }

            if (!isModified)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.PreconditionFailed, $"Sorry, but the Airline isn't modified")));
            }

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, $"The Airline number {airline.ID} is modified")));
        }
Exemplo n.º 3
0
        public void NullUserTriesToUpdateDetailsException()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "dana111", "gdfds");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;

            facade.MofidyAirlineDetails(null, new AirlineCompany());
        }
Exemplo n.º 4
0
        public void TestModifyAirlineDetails()
        {
            ResetWhatIsNeeded();
            LoginService ls = new LoginService();
            LoginToken <AirlineCompany> loginToken = new LoginToken <AirlineCompany>();

            ls.TryAirlineLogin("wefly", "wefly", out loginToken);
            LoggedInAirlineFacade loggedInAirlineFacade = new LoggedInAirlineFacade();

            AirlineCompany newAirlineCompany = new AirlineCompany(loginToken.User.ID, loginToken.User.AirlineName, loginToken.User.Username, "youfly", loginToken.User.CountryID);

            loggedInAirlineFacade.MofidyAirlineDetails(loginToken, newAirlineCompany);

            Assert.IsTrue(ls.TryAirlineLogin("wefly", "youfly", out loginToken));

            newAirlineCompany = new AirlineCompany(loginToken.User.ID, loginToken.User.AirlineName, loginToken.User.Username, "wefly", loginToken.User.CountryID);
            loggedInAirlineFacade.MofidyAirlineDetails(loginToken, newAirlineCompany);
        }
Exemplo n.º 5
0
        public IHttpActionResult MofidyAirlineDetails([FromBody] AirlineCompany airline)
        {
            GetLoginToken();
            if (AirLineToken != null)
            {
                F.MofidyAirlineDetails(AirLineToken, airline);
                return(Ok($"airline company:{AirLineToken.User.AirlineName} details has changed"));
            }

            return(NotFound());
        }
Exemplo n.º 6
0
        public async Task <ActionResult> MofidyAirlineDetails([FromBody] AirlineCompany airline)
        {
            FlightsCenterSystem.GetInstance().login(GetLoginToken().Name, GetLoginToken().Password,
                                                    out LoginToken <Object> l, out FacadeBase f);
            facade        = f as LoggedInAirlineFacade;
            token_airline = GetLoginToken();
            User u = new UserDAOPGSQL().GetAll().FirstOrDefault(_ => _.Password == token_airline.Password && _.Username == token_airline.Name);

            token_airline.User = new AirlineDAOPGSQL().GetAll().FirstOrDefault(_ => _.UserId == u.Id);
            await Task.Run(() => facade.MofidyAirlineDetails(token_airline, airline));

            return(StatusCode(200));
        }
Exemplo n.º 7
0
        public void Change_Airline_Details()
        {
            Execute_Test(() =>
            {
                AirlineCompany airlineCompany = airline_token.User;
                airlineCompany.Name           = "Changed Name";
                airlineCompany.CountryId      = 3;

                airline_facade.MofidyAirlineDetails(airline_token, airlineCompany);

                AirlineCompany airline_from_db = airline_facade.GetAirlineCompanyById(airlineCompany.Id);

                TestData.CompareProps(airlineCompany, airline_from_db);
            });
        }
Exemplo n.º 8
0
        public void NullUserTriesToModifyDetailsException()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "adi213", "54321");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            AirlineCompany airline = new AirlineCompany
            {
                Id         = loginToken.User.Id,
                Name       = loginToken.User.Name,
                Country_Id = 4,
                User_Id    = loginToken.User.User_Id
            };

            facade.MofidyAirlineDetails(null, airline);
        }
Exemplo n.º 9
0
        public IHttpActionResult MofidyAirlineDetails(AirlineCompany airline)
        {
            LoginToken <AirlineCompany> airlineToken = new LoginToken <AirlineCompany>();

            try
            {
                airlineCompanyFacade.MofidyAirlineDetails(airlineToken, airline);
                return(Ok());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(BadRequest());
            }
        }
Exemplo n.º 10
0
        public void MofidyAirlineDetails_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "adi213", "54321");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            AirlineCompany airline = new AirlineCompany
            {
                Id         = loginToken.User.Id,
                Name       = loginToken.User.Name,
                Country_Id = 4,
                User_Id    = loginToken.User.User_Id
            };

            facade.MofidyAirlineDetails(loginToken, airline);
            Assert.AreEqual(loginToken.User.Country_Id, 4);
        }
Exemplo n.º 11
0
        public void AirlineFacade_MofidyAirlineDetails()
        {
            LoggedInAirlineFacade facade = FlyingCenterSystem.GetInstance().Login(TestResource.AIRLINE_USERNAME, TestResource.AIRLINE_PASSWORD, out LoginTokenBase login) as LoggedInAirlineFacade;

            IList <AirlineCompany> companies = facade.GetAllAirlineCompanies();

            AirlineCompany company1 = companies[0];

            company1.CountryCode = 3;

            facade.MofidyAirlineDetails(login as LoginToken <AirlineCompany>, company1);

            Assert.AreEqual(3, company1.CountryCode);

            Assert.AreEqual(TestResource.AIRLINE_NAME, company1.AirlineName);
        }
Exemplo n.º 12
0
        public void WrongDetailsToUpdateUserException()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "dana111", "gdfds");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            User user = new User
            {
                Id        = loginToken.User.User.Id,
                User_Name = loginToken.User.User.User_Name,
                Password  = loginToken.User.User.Password,
                Email     = "*****@*****.**",
                User_Role = loginToken.User.User.User_Role
            };

            _airlineDAO.Get(1).User = user;
            facade.MofidyAirlineDetails(loginToken, _airlineDAO.Get(1));
        }
Exemplo n.º 13
0
        public void UpdateUserDetails_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "dana131", "gdfds");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            User user = new User
            {
                Id        = loginToken.User.User.Id,
                User_Name = "dana111",
                Password  = loginToken.User.User.Password,
                Email     = loginToken.User.User.Email,
                User_Role = loginToken.User.User.User_Role
            };

            _airlineDAO.Get(1).User = user;
            facade.MofidyAirlineDetails(loginToken, _airlineDAO.Get(1));
            Assert.AreEqual(_userDAO.Get(4).User_Name, "dana111");
        }