public AirportService( IAirportsRepository airportsRepository, IMappingService mappingService) { _airportsRepository = airportsRepository; _mappingService = mappingService; }
/// <summary> /// Generate report by ItineraryId /// </summary> /// <param name="itineraryId"></param> /// <returns></returns> public ActionResult GenerateReport(long itineraryId) { _airportsRepository = new AirportsRepository(); _itinerarysRepository = new ItinerarysRepository(); _usersRepository = new UsersRepository(); var itineraryInfo = _itinerarysRepository.Get(itineraryId); var userInfo = new Users(); _listF = new List <Flights>(); if (itineraryInfo != null) { userInfo = _usersRepository.Get(itineraryInfo.UserID); foreach (var flight in itineraryInfo.Flights) { flight.DepartureLocation = _airportsRepository.Get(flight.DepartureLocation).AirportID; flight.ArrivalLocation = _airportsRepository.Get(flight.ArrivalLocation).AirportID; } } ViewBag.itineraryInfo = itineraryInfo; return(View()); }
/// <summary> /// Get Airports information /// </summary> /// <returns></returns> private List <string> GetAirports() { _airportsRepository = new AirportsRepository(); var airports = _airportsRepository.All(); return(airports.Where(x => x.IsTestAirport == false).Select(item => item.AirportDesignationLetters).ToList()); }
public AirportsService(IAirportsHttpService airportsHttpService, IAirportsRepository airportsRepository, IMapperFactory mapperFactory) { AirportsHttpService = airportsHttpService; AirportsRepository = airportsRepository; MapperFactory = mapperFactory; }
/// <summary> /// Insert flight into a temporal list for then save the flight information in the database of fights and itineraries. /// </summary> /// <param name="model"></param> public void InsertFlightIntoList(BasicItineraryModel model) { var airlineInfo = _airlinesRepository.GetAirlinebyName(model.AirlineName); _airportsRepository = new AirportsRepository(); _passengerRepository = new PassengerRepository(); if (airlineInfo == null) { return; } var airlineId = airlineInfo.AirlineID; var airportInfo1 = _airportsRepository.GetAirportbyName(model.DepartureName); var airportInfo2 = _airportsRepository.GetAirportbyName(model.ArrivalName); if ((airportInfo1 == null) || (airportInfo2 == null)) { return; } var departureLocation = airportInfo1.AirportID; var arrivalLocation = airportInfo2.AirportID; var flight = new Flights { AirlineID = airlineId, DepartureLocation = departureLocation, FlightNumber = model.FlightNumber, ArrivalLocation = arrivalLocation, DepartureDateTime = (DateTime)model.DepartureTime, ArrivalDateTime = (DateTime)model.ArrivalTime, }; _listF.Add(flight); _listIti.Add(model); var passenger = _passengerRepository.Get(model.PassengerEmail); if (passenger == null) { passenger = new Passengers { PassengerEmail = model.PassengerEmail, PassengerLastName = model.PassengerLastName, PassengerName = model.PassengerName, TokenId = "TokenID" }; _passengerRepository.Add(passenger); } }
public DataServiceController(IContractsRepository cntrcRep, ITradersRepository trdrRep, IOrdersRepository ordRep, IInvoicesRepository invRep, IItemsRepository itmRep, IAirportsRepository airRep, IAircraftsRepository acrRep, ICurrenciesRepository curRep) { _contractsRepository = cntrcRep; _tradersRepository = trdrRep; _ordersRepository = ordRep; _invoicesRepository = invRep; _itemsRepository = itmRep; _airportsRepository = airRep; _aircraftsRepository = acrRep; _currenciesRepository = curRep; }
public void Setup() { var services = new ServiceCollection(); //Inject repositories services.AddTransient <IAirportsRepository, AirportsRepository>(); //Inject services services.AddTransient <IAirportsService, AirportsService>(); services.AddDbContext <AirportsContext>(options => { options.UseInMemoryDatabase("InMemoryDbForTesting"); }); var serviceProvider = services.BuildServiceProvider(); _airportService = serviceProvider.GetService <IAirportsService>(); _airportRepository = serviceProvider.GetService <IAirportsRepository>(); SetupDatabase(); }
public void PrepareRepositories(bool initialize = false) { // Kick the model creation process if not already created (hence force is false). In other words, do // not wait on any database activities. Without this, nothing happens unless some context activities take // place. _context = new AviTradeContext(); if (initialize) { // Kick the model creation process if not already created (hence force is false). In other words, do // not wait on any database activities. Without this, nothing happens unless some context activities take // place. _context.Database.Initialize(force: false); } _contractsRepository = new ContractsRepository(_context); _airportsRepository = new AirportsRepository(_context); _aircraftsRepository = new AircraftsRepository(_context); _itemsRepository = new ItemsRepository(_context); _currenciesRepository = new CurrenciesRepository(_context); _periodsRepository = new PeriodsRepository(_context); _invoicesRepository = new InvoicesRepository(_context, _periodsRepository); _ordersRepository = new OrdersRepository(_context, _contractsRepository, _airportsRepository, _aircraftsRepository, _itemsRepository, _currenciesRepository, _invoicesRepository); _tradersRepository = new TradersRepository(_context); }
public DetailsModel(IAirportsRepository r) : base(r) { }
public AirportsManager(IAirportsRepository airportsRepository) { this.airportsRepository = airportsRepository; }
public CreateModel(IAirportsRepository r) : base(r) { }
public IndexModel(IAirportsRepository r) : base(r) { }
public AirportsService(IAirportsRepository airportsRepository) { _airportsRepository = airportsRepository; }
internal TestClass(IAirportsRepository r) : base(r) { }
public ActionResult InsertBasic(string Stops, string TripTypeName, string PassengerName, string PassengerLastName, string PassengerEmail) { _airlinesRepository = new AirlinesRepository(); _airportsRepository = new AirportsRepository(); _tagsRepository = new TagsRepository(); _passengerRepository = new PassengerRepository(); _itineraryPingersRepository = new ItineraryPingersRepository(); new UserTagsRepository(); _usersRepository = new UsersRepository(); _monitoredFlightsRepository = new MonitoredFlightsRepository(); _itinerarysRepository = new ItinerarysRepository(); _flightsRepository = new FlightsRepository(); new GatewayAirlineRepository(); #region Create Itinerary var model = new BasicItineraryModel { //ConnxysTagId = ConnxysTagId, DepartureTime = _listF.First().DepartureDateTime, ArrivalTime = _listF.Last().ArrivalDateTime, DepartureName = _airportsRepository.Get(_listF.First().DepartureLocation).AirportDesignationLetters, ArrivalName = _airportsRepository.Get(_listF.Last().ArrivalLocation).AirportDesignationLetters, Stops = Convert.ToInt32(Stops), TripTypeName = TripTypeName, DepartDateTimeUTC = _listIti.First().DepartDateTimeUTC, ArrivalDateTimeUTC = _listIti.Last().ArrivalDateTimeUTC }; object jsonData; //Get Passenger Information var passenger = _passengerRepository.Get(PassengerEmail); passenger.PassengerName = PassengerName; passenger.PassengerLastName = PassengerLastName; _passengerRepository.Update(passenger); var itinerary = new Itinerary { //UserID = userInfo.userID, UserID = 0, Stops = model.Stops, DepartDateTime = model.DepartureTime, ArrivalDateTime = model.ArrivalTime, AirlineReservationID = model.AirlineReservationId, RetStops = model.RetStops, TripType = (short?)int.Parse(model.TripTypeName), From = model.DepartureName, To = model.ArrivalName, CreationDate = DateTime.UtcNow, Type = "Real Flight", PassengerID = passenger != null ? passenger.PassengerID : 0, DepartDateTimeUTC = model.DepartDateTimeUTC, ArrivalDateTimeUTC = model.ArrivalDateTimeUTC }; try { //insert the new itinerary _itinerarysRepository.Add(itinerary); var itineraryId = itinerary.ItineraryID; if (itineraryId > 0) { var connxysWcfRestService = new ConnxysWCFRestService(); var flightsList = new StringBuilder(); var currentFlight = 0L; var flightInd = 0; //insert all the flights foreach (var flightItem in _listF) { flightItem.ItineraryID = itineraryId; _flightsRepository.Add(flightItem); if (flightInd == (_listF.Count - 1)) { flightsList.Append(flightItem.FlightID); } else { flightsList.Append(flightItem.FlightID).Append("-"); } if (flightInd == 0) { currentFlight = flightItem.FlightID; } var monitoredFlights = new MonitoredFlights(); { monitoredFlights.FlightId = flightItem.FlightID; monitoredFlights.FlightNumber = flightItem.FlightNumber; monitoredFlights.StartDate = Convert.ToDateTime(flightItem.DepartureDateTime); monitoredFlights.EndDate = Convert.ToDateTime(flightItem.ArrivalDateTime); monitoredFlights.DepartureLocation = flightItem.DepartureLocation; monitoredFlights.ArrivalLocation = flightItem.ArrivalLocation; monitoredFlights.Status = 0; var airline = _airlinesRepository.Get(flightItem.AirlineID); monitoredFlights.AirlineDesignator = airline.AirlineDesignator; monitoredFlights.AirlineName = airline.AirlineName; } //Insert monitoredflight in the database _monitoredFlightsRepository.Add(monitoredFlights); // Increase Flight index flightInd++; } //insert all the bags foreach (var bagItem in _listB) { var baggageInfo = new BaggageInfo { BagIATANumber = bagItem.BagIATANumber, ItineraryId = itineraryId, PingerId = bagItem.ConnxysTagID, PassengerEmail = passenger.PassengerEmail, PassengerLastName = passenger.PassengerLastName, PassengerName = passenger.PassengerName }; connxysWcfRestService.UpdateBaggageInfo(baggageInfo); var itineraryPinger = new ItineraryPingers { ItineraryID = itinerary.ItineraryID, ConnxysTagID = bagItem.ConnxysTagID }; _itineraryPingersRepository.Add(itineraryPinger); } _listB = new List <BagTagDesignation>(); var creationDate = DateTime.Now.ToUniversalTime(); _storeProcedureRepository = new StoreProcedureRepository(); _storeProcedureRepository.CreateOutgoingMessage(itinerary.ItineraryID, null, null, null, null, Convert.ToInt64(model.TagId), "Manually", creationDate, false); //Create notification message to sent a message to the passenger abput the itinerary creation var notification = new NotificationMessage { Title = "Itinerary Information", Message = string.Format ("Hello {0}! We’re excited to have you fly with us on flight #: {1} to {2}. We’ll notify you when your bag is checked in, when it’s been loaded aboard your flight, and where you can reclaim it in {3}. Enjoy your flight with us!", passenger.PassengerName, _listF[0].FlightNumber.ToString(), model.ArrivalName, model.ArrivalName), TokenId = passenger.TokenId }; foreach (var fl in _listF) { var airlineDesignator = _airlinesRepository.Get(fl.AirlineID); var callUpdateFlight = new ConnxysWCFRestService(); if (fl.DepartureDateTime == null) { continue; } if (fl.ArrivalDateTime != null) { callUpdateFlight.UpdateSimpleFlight( fl.FlightID.ToString(CultureInfo.InvariantCulture), airlineDesignator.AirlineDesignator, fl.FlightNumber.ToString(CultureInfo.InvariantCulture), fl.DepartureDateTime.Value.ToString(CultureInfo.InvariantCulture), fl.ArrivalDateTime.Value.ToString(CultureInfo.InvariantCulture)); } } _listF = new List <Flights>(); jsonData = new { status = "Ok", itineraryId = itinerary.ItineraryID }; //Send push notification about itinerary creation to the passenger connxysWcfRestService.SendPushNotification(notification); } else { //throw error the itinerary can not be created _listF = new List <Flights>(); PopulateList(); jsonData = new { status = "Failed", message = "Error: The itinerary was not added." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); } return(Json(jsonData, JsonRequestBehavior.AllowGet)); } catch (Exception e) { //throw error the itinerary can not be created _listF = new List <Flights>(); jsonData = new { status = "Failed", message = "Error: The itinerary was not added." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); } #endregion }
public DeleteModel(IAirportsRepository r) : base(r) { }
/// <summary> /// Initialize the repositories /// </summary> private void InitializeRepositories() { AirportRepository = DataIoCContainer.Resolver.Get <IAirportsRepository>(); }
public EditModel(IAirportsRepository r) : base(r) { }
public ActionResult FlightValidation(string AirlineName, string FlightNumber, string DepartureName, string ArrivalName, string DepartureTime, string ArrivalTime, string Stops, string TripTypeName, string PassengerName, string PassengerLastName, string PassengerEmail) { var flightService = new ConnxysWCFRestService(); var fsm = new FlightStatusMessages(); string jsonData; GoogleTimeZone timezone = new GoogleTimeZone(); fsm.isValid = false; fsm.messages = new Message(); _airlinesRepository = new AirlinesRepository(); _tagsRepository = new TagsRepository(); _airportsRepository = new AirportsRepository(); if (!AirlineName.Equals("") && !FlightNumber.Equals("") && !DepartureName.Equals("") && !ArrivalName.Equals("") && !DepartureTime.Equals("") && !ArrivalTime.Equals("") && !Stops.Equals("") && !TripTypeName.Equals("")) { #region Complete Info var model = new BasicItineraryModel { AirlineName = AirlineName, FlightNumber = Convert.ToInt32(FlightNumber), DepartureName = DepartureName, ArrivalName = ArrivalName, DepartureTime = Convert.ToDateTime(DepartureTime), ArrivalTime = Convert.ToDateTime(ArrivalTime), Stops = Convert.ToInt32(Stops), TripTypeName = TripTypeName, PassengerName = PassengerName, PassengerLastName = PassengerLastName, PassengerEmail = PassengerEmail }; //Get Airport Information: Departure and Arrival airports Airports DepartureAirport = new Airports(); DepartureAirport = _airportsRepository.GetAirportbyName(DepartureName); Airports ArrivalAirport = new Airports(); ArrivalAirport = _airportsRepository.GetAirportbyName(ArrivalName); //Get UTC of Departure Airport Double UTCDepartureAir = timezone.GetLocalDateTime(DepartureAirport.Latitude, DepartureAirport.Longitude, DateTime.UtcNow); //Get UTC of Arrival Airport Double UTCArrivalAir = timezone.GetLocalDateTime(ArrivalAirport.Latitude, ArrivalAirport.Longitude, DateTime.UtcNow); //Get the difference between UTC and local time to Departure and Arrival airport model.DepartDateTimeUTC = model.DepartureTime.Value.AddHours(UTCDepartureAir); model.ArrivalDateTimeUTC = model.ArrivalTime.Value.AddHours(UTCArrivalAir); var tempAirline = _airlinesRepository.GetAirlinebyName(model.AirlineName); var result = flightService.GetInfoFlightStatus(model.FlightNumber, tempAirline.AirlineDesignator, Convert.ToDateTime(model.DepartDateTimeUTC)); var listResult = result.flightStatuses.ToList(); var totalFlightStatus = listResult.Count; //Time validation validate the hour and minutes selected by the user if (model.DepartureTime.Value >= model.ArrivalTime.Value) { fsm.messages.mainMessage = "Arrival Time must be greater than Departure Time"; jsonData = new JavaScriptSerializer().Serialize(fsm); return(Json(jsonData, JsonRequestBehavior.AllowGet)); } var utcNow = DateTime.UtcNow; if (model.DepartureTime.Value < utcNow || model.ArrivalTime.Value < utcNow) { fsm.messages.mainMessage = "Departure Time and Arrival Time must be greater or equal than Current UTC time"; jsonData = new JavaScriptSerializer().Serialize(fsm); return(Json(jsonData, JsonRequestBehavior.AllowGet)); } if (totalFlightStatus > 0) { /* If is a real flight */ foreach (var item in listResult) { fsm.messages = new Message(); var matchesElements = true; var flightStatus = item; var serviceDepartureDate = flightStatus.departureDate.dateUtc.ToUniversalTime(); //DateTimeOffset.Parse(flightStatus.departureDate.dateUtc).UtcDateTime; var serviceArrivalDate = flightStatus.arrivalDate.dateUtc.ToUniversalTime(); //DateTimeOffset.Parse().UtcDateTime; #region Departure and Arrival Airports match with real flight if (model.DepartureName == flightStatus.departureAirportFsCode && model.ArrivalName == flightStatus.arrivalAirportFsCode) { if (serviceDepartureDate.CompareTo(model.DepartDateTimeUTC) != 0) { fsm.messages.depDateMessage = "The Departure Date doesn't match with real flight."; matchesElements = false; } if (serviceArrivalDate.CompareTo(model.ArrivalDateTimeUTC) != 0) { fsm.messages.arrDateMessage = "The Arrival Date doesn't match with real flight."; matchesElements = false; } if (matchesElements) { fsm.isValid = true; } break; } #endregion #region Departure Airport match with real flight if (model.DepartureName == flightStatus.departureAirportFsCode) { if (model.ArrivalName != flightStatus.arrivalAirportFsCode) { fsm.messages.arrivalMessage = "The Arrival doesn't match with real flight."; } if (serviceDepartureDate.CompareTo(model.DepartDateTimeUTC) != 0) { fsm.messages.departureMessage = "The Departure Date doesn't match with real flight."; } if (serviceArrivalDate.CompareTo(model.ArrivalDateTimeUTC) != 0) { fsm.messages.arrDateMessage = "The Arrival Date doesn't match with real flight."; } break; } #endregion #region Arrival Airport match with real flight if (model.ArrivalName == flightStatus.arrivalAirportFsCode) { if (model.DepartureName != flightStatus.departureAirportFsCode) { fsm.messages.departureMessage = "The Departure doesn't match with real flight."; } if (serviceDepartureDate.CompareTo(model.DepartDateTimeUTC) != 0) { fsm.messages.depDateMessage = "The Departure Date doesn't match with real flight."; } if (serviceArrivalDate.CompareTo(model.ArrivalDateTimeUTC) != 0) { fsm.messages.arrDateMessage = "The Arrival Date doesn't match with real flight."; } break; } #endregion #region Departure and Arrival Airports don't match with real flight if (model.DepartureName == flightStatus.departureAirportFsCode || model.ArrivalName == flightStatus.arrivalAirportFsCode) { continue; } fsm.messages.departureMessage = "The Departure doesn't match with real flight."; fsm.messages.arrivalMessage = "The Arrival doesn't match with real flight."; if (serviceDepartureDate.CompareTo(model.DepartDateTimeUTC) != 0) { fsm.messages.depDateMessage = "The Departure Date doesn't match with real flight."; } if (serviceArrivalDate.CompareTo(model.ArrivalDateTimeUTC) != 0) { fsm.messages.arrDateMessage = "The Arrival Date doesn't match with real flight."; } #endregion } } else { /* If is not a real flight */ fsm.isValid = true; } if (fsm.isValid) { // Insert the flight into flight's list InsertFlightIntoList(model); } else { fsm.messages.mainMessage = "Error: Flight number " + model.FlightNumber + " doesn't match the Flight Stats information. Please edit the information below."; } #endregion } else { fsm.messages.mainMessage = "Information required: Please complete all the flight information fields."; } jsonData = new JavaScriptSerializer().Serialize(fsm); return(Json(jsonData, JsonRequestBehavior.AllowGet)); }