Exemplo n.º 1
0
        public List <Flight> GetFlightList()
        {
            var flightsEntityList = new List <Flight>();

            try
            {
                //TraceManager.StartMethodTrace(parameters: "flightEntity: " + JsonConvert.SerializeObject(flightEntity));

                // Build the filters

                var flights = this.DatabaseContext.Flight
                              .Include(flight => flight.DepartureAirport)
                              .Include(flight => flight.DestinationAirport);

                if (flights.Any())
                {
                    flightsEntityList = DataAutoMapper.Map <List <Flight> >(flights.ToList());
                }

                return(flightsEntityList);
            }
            finally
            {
                //TraceManager.FinishMethodTrace(output: "flightsEntityList: " + JsonConvert.SerializeObject(flightsEntityList));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the airport list
        /// </summary>
        /// <param name="airportEntity">Airport data</param>
        /// <returns>Return the airports List with the data </returns>
        public List <Airport> GetAirports(Airport airportEntity)
        {
            var airportsEntityList = new List <Airport>();

            try
            {
                //TraceManager.StartMethodTrace(parameters: "airportEntity: " + JsonConvert.SerializeObject(airportEntity));

                // Build the filters
                var getPredicateBuilderForGetAirports = AirportsPredicateBuilder.GetPredicateBuilderForGetAirports(airportEntity);

                var airports = this.DatabaseContext.Airport
                               .Where(getPredicateBuilderForGetAirports);

                if (airports.Any())
                {
                    airportsEntityList = DataAutoMapper.Map <List <Airport> >(airports.ToList());
                }

                return(airportsEntityList);
            }
            finally
            {
                //TraceManager.FinishMethodTrace(output: "airportsEntityList: " + JsonConvert.SerializeObject(airportsEntityList));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an airport
        /// </summary>
        /// <param name="airportEntity">entity with the info</param>
        public void CreateAirport(Airport airportEntity)
        {
            try
            {
                //TraceManager.StartMethodTrace(parameters: "airportEntity: " + JsonConvert.SerializeObject(airportEntity));

                var airport = DataAutoMapper.Map <Models.Schemas.dbo.Airport>(airportEntity);
                //TraceManager.ObjectDataTrace("airport", JsonConvert.SerializeObject(airport));

                DatabaseContext.Airport.AddOrUpdate(airport);
                DatabaseContext.SaveChanges();
            }
            finally
            {
                //TraceManager.FinishMethodTrace();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update or insert in a flight
        /// </summary>
        /// <param name="flightEntity">entity with the info</param>
        public void CreateFlight(Flight flightEntity)
        {
            try
            {
                //TraceManager.StartMethodTrace(parameters: "flightEntity: " + JsonConvert.SerializeObject(flightEntity));

                var flight = DataAutoMapper.Map <Models.Schemas.dbo.Flight>(flightEntity);
                //TraceManager.ObjectDataTrace("flight", JsonConvert.SerializeObject(flight));

                flight.DepartureAirport   = DatabaseContext.Airport.FirstOrDefault(airport => airport.Name.Equals(flight.DepartureAirport.Name));
                flight.DestinationAirport = DatabaseContext.Airport.FirstOrDefault(airport => airport.Name.Equals(flight.DestinationAirport.Name));

                DatabaseContext.Flight.AddOrUpdate(flight);
                DatabaseContext.SaveChanges();
            }
            finally
            {
                //TraceManager.FinishMethodTrace();
            }
        }