public async Task ReturnEmptyJSonWhenEmptyRouteAsync() { string receivedJsonResult; var TestFlightTicket = new FlightTicket() { TakeOffDate = TEST_DATE, Destination = TEST_DESTINATION }; using (var TestDBContext = new FoxAirlinesContext(TestDBOptions)) { TestDBContext.AddNewFlightTicket(TEST_DATE, TEST_DESTINATION); receivedJsonResult = JsonConvert.SerializeObject(await TestDBContext .FlightTickets .FirstOrDefaultAsync(ticket => ticket.TakeOffDate.Equals(TEST_DATE) && ticket.Destination.Equals(TEST_DESTINATION))); //var response = await Client.GetAsync("/api"); //var responseString = await response.Content.ReadAsStringAsync(); } Assert.Equal(TestFlightTicket, JsonConvert.DeserializeObject <FlightTicket>(receivedJsonResult)); }
public async Task <IActionResult> Edit(int id, [Bind("FlightTicketID,FlightNumber,FlightDestination")] FlightTicket flightTicket) { if (id != flightTicket.FlightTicketID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(flightTicket); _logger.LogInformation("Edited flight"); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FlightTicketExists(flightTicket.FlightTicketID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(flightTicket)); }
public ActionResult addFlight(FlightTicket flightTicket) { string fileFlightTicketName = Path.GetFileNameWithoutExtension(flightTicket.imageFile.FileName); string extension = Path.GetExtension(flightTicket.imageFile.FileName); fileFlightTicketName = fileFlightTicketName + DateTime.Now.ToString("yymmssfff") + extension; flightTicket.flightTicketPicture = "../../images/flightImage/" + fileFlightTicketName; fileFlightTicketName = Path.Combine(Server.MapPath("~/images/flightImage/"), fileFlightTicketName); flightTicket.imageFile.SaveAs(fileFlightTicketName); flightTicket.flightActive = true; if (int.TryParse(Session["userId"].ToString(), out int result)) { flightTicket.customerID = result; } db.FlightTickets.Add(flightTicket); db.SaveChanges(); Response.Output.Write("<script>alert('youre flight add succssfully')</script>"); return(View("Index")); }
public FlightRecordBatchStreamingCall GetStream(FlightTicket ticket, Metadata headers = null) { var stream = _client.DoGet(ticket.ToProtocol(), headers); var responseStream = new FlightClientRecordBatchStreamReader(stream.ResponseStream); return(new FlightRecordBatchStreamingCall(responseStream, stream.ResponseHeadersAsync, stream.GetStatus, stream.GetTrailers, stream.Dispose)); }
public bool AddFlightOrder(FlightOrder flightOrder) { int rowsEffected = -1; using (var context = new DataContext(DataContext.ops.dbOptions)) { User user = context.User.Where(theUser => theUser.UserId == flightOrder.User.UserId).SingleOrDefault(); Flight flight = context.Flight.Where(theFlight => theFlight.FlightId == flightOrder.Flight.FlightId).SingleOrDefault(); FlightLuggage flightLuggage = context.FlightLuggage.Where(theFlightLuggage => theFlightLuggage.FlightLuggageId == flightOrder.FlightLuggage.FlightLuggageId).SingleOrDefault(); Seat seat = context.Seat.Where(theSeat => theSeat.SeatId == flightOrder.Seat.SeatId).SingleOrDefault(); FlightTicket flightTicket = context.FlightTicket.Where(theFlightTicket => theFlightTicket.FlightTicketId == flightOrder.FlightTicket.FlightTicketId).SingleOrDefault(); flightOrder.User = user; flightOrder.Flight = flight; flightOrder.FlightLuggage = flightLuggage; flightOrder.Seat = seat; flightOrder.FlightTicket = flightTicket; context.FlightOrder.Add(flightOrder); rowsEffected = context.SaveChanges(); if (rowsEffected > 0) { return(true); } } return(false); }
private FlightEndpoint GetEndpoint(FlightTicket ticket, string host) { var location = new FlightLocation(host); return(new FlightEndpoint(ticket, new List <FlightLocation> { location })); }
private Task SendInvitationAsync(FlightTicket ticket) { var email = ticket.TicketOwnerEmail; string href = $"{_settings.Client_URL}/flight-ticket/{ticket.Id}/accept"; string body = $"<p>For: {email}</p><a href=\"{href}\">Accept invitation</a>"; return(_emailService.SendMailAsync(email, "Flight Ticket Invitation request", body)); }
public async Task UpdateAsync(FlightTicket flightTicket) { var ticket = await GetByIdAsync(flightTicket.Id); ticket.TicketOwnerEmail = flightTicket.TicketOwnerEmail; ticket.Discount = flightTicket.Discount; ticket.Rating = flightTicket.Rating; await _context.SaveChangesAsync(); }
public void orderDetail(FlightTicket result) { Order order = new Order(); order.customerID = result.customerID; order.flightID = result.flightID; order.orderPrice = result.flightPrice; order.orderDate = DateTime.Now.ToString(); db.Orders.Add(order); db.SaveChanges(); }
//Map Entity --> Business public static Logic.FlightTicket MapEToFlightTicket(FlightTicket EFlightTicket) { return(new Logic.FlightTicket { TicketID = EFlightTicket.FlightTicketID, FlightID = EFlightTicket.FlightID, CustomerID = EFlightTicket.CustomerID, Price = EFlightTicket.Price, Checkin = EFlightTicket.Checkin, Luggage = EFlightTicket.Luggage }); }
public async Task <IActionResult> Create([Bind("FlightTicketID,FlightNumber,FlightDestination")] FlightTicket flightTicket) { if (ModelState.IsValid) { _context.Add(flightTicket); _logger.LogInformation("Added flight"); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(flightTicket)); }
public async Task <long> AddAsync(FlightTicket flightTicket) { if (string.IsNullOrWhiteSpace(flightTicket.TicketOwnerEmail)) { flightTicket.TicketOwnerEmail = null; } var entry = await _context.FlightTicket.AddAsync(flightTicket); await _context.SaveChangesAsync(); return(entry.Entity.Id); }
private void gridtable_SelectionChanged(object sender, SelectionChangedEventArgs e) { FlightTicket fticket = gridtable.SelectedItem as FlightTicket; if (fticket != null) { var aero = new AirportSHIAEntities(); orderconnetctor.id = aero.FlightTicket.Include(x => x.Ticket).Include(u => u.Flight).Where(x => x.Ticket.ClassTicket == fticket.Ticket.ClassTicket && x.Flight.LandingPoint == fticket.Flight.LandingPoint && x.Flight.PointOfDeparture == fticket.Flight.PointOfDeparture && x.Flight.DateFlight == fticket.Flight.DateFlight).Select(x => x.idFlightTicket).FirstOrDefault(); } else { return; } }
public FlightTicketDetailsModel(FlightTicket ticket) { Id = ticket.Id; TicketOwnerEmail = ticket.TicketOwnerEmail; Flight = new FlightModel(ticket.Flight); FlightSeat = new FlightSeatModel(ticket.FlightSeat); Discount = ticket.Discount; DateCreated = ticket.DateCreated; Accepted = ticket.Accepted; Rating = ticket.Rating; CanCancel = ticket.Flight.CanCancelReservation(); CanRate = ticket.Flight.CanRate(); TotalPrice = ticket.Flight.GetTotalPrice(ticket.Discount); }
public async Task CreateTicketTest() { DbContextOptions <SWTDbContext> options = new DbContextOptionsBuilder <SWTDbContext>() .UseInMemoryDatabase("CreateTicket") .Options; using SWTDbContext testContext = new SWTDbContext(options); Repo repo = new Repo(testContext); string create = await repo.CreateFlightTicket(ticket); FlightTicket check = testContext.FlightTicket.Select(f => f).First(); Assert.NotNull(check); }
public override async Task DoGet(FlightTicket ticket, FlightServerRecordBatchStreamWriter responseStream, ServerCallContext context) { var flightDescriptor = FlightDescriptor.CreatePathDescriptor(ticket.Ticket.ToStringUtf8()); if (_flightStore.Flights.TryGetValue(flightDescriptor, out var flightHolder)) { var batches = flightHolder.GetRecordBatches(); foreach (var batch in batches) { await responseStream.WriteAsync(batch.RecordBatch, batch.Metadata); } } }
public override async Task DoGet( FlightTicket ticket, FlightServerRecordBatchStreamWriter responseStream, ServerCallContext context ) { if (!_flightData.Tables.ContainsKey(ticket)) { throw new RpcException(new Status(StatusCode.NotFound, "Flight not found.")); } var table = _flightData.Tables[ticket]; foreach (var batch in table) { await responseStream.WriteAsync(batch); } }
public FlightTicketModel(FlightTicket ticket) : this() { if (ticket == null) { return; } Id = ticket.Id; TicketOwnerEmail = ticket.TicketOwnerEmail; FlightId = ticket.FlightId; FlightSeatId = ticket.FlightSeatId; Discount = ticket.Discount; Accepted = ticket.Accepted; Rating = ticket.Rating; CanCancel = ticket.Flight?.CanCancelReservation() ?? true; CanRate = ticket.Flight?.CanRate() ?? true; }
public FlightTicket AddTicket(FlightTicket flightTicket) { int rowsEffected = -1; using (var context = new DataContext(DataContext.ops.dbOptions)) { FlightTicket ticket = context.FlightTicket.Add(flightTicket).Entity; rowsEffected = context.SaveChanges(); if (rowsEffected > 0) { return(ticket); } } return(null); }
public void FlightTicketTest() { FlightTicket ticket = new FlightTicket { FlightTicketID = 1, CustomerID = 1, FlightID = 1, Price = 299.99, Checkin = false, Luggage = 1 }; Assert.Equal(1, ticket.FlightTicketID); Assert.Equal(1, ticket.CustomerID); Assert.Equal(1, ticket.FlightID); Assert.Equal(299.99, ticket.Price); Assert.False(ticket.Checkin); Assert.Equal(1, ticket.Luggage); }
public async Task ArrowFlight() { var flightTicket = new FlightTicket(Sql); var stream = flightClient.GetStream(flightTicket); await foreach (var recordBatch in stream.ResponseStream) { for (int i = 0; i < recordBatch.ColumnCount; i++) { var array = recordBatch.Arrays.ElementAt(i); switch (recordBatch.Schema.GetFieldByIndex(i).DataType.TypeId) { case ArrowTypeId.Int64: Int64Array int64Array = (Int64Array)array; Sum(int64Array); break; case ArrowTypeId.String: StringArray stringArray = (StringArray)array; for (int z = 0; z < stringArray.Length; z++) { stringArray.GetString(z); } break; case ArrowTypeId.Timestamp: TimestampArray timestampArray = (TimestampArray)array; for (int z = 0; z < timestampArray.Length; z++) { timestampArray.GetTimestamp(z); } break; } } //nop } }
public ActionResult finalPurchase() { foreach (var item in (List <Item>)Session["cart"]) { for (int i = 0; i < item.Quantity; i++) { FlightTicket result = db.FlightTickets.SingleOrDefault(p => p.flightID == item.Flights.flightID); if (result != null) { bool flightActive = false; result.flightActive = flightActive; db.SaveChanges(); } orderDetail(result); } } Response.Output.Write("<script>alert('thank you for buying with Pedro-Flight')</script>"); Session["cart"] = new List <Item>(); return(View("Index")); }
public ActionResult addFlight() { FlightTicket flightTicket = new FlightTicket(); return(View(flightTicket)); }
public override async Task DoGet(FlightTicket ticket, FlightServerRecordBatchStreamWriter responseStream, ServerCallContext context) { try { int maxBatchSize = DefaultMaxBatchSize; var maxBatchSizeMetadata = context.RequestHeaders.Get("max-batch-size"); if (maxBatchSizeMetadata != null && int.TryParse(maxBatchSizeMetadata.Value, out var parsedMaxBatchSize)) { maxBatchSize = parsedMaxBatchSize; } var queryResult = await _koraliumTransportService.Execute(ticket.Ticket.ToStringUtf8(), new Shared.SqlParameters(), context.GetHttpContext()); //Get the resulting schema var schema = GetSchema(queryResult.Columns); var encoders = queryResult.Columns.Select(x => EncoderHelper.GetEncoder(x)).ToArray(); foreach (var encoder in encoders) { encoder.NewBatch(); } List <object> list = new List <object>(20000); int count = 0; System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); foreach (var obj in queryResult.Result) { count++; for (int i = 0; i < encoders.Length; i++) { encoders[i].Encode(obj); } if (encoders.Select(x => x.Size()).Sum() > maxBatchSize) { await responseStream.WriteAsync(new RecordBatch(schema, encoders.Select(x => x.BuildArray()), count)); foreach (var encoder in encoders) { encoder.NewBatch(); } count = 0; } } stopwatch.Stop(); var batch = new RecordBatch(schema, encoders.Select(x => x.BuildArray()), count); await responseStream.WriteAsync(batch); } catch (SqlErrorException error) { throw new RpcException(new Status(StatusCode.InvalidArgument, error.Message)); } catch (AuthorizationFailedException authFailed) { throw new RpcException(new Status(StatusCode.Unauthenticated, authFailed.Message)); } catch (Exception e) { throw new RpcException(new Status(StatusCode.Internal, "Internal error")); } }
internal void DeleteFlightTicket(FlightTicket flightTicket) { FlightTickets.Remove(flightTicket); SaveChanges(); }
public void UpdateFlightTicket(FlightTicket flightTicket) { FlightTickets.Update(flightTicket); SaveChanges(); }
public ActionResult flightDetails(int id) { FlightTicket flightTicket = db.FlightTickets.FirstOrDefault(x => x.flightID == id); return(View(flightTicket)); }
public Item(FlightTicket flights, int quantity) { this.flights = flights; this.quantity = quantity; }
public virtual Task DoGet(FlightTicket ticket, FlightServerRecordBatchStreamWriter responseStream, ServerCallContext context) { throw new NotImplementedException(); }
public void AddNewFlightTicket(FlightTicket flightTicket) { foxAirlinesRepository.AddNewFlightTicket(flightTicket.TakeOffDate, flightTicket.Destination); }