public void RemoveCustomer(LogInToken <Adminstrator> token, Customer customer)
 {
     if (customer != null)
     {
         _customerDAO.Remove(customer);
     }
 }
 public void CancelFlight(LogInToken <AirlineCompany> token, Flight flight)
 {
     if (flight.AirlineCompanyId == token.user.Id)
     {
         base._FlightDAO.Remove(flight);
     }
 }
Пример #3
0
        public bool TryAirlineCompany(string userName, string password, out LogInToken <AirlineCompany> token)
        {
            AirlineCompany airlineCompany = new AirlineCompany();
            SqlCommand     cmd            = con.GetSQLCommand();

            cmd.CommandText = $"select * FROM AirLineCompanies where USER_NAME= '{userName}' AND PASSWORD='******';";
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

            while (reader.Read())
            {
                var r = new
                {
                    Id          = (long)reader["ID"],
                    AirlineName = (string)reader["AIRLINE_NAME"],
                    Username    = (string)reader["USER_NAME"],
                    Password    = (string)reader["PASSWORD"],
                    CountryCode = (long)reader["COUNTRY_CODE"],
                };
                if (r == null)
                {
                    token = null;
                    return(false);
                }

                airlineCompany.Id          = r.Id;
                airlineCompany.AirlineName = r.AirlineName;
                airlineCompany.Username    = r.Username;
                airlineCompany.Password    = r.Password;
                airlineCompany.CountryCode = r.CountryCode;
            }
            token      = new LogInToken <AirlineCompany>();
            token.user = airlineCompany;

            return(true);
        }
Пример #4
0
        public bool TryCustomerLogin(string UserName, string Password, out LogInToken <Customer> token)
        {
            Customer   customer = new Customer();
            SqlCommand cmd      = con.GetSQLCommand();

            cmd.CommandText = $"select * FROM AiRLineCompanies where USER_NAME= '{UserName}' AND PASSWORD='******';";
            SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.Default);

            if (reader.FieldCount == 0)
            {
                token = null;
                return(false);
            }
            while (reader.Read())
            {
                customer.Id               = (long)reader[0];
                customer.FirstName        = (string)reader[1];
                customer.LastName         = (string)reader[2];
                customer.UserName         = (string)reader[3];
                customer.Password         = (string)reader[4];
                customer.Address          = (string)reader[5];
                customer.PhoneNumber      = (string)reader[6];
                customer.CreditCardNumber = (string)reader[7];
            }
            token      = new LogInToken <Customer>();
            token.user = customer;
            return(true);
        }
 public void UpdateCustoemrDetails(LogInToken <Adminstrator> token, Customer customer)
 {
     if (customer != null)
     {
         _customerDAO.Update(customer);
     }
 }
Пример #6
0
        public bool TryAdminLogin(string UserName, string Password, out LogInToken <Adminstrator> token)
        {
            Adminstrator admin = new Adminstrator();
            SqlCommand   cmd   = con.GetSQLCommand();

            cmd.CommandText = $"select * FROM Administrator where USERNAME= '******' AND PASSWORD='******';";
            SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.Default);

            while (reader.Read())
            {
                var r = new
                {
                    Id = (long)reader[0],
                    u  = (string)reader[1],
                    p  = (string)reader[2]
                };
                if (r == null)
                {
                    token = null;
                    return(false);
                }
                else
                {
                    admin.Id       = r.Id;
                    admin.UserName = r.u;
                    admin.Password = r.p;
                }
            }
            token      = new LogInToken <Adminstrator>();
            token.user = admin;
            return(true);
        }
 public void CreateNewCustomer(LogInToken <Adminstrator> token, Customer customer)
 {
     if (customer != null)
     {
         _customerDAO.Add(customer);
     }
 }
 public void UpdateAirlineDetails(LogInToken <Adminstrator> token, AirlineCompany airline)
 {
     if (airline != null)
     {
         _airlineDAO.Update(airline);
     }
 }
 public void RemoveAirline(LogInToken <Adminstrator> token, AirlineCompany airline)
 {
     if (airline != null)
     {
         _airlineDAO.Remove(airline);
     }
 }
 public void CreateNewAirline(LogInToken <Adminstrator> token, AirlineCompany airline)
 {
     if (airline != null)
     {
         _airlineDAO.Add(airline);
     }
 }
 public void UpdateFlight(LogInToken <AirlineCompany> token, Flight flight)
 {
     if (token.user.Id == flight.AirlineCompanyId)
     {
         base._FlightDAO.Update(flight);
     }
 }
 public void MofidyAirlineDetails(LogInToken <AirlineCompany> token, AirlineCompany airlineCompany)
 {
     if (true)
     {
         base._airlineDAO.Update(airlineCompany);
     }
 }
 public void ChangeMyPassword(LogInToken <AirlineCompany> token, string oldPassword, string newPassword)
 {
     if (token.user.Password == oldPassword)
     {
         SqlCommand cmd = con.GetSQLCommand();
         cmd.CommandText = $"UPDATE AieLineCompanies SET PASSWORD='******' WHERE ID={token.user.Id}";
     }
 }
        public IList <Ticket> GetAllTickets(LogInToken <AirlineCompany> token)
        {
            List <Ticket> listOfTicketsFromTheSameCompany = new List <Ticket>();
            Ticket        ticket = new Ticket();
            SqlCommand    cmd    = con.GetSQLCommand();

            cmd.CommandText = $"SELEcT * FROM Tickets WHERE FLIGHT_ID=(SELECT ID FROM Flights WHERE AIRLINECOMPANY_ID ={token.user.Id} ); ";
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

            while (reader.Read())
            {
                ticket.Id         = (long)reader["ID"];
                ticket.CustomerId = (long)reader["CUSTOMER_ID"];
                ticket.FlightId   = (long)reader["FLIGHT_ID"];
                listOfTicketsFromTheSameCompany.Add(ticket);
            }
            return(listOfTicketsFromTheSameCompany);
        }
        public IList <Flight> GettAllFlighs(LogInToken <AirlineCompany> token)
        {
            List <Flight> listOfFlighttsFromTheSameAirLineComapy = new List <Flight>();
            Flight        flight = new Flight();
            SqlCommand    cmd    = con.GetSQLCommand();

            cmd.CommandText = $"SELECT * FROM Flights WHERE AIRLINECOMPANY_ID={token.user.Id} ); ";
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

            while (reader.Read())
            {
                flight.Id = (long)reader[0];
                flight.AirlineCompanyId       = (long)reader[1];
                flight.OriginCountryCode      = (long)reader[2];
                flight.DistinationCountryCode = (long)reader[3];
                flight.DepartureTime          = (DateTime)reader[4];
                flight.LandingTime            = (DateTime)reader[4];
                flight.RemainingTickets       = (int)reader[4];
                listOfFlighttsFromTheSameAirLineComapy.Add(flight);
            }
            return(listOfFlighttsFromTheSameAirLineComapy);
        }
 public Ticket PurchaseTicket(LogInToken <Customer> token, Flight flight)
 {
     throw new NotImplementedException();
 }
 public IList <Flight> GetAllMyFlights(LogInToken <Customer> token)
 {
     return(_FlightDAO.GetFlightsByCustomer(token.user));
 }
 public void CancelTicket(LogInToken <Customer> token, Ticket ticket)
 {
     throw new NotImplementedException();
 }