/// <summary> /// Set new flight. /// </summary> /// <param name="flightName"></param> /// <param name="timeoutInMinutes"></param> public void SetFlight(string flightName, int timeoutInMinutes) { CodeContract.RequiresArgumentNotNullAndNotWhiteSpace(flightName, "flightName"); if (timeoutInMinutes < 0) { throw new ArgumentException("Flight expiration timeout can't be negative", "timeoutInMinutes"); } flightName = flightName.ToLowerInvariant(); DateTimeOffset expiration = DateTimeOffset.UtcNow.AddMinutes(timeoutInMinutes); lock (lockObject) { IEnumerable <string> rawFlights = GetRawFlights(); foreach (string item in rawFlights) { FlightInformation flightInformation = FlightInformation.Parse(item); if (flightInformation != null && flightInformation.Flight == flightName) { return; } } SetRawFlights(rawFlights.Union(new string[1] { new FlightInformation(flightName, expiration).ToString() })); } }
public JsonResult AddFlight(FlightInformation flightInformation) { var status = false; if (flightInformation.TripId > 0) { var v = _context.FlightInformation.Where(a => a.TripId == flightInformation.TripId).FirstOrDefault(); if (v != null) { v.Id = v.Id; v.TripId = flightInformation.TripId; v.Cost = flightInformation.Cost; v.Start = flightInformation.Start; v.End = flightInformation.End; v.FlightTicketStatus = flightInformation.FlightTicketStatus; _context.Update(v); } else { _context.Add(flightInformation); } } _context.SaveChanges(); status = true; return(new JsonResult(status)); }
public void Start() { List <string> list = new List <string>(); bool flag = false; lock (lockObject) { foreach (string rawFlight in GetRawFlights()) { FlightInformation flightInformation = FlightInformation.Parse(rawFlight); if (flightInformation != null && flightInformation.ExpirationTime > DateTimeOffset.UtcNow) { list.Add(rawFlight); } else { flag = true; } } if (flag) { SetRawFlights(list); } } }
public object GetRecordFlightInformation(string DailyFlightSno) { try { object FlightInformation = null; try { if (!string.IsNullOrEmpty(DailyFlightSno)) { FlightInformation FlightInformationList = new FlightInformation(); object obj = (object)FlightInformationList; FlightInformation = DataGetRecordService(DailyFlightSno, obj, this.MyModuleID); this.MyRecordID = (System.Web.HttpContext.Current.Request.QueryString["RecID"]); } else { //Error Messgae: Record not found. } } catch (Exception ex)// (Exception ex) { } return(FlightInformation); } catch (Exception ex)// { throw ex; } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); LuisMessage luisMessage = await LuisClient.ParseMessage(activity.Text); string replyMessage = string.Empty; if (luisMessage.intents.Count() > 0) { switch (luisMessage.intents[0].intent) { case "GetFlightInfo": FlightInformation flightInfo = await FlightAwareClient.GetFlightData( ConfigurationManager.AppSettings["FlightAwareUserName"], ConfigurationManager.AppSettings["FlightAwareApiKey"], luisMessage.entities[0].entity); replyMessage = FlightAwareClient.GetFlightStatus(flightInfo); break; case "GetDepartureStatus": replyMessage = luisMessage.intents[0].intent; break; case "GetArrivalStatus": replyMessage = luisMessage.intents[0].intent; break; case "RepeatPrevious": replyMessage = luisMessage.intents[0].intent; break; default: replyMessage = "I didn't catch that."; break; } } else { replyMessage = "I didn't catch that."; } // return our reply to the user Activity reply = activity.CreateReply(replyMessage); await connector.Conversations.ReplyToActivityAsync(reply); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
/// <summary> /// Raw flight data are in the format: "flight_name#yyyy-MM-dd HH:mm:ssZ". /// First part (before '#') is the flight name and second part (after '#') is the expiration date of the flight. /// Return clean set of the flight (without expired flights). /// </summary> /// <param name="rawFlights"></param> /// <returns></returns> private IEnumerable <string> ConvertRawDataToPlainFlights(IEnumerable <string> rawFlights) { foreach (string rawFlight in rawFlights) { FlightInformation flightInformation = FlightInformation.Parse(rawFlight); if (flightInformation != null && flightInformation.ExpirationTime > DateTimeOffset.UtcNow) { yield return(flightInformation.Flight); } } }
public async Task <IActionResult> Create(FlightInformation flightInformation) { var tempFlightInformation = _context.FlightInformation.SingleOrDefault(f => f.TripId == flightInformation.TripId); tempFlightInformation.Start = flightInformation.Start; tempFlightInformation.Details = flightInformation.Details; tempFlightInformation.End = flightInformation.End; tempFlightInformation.Cost = flightInformation.Cost; tempFlightInformation.FlightTicketStatus = flightInformation.FlightTicketStatus; _context.Update(tempFlightInformation); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Trip", new { id = tempFlightInformation.TripId })); }
public void Constructor_MakingObjectNoFlightSections_ShouldPassTest() { // Arrange FlightInformation expected = new FlightInformation(info); // Act Flight actual = new Flight(info.AirlineName, info.OriginatingAirport, info.DestinationAirport, info.FlightNumber, info.DepartureDate); // Assert Assert.Equal(expected.AirlineName, actual.Information.AirlineName); Assert.Equal(expected.OriginatingAirport, actual.Information.OriginatingAirport); Assert.Equal(expected.DestinationAirport, actual.Information.DestinationAirport); Assert.Equal(expected.DepartureDate, actual.Information.DepartureDate); Assert.Equal(expected.Id, actual.Information.Id); Assert.NotNull(actual.FlightSections); }
public async Task <IActionResult> Book(int flightId, string travelClassCode, int adults, int children, int infants) { if (!await _flightInfoService.FlightExistsAsync(flightId)) { return(NotFound()); } FlightInformation flightInformation = await _flightInfoService.GetFlightByIdAsync(flightId, adults, children, infants); TravelClassDto travelClass = await _flightInfoService.GetTravelClassByCodeAsync(travelClassCode); List <NationalityDto> nationalities = await _passengerInfoService.GetNationalitiesAsync(); BookFlightViewModel viewModel = new BookFlightViewModel { FlightInformation = flightInformation, Passengers = new List <PassengerDto>(), TravelClass = travelClass, Nationalities = nationalities }; for (int i = 0; i < adults; i++) { viewModel.Passengers.Add(new PassengerDto { AgeBracket = AgeBracket.Adult, DateOfBirth = DateTime.Today }); } for (int i = 0; i < children; i++) { viewModel.Passengers.Add(new PassengerDto { AgeBracket = AgeBracket.Child, DateOfBirth = DateTime.Today }); } for (int i = 0; i < infants; i++) { viewModel.Passengers.Add(new PassengerDto { AgeBracket = AgeBracket.Infant, DateOfBirth = DateTime.Today }); } return(View(viewModel)); }
public static void SeedFlightInfo(FlightTrackContext context, Aircraft[] craft) { var info = new FlightInformation[] { new FlightInformation { Id = Guid.NewGuid(), Aircraft = craft[0], Approaches = 0, ApproachesHold = false, CFI = 0, Comments = "This is a sample comment", CrossCountry = 0, DateOfFlight = DateTime.Today, Dual = 1, FullStopDay = 0, FullStopNight = 0, GroundSim = 0, IMC = 0, Night = 1.5, PIC = 0, Route = "ATL to MSY", SIC = 0, SimulatedInstrument = 0, Solo = 0, TotalLandings = 12, TotalTime = 2.5 } }; foreach (FlightInformation f in info) { context.FlightInformations.Add(f); } context.SaveChanges(); }
public IActionResult Create(string officeTitle1, string officeTitle2, Trip trip, TicketStatusEnum ticketStatus, CarRentalEnum carRental, AccomodationStatusEnum accomodationStatus) { using (var transaction = _context.Database.BeginTransaction()) { try { var office1 = _context.Office.SingleOrDefault(x => x.Name == officeTitle1); var office2 = _context.Office.SingleOrDefault(x => x.Name == officeTitle2); trip.ToOffice = office2.Id; trip.FromOffice = office1.Id; trip.TripStatus = 0; user = _us.GetUserFromRequest(Request); trip.Organizator = user.Id; _context.Add(trip); //await _context.SaveChangesAsync(); Console.WriteLine(trip.Id); trip.Participators = new List <TripParticipator>(); int i1 = 0; if (list == null || list.Count() == 0) { return(RedirectToAction(nameof(Create), new { error = "Kelionėje turi dalyvauti bent vienas dalyvis" })); } list = list.Distinct().ToList(); foreach (int i in list) { TripParticipator participator = new TripParticipator(); participator.TripId = trip.Id; participator.UserId = i; participator.Approve = false; if (i1 != i) { trip.Participators.Add(participator); } i1 = i; } if (!_ts.IsTripParticipatorsBusy(trip)) { _context.Add(trip); _context.SaveChanges(); foreach (TripParticipator tripParticipator in trip.Participators) { var accomodationInfo = new AccomodationInfo() { TripId = trip.Id, UserId = tripParticipator.UserId, Start = DateTime.MinValue, End = DateTime.MinValue, AccomodationStatus = accomodationStatus }; _context.Add(accomodationInfo); } var flightInfo = new FlightInformation() { TripId = trip.Id, Cost = 0, Start = DateTime.MinValue, End = DateTime.MinValue, FlightTicketStatus = ticketStatus }; _context.Add(flightInfo); var rentalCarinfo = new RentalCarInformation() { TripId = trip.Id, Cost = 0, Start = DateTime.MinValue, End = DateTime.MinValue, CarRental = carRental }; _context.Add(rentalCarinfo); _context.SaveChanges(); transaction.Commit(); return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction(nameof(Create), new { error = "Pasirinkti dalyiai šiuo laiku užimti" })); } } catch (Exception) { return(NotFound()); } } }
/// <summary> /// Creates a success response. /// </summary> /// <param name="category">Saved category.</param> /// <returns>Response.</returns> public FlightResponse(FlightInformation flightInformation) : this(true, string.Empty, flightInformation) { }
public FlightResponse(bool success, string message, FlightInformation flightInformation) : base(success, message) { FlightInformation = flightInformation; }