Exemplo n.º 1
0
        public async Task <ActionResult> GetAll()
        {
            List <Country> countries = new List <Country>();
            await Task.Run(() => countries = new CountryDAOPGSQL().GetAll());

            return(Ok(countries));
        }
Exemplo n.º 2
0
        public FlightProfile()
        {
            Dictionary <int, string> map_airline_id_to_name = new Dictionary <int, string>();

            List <AirlineCompany> airlines = new AirlineDAOPGSQL().GetAll();

            foreach (AirlineCompany airline in airlines)
            {
                map_airline_id_to_name.Add(airline.Id, airline.Name);
            }

            Dictionary <int, string> map_countryid_to_name = new Dictionary <int, string>();

            List <Country> countries = new CountryDAOPGSQL().GetAll();

            foreach (Country country in countries)
            {
                map_countryid_to_name.Add(country.Id, country.Name);
            }

            CreateMap <Flight, FlightDTO>()
            .ForMember(dest => dest.Id,
                       opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Airline_Company_Name,
                       opt => opt.MapFrom(src => map_airline_id_to_name[src.Airline_Company_Id]))
            .ForMember(dest => dest.Origin_Country_Name,
                       opt => opt.MapFrom(src => map_countryid_to_name[src.Origin_Country_Id]))
            .ForMember(dest => dest.Destination_Country_Name,
                       opt => opt.MapFrom(src => map_countryid_to_name[src.Destination_Country_Id]))
            .ForMember(dest => dest.Departure_Time,
                       opt => opt.MapFrom(src => src.Departure_Time))
            .ForMember(dest => dest.Landing_Time,
                       opt => opt.MapFrom(src => src.Landing_Time));
        }
Exemplo n.º 3
0
        public static string returnNameFromId(long id)
        {
            CountryDAOPGSQL countryDAOPGSQL = new CountryDAOPGSQL();
            IList <Country> countries       = countryDAOPGSQL.GetAll();

            foreach (Country country in countries)
            {
                if (country.Id == id)
                {
                    return(country.Name);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public static long ReturnIdFromName(string name)
        {
            CountryDAOPGSQL countryDAOPGSQL = new CountryDAOPGSQL();
            IList <Country> countries       = countryDAOPGSQL.GetAll();

            foreach (Country country in countries)
            {
                if (country.Name == name)
                {
                    return(country.Id);
                }
            }
            return(0);
        }
        static void Main(string[] args)
        {
            CountryDAOPGSQL country = new CountryDAOPGSQL();

            Console.WriteLine(ConnectionDataInfo.TestConnection(AppConfigFile.GetInstance().ConnectionString));
            //Tickets a = new Tickets();

            Administrators a = new Administrators()
            {
                FirstName = "Patreck", LastName = "Sky", Level = 1, UserID = 2
            };

            AdministratorsDAOPGSQL admin = new AdministratorsDAOPGSQL();

            admin.Add(a);
            //admin.Get(2);
            //admin.GetAll();
        }
        public AirlineCompanyProfile()
        {
            List <Country> countries = new CountryDAOPGSQL().GetAll();

            foreach (Country country in countries)
            {
                map_countryid_to_name.Add(country.Id, country.Name);
            }


            CreateMap <AirlineCompany, AirlineDTO>()
            .ForMember(dest => dest.CountryName,
                       opt => opt.MapFrom(src => map_countryid_to_name[src.Country_Id]))
            .ForMember(dest => dest.Id,
                       opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name,
                       opt => opt.MapFrom(src => src.Name));
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            TestDbConnection();
            //CountryDAOPGSQL countryDAOPGSQL = new CountryDAOPGSQL();

            //Country countryDominicana = new Country
            //{
            //    Name = "Dominicana"
            //};

            //countryDAOPGSQL.Add(countryDominicana);



            ////var countries = countryDAOPGSQL.GetAll();

            ////foreach (var c in countries)
            ////{
            ////    var id = ((dynamic)c).Id;
            ////    var name = ((dynamic)c).Name;

            ////    Console.WriteLine($"{id} {name}");
            ////}

            //Console.WriteLine(countryDAOPGSQL.Get(6));

            //countryDAOPGSQL.Remove(countryDominicana);

            ////countryDAOPGSQL.Update(countryDominicana);

            //var countries = countryDAOPGSQL.GetAll();

            //foreach (var c in countries)
            //{

            //admin.Add(admin1);       //    var id = ((dynamic)c).Id;
            //    var name = ((dynamic)c).Name;

            //    Console.WriteLine($"{id} {name}");
            //}



            //UserDAOPGSQL user = new UserDAOPGSQL();
            //AdminDAOPGSQL admin = new AdminDAOPGSQL();
            //DeleteAllData();
            //User manager2 = new User
            //{
            //    Username = "******",
            //    Password = "******",
            //    Email = "*****@*****.**",
            //    User_Role = 3
            //};
            //user.Add(manager2);



            //var u = user.GetByUserName("manager2");

            //long id = u.Id;

            //Console.WriteLine(id);

            //Admin admin1 = new Admin("Mary", "Mill", 1, id);


            UserDAOPGSQL user = new UserDAOPGSQL();
            //AdminDAOPGSQL admin = new AdminDAOPGSQL();
            CustomerDAOPGSQL       customerDAOPGSQL       = new CustomerDAOPGSQL();
            FlightDAOPGSQL         flightDAOPGSQL         = new FlightDAOPGSQL();
            AirlineCompanyDAOPGSQL airlineCompanyDAOPGSQL = new AirlineCompanyDAOPGSQL();
            CountryDAOPGSQL        countryDAOPGSQL        = new CountryDAOPGSQL();

            AnonymousUserFacade facade = FlightsCenterSystem.GetInstance().GetFacade <Anonymous>(null) as AnonymousUserFacade;
            //DeleteAllData();


            //LoginToken<Admin> token = new LoginToken<Admin>(


            //    );
            //token.User.UserName = FlightCenterConfig.ADMIN_NAME;
            //token.User.Password = FlightCenterConfig.ADMIN_PASSWORD;

            //User user0 = new User
            //{
            //    Username = "******",
            //    Password = "******",
            //    Email = "*****@*****.**",
            //    User_Role = 1
            //};
            //user.Add(user0);

            //var uA = user.GetByUserName("Airline");
            //long idA = uA.Id;


            //AirlineCompany airline = new AirlineCompany
            //{
            //    Name = "AirlineCompany1",
            //    Country_Id = 1,
            //    User_Id = (int)idA
            //};
            //airlineCompanyDAOPGSQL.Add(airline);

            //var a = airlineCompanyDAOPGSQL.GetAirlineByUserame("Airline");
            //Console.WriteLine("aurline: " + a);
            //long a_id = a.Id;

            //Flight flight = new Flight
            //{
            //    Airline_Company_Id = (long)a_id,
            //    Origin_Country_Id = 1,
            //    Destination_Country_Id = 2,
            //    Departure_Time = new DateTime(2021, 05, 09, 12, 00, 00),
            //    Landing_Time = new DateTime(2021, 05, 09, 18, 00, 00),
            //    Tickets_Remaining = 100
            //};
            //flightDAOPGSQL.Add(flight);

            //User user1 = new User
            //{
            //    Username = "******",
            //    Password = "******",
            //    Email = "*****@*****.**",
            //    User_Role = 1
            //};
            //user.Add(user1);

            //var u = user.GetByUserName("Customer");
            //long id = u.Id;

            //Customer customer = new Customer()
            //{
            //    First_Name = "name",
            //    Last_Name = "lNAme",
            //    Address = "Adress",
            //    Phone_No = "Phone",
            //    Credit_Card_No = "Card",
            //    User_Id = id
            //};

            //loginService.TryAdminLogin(FlightCenterConfig.ADMIN_NAME, FlightCenterConfig.ADMIN_PASSWORD, out LoginToken<Admin> tokenAdmin);
            //LoggedInAdministratorFacade facadeAdmin = FlightsCenterSystem.GetInstance().GetFacade<Admin>(tokenAdmin) as LoggedInAdministratorFacade;

            //facadeAdmin.CreateNewCustomer(tokenAdmin, customer);
            //Customer c = facadeAdmin.GetAllCustomers(tokenAdmin)[0];
            //// facadeAdmin.CreateNewCustomer(tokenAdmin, customer);


            //LoginToken<Customer> tokenCustomer = new LoginToken<Customer>()
            //{
            //    User = c
            //};
            //loginService.TryCustomerLogin("Customer", "c112", out tokenCustomer);
            //Customer customer1 = customerDAOPGSQL.GetCustomerByUserName("Customer");
            // loginService.TryCustomerLogin ("Customer", "c112", out tokenCustomer);


            //LoggedInCustomerFacade fasadeCustomer = FlightsCenterSystem.GetInstance().GetFacade(tokenCustomer) as LoggedInCustomerFacade;
            //var myFlight = flightDAOPGSQL.GetAll()[0];
            //Ticket t = fasadeCustomer.PurchaseTicket(tokenCustomer, myFlight);
            // Console.WriteLine(tokenCustomer);
            // Console.WriteLine(customer1.Password);
            // Console.WriteLine(c.U);


            // User manager2 = new User
            // {
            //     Username = "******",
            //     Password = "******",
            //     Email = "*****@*****.**",
            //     User_Role = 3
            // };


            // //User manager3 = new User
            // //{
            // //    Username = "******",
            // //    Password = "******",
            // //    Email = "*****@*****.**",
            // //    User_Role = 3
            // //};

            // user.Add(manager2);
            // //user.Add(manager3);


            // var u = user.GetByUserName("manager2");

            //// var u3 = user.GetByUserName("manager3");

            // long id = u.Id;
            // Admin admin1 = new Admin
            // {
            //     First_Name = "Mary",
            //     Last_Name = "Mill",
            //     Level = 3,
            //     User_id = id
            // };



            // //long id3 = u3.Id;
            // //Admin adminLevel1 = new Admin
            // //{
            // //    First_Name = "Parry",
            // //    Last_Name = "Mill",
            // //    Level = 1,
            // //    User_id = id3
            // //};



            //  admin.Add(admin1);


            //var list = admin.GetAll();
            //list.RemoveAt(0);
            //facadeAdminLevel3.RemoveAdmin(tokenAdminLevel3, list[0]);
            //list = admin.GetAll();

            //list.Remove(admin1);
            //list = admin.GetAll();
            //Console.WriteLine(list.Count);

            // Console.WriteLine(token.User.UserName);


            //customerDAOPGSQL.Add(customer);
            //facadeAdmin.CreateNewCustomer(token, customer);
            //var list = facadeAdmin.GetAllCustomers(token);

            //Console.WriteLine(list.Count);



            // var l_cust = facadeAdmin.GetAllCustomers(token);

            //Console.WriteLine(l_cust[1]);

            //AirlineCompany airline = new AirlineCompany
            //{
            //    Name = "AirlineCompany1",
            //    Country_Id = 1,
            //    User_Id = (int)id
            //};
            //airlineCompanyDAOPGSQL.Add(airline);

            //var a = airlineCompanyDAOPGSQL.GetAirlineByUserame("airline1");
            //Console.WriteLine("aurline: " + a);
            //long a_id = a.Id;

            //Flight flight = new Flight
            //{
            //    Airline_Company_Id = (long)a_id,
            //    Origin_Country_Id = 1,
            //    Destination_Country_Id = 2,
            //    Departure_Time = new DateTime(2021, 05, 09, 12, 00, 00),
            //    Landing_Time = new DateTime(2021, 05, 09, 18, 00, 00),
            //    Tickets_Remaining = 100
            //};
            //flightDAOPGSQL.Add(flight);

            //var f_list = flightDAOPGSQL.GetAll();
            //var f = facade.GetFlightsByDestinationCountry(2);

            //Console.WriteLine(f[0].Id);
            //Console.WriteLine(f[0].Landing_Time);
            //Console.WriteLine(f[0].NameOfOriginCountry);
        }