示例#1
0
        public List <Cargo> GetAllCargo()
        {
            string       sqlQuery  = @"SELECT Cargo.PlaneId, Plane.PlaneName, Cargo.Id, Cargo.CargoItem FROM Cargo
                                INNER JOIN Plane ON Cargo.PlaneId = Plane.Id";
            DataTable    dataTable = _dBO.GetTable(sqlQuery, null, CommandType.Text);
            List <Cargo> listCargo = new List <Cargo>();

            if (dataTable.Rows.Count > 0)
            {
                listCargo = dataTable.AsEnumerable().Select(m => new Cargo()
                {
                    Id        = m.Field <int>("Id"),
                    PlaneId   = m.Field <int>("PlaneId"),
                    PlaneName = m.Field <string>("PlaneName"),
                    CargoItem = m.Field <string>("CargoItem"),
                }).ToList();
            }
            return(listCargo);
        }
示例#2
0
        public List <Plane> GetAllPlanes()
        {
            string       sqlQuery  = "Select * from Plane";
            DataTable    dataTable = _dBO.GetTable(sqlQuery, null, CommandType.Text);
            List <Plane> listPlane = new List <Plane>();

            if (dataTable.Rows.Count > 0)
            {
                listPlane = dataTable.AsEnumerable().Select(m => new Plane()
                {
                    Id              = m.Field <int>("Id"),
                    PlaneName       = m.Field <string>("PlaneName"),
                    PlaneType       = m.Field <string>("PlaneType"),
                    Capacity        = m.Field <int>("Capacity"),
                    PassengerNumber = m.Field <int>("PassengerNumber"),
                }).ToList();
            }
            return(listPlane);
        }
示例#3
0
        public List <Customer> GetAllCustomers()
        {
            string          sqlQuery  = "Select * from Customer";
            DataTable       dataTable = _dBO.GetTable(sqlQuery, null, CommandType.Text);
            List <Customer> listCust  = new List <Customer>();

            if (dataTable.Rows.Count > 0)
            {
                listCust = dataTable.AsEnumerable().Select(m => new Customer()
                {
                    Id      = m.Field <int>("Id"),
                    Name    = m.Field <string>("Name"),
                    Address = m.Field <string>("Address"),
                    City    = m.Field <string>("City"),
                    Country = m.Field <string>("Country"),
                    Contact = m.Field <long>("Contact"),
                    Email   = m.Field <string>("Email"),
                }).ToList();
            }
            return(listCust);
        }
        public List <PlaneBook> GetAllBooking()
        {
            string           sqlQuery      = @"SELECT PlaneBook.PlaneId, Plane.PlaneName, Plane.PlaneType, Cargo.CargoItem, PlaneBook.BookedBy, PlaneBook.CustomerId, Customer.Name AS [CustomerName], PlaneBook.Id AS [BookId], PlaneBook.Departure, PlaneBook.Arrival
                                FROM PlaneBook LEFT JOIN Plane ON PlaneBook.PlaneId = Plane.Id
								LEFT JOIN Cargo ON PlaneBook.CargoId = Cargo.Id
                                LEFT JOIN Customer ON PlaneBook.CustomerId = Customer.Id";
            DataTable        dataTable     = _dBO.GetTable(sqlQuery, null, CommandType.Text);
            List <PlaneBook> listPlaneBook = new List <PlaneBook>();

            if (dataTable.Rows.Count > 0)
            {
                listPlaneBook = dataTable.AsEnumerable().Select(m => new PlaneBook()
                {
                    PlaneList = new Plane()
                    {
                        Id        = m.Field <int>("PlaneId"),
                        PlaneName = m.Field <string>("PlaneName"),
                        PlaneType = m.Field <string>("PlaneType")
                    },
                    CustomerList = new Customer()
                    {
                        Id   = m.Field <int?>("CustomerId"),
                        Name = m.Field <string>("CustomerName"),
                    },
                    CargoList = new Cargo()
                    {
                        CargoItem = m.Field <string>("CargoItem"),
                    },
                    Id        = m.Field <int>("BookId"),
                    Departure = m.Field <DateTime>("Departure"),
                    Arrival   = m.Field <DateTime?>("Arrival"),
                    BookedBy  = m.Field <string>("BookedBy")
                }).ToList();
            }
            return(listPlaneBook);
        }