public async Task <List <AvailableSeat> > GetAvailabilityAsync(SeatTypes seatType) { var response = await _client.GetAsync($"availability/seats-count-by-seattype?seatType={seatType}"); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadFromJsonAsync <List <AvailableSeat> >(); return(result); }
public async Task <List <Seat> > GetAvailabileSeatsAsync(SeatTypes seatType, DateTime availableOn) { return(await(from seat in _context.Set <Seat>().Where(s => (SeatTypes)s.SeatTypeId == seatType) join booking in _context.Set <Booking>().Where(b => b.VisitStartDate == availableOn && (BookingStatuses)b.BookingStatusId != BookingStatuses.Cancelled) on seat.Id equals booking.SeatId into lj from subseat in lj.DefaultIfEmpty() where subseat == null select new Seat { Id = seat.Id, Number = seat.Number, SeatType = seat.SeatType, SeatTypeId = seat.SeatTypeId }).ToListAsync()); }
public static string ToStringURL(this SeatTypes seatTypes) { switch (seatTypes) { case SeatTypes.StdRRSeat: return("standard-reading-room"); case SeatTypes.MandLRR: return("map-and-large-document-reading-room"); default: return(string.Empty); } }
private void RunOnce(Func <int, int, int> getNumberOfOccupiedSeats, int max) { var copy = new SeatTypes[m_Model.Length][]; for (var i = 0; i < copy.Length; i++) { copy[i] = new SeatTypes[m_Model[0].Length]; for (var j = 0; j < copy[i].Length; j++) { copy[i][j] = GetSeatType(i, j, max, getNumberOfOccupiedSeats); } } m_Model = copy; }
public async Task <IActionResult> Availability(BookingTypes bookingType, SeatTypes seatType, ErrorCode errorCode) { if (seatType == default(SeatTypes)) { seatType = bookingType == BookingTypes.StandardOrderVisit ? SeatTypes.StdRRSeat : SeatTypes.BulkOrderSeat; } var model = new AvailabilityViewModel { BookingType = bookingType, SeatType = seatType, AvailableBookings = await _availabilityService.GetAvailabilityAsync(seatType), ErrorMessage = errorCode.ToMessage() }; return(View(model)); }
public async Task <List <AvailabilityModel> > GetAvailabilityAsync(SeatTypes seatType) { if (StandardOrderSeats.Contains(seatType)) { var stdSeatCount = await _context.Seats.CountAsync(s => (SeatTypes)s.SeatTypeId == seatType); var standardAvailableDates = await _workingDayService.GetStandardOrderAvailableDatesAsync(); var standardBookings = await(from booking in _context.Set <Booking>().Where(b => standardAvailableDates.Contains(b.VisitStartDate) && (BookingStatuses)b.BookingStatusId != BookingStatuses.Cancelled) join seat in _context.Set <Seat>().Where(s => (SeatTypes)s.SeatTypeId == seatType) on booking.SeatId equals seat.Id group booking by booking.VisitStartDate into g select new AvailabilityModel { Date = g.Key, AvailableSeats = stdSeatCount - g.Count() }).ToListAsync(); return((from date in standardAvailableDates join booking in standardBookings on date equals booking.Date into lj from subbook in lj.DefaultIfEmpty() select new AvailabilityModel { Date = date, AvailableSeats = subbook?.AvailableSeats ?? stdSeatCount }).ToList()); } var bulkSeatCount = await _context.Seats.CountAsync(s => (SeatTypes)s.SeatTypeId == seatType); var bulkAvailableDates = await _workingDayService.GetBulkOrderAvailableDatesAsync(); var bulkbookings = await(from booking in _context.Set <Booking>().Where(b => bulkAvailableDates.Contains(b.VisitStartDate) && (BookingStatuses)b.BookingStatusId != BookingStatuses.Cancelled) join seat in _context.Set <Seat>().Where(s => (SeatTypes)s.SeatTypeId == seatType) on booking.SeatId equals seat.Id group booking by booking.VisitStartDate into g select new AvailabilityModel { Date = g.Key, AvailableSeats = bulkSeatCount - g.Count() }).ToListAsync(); return((from date in bulkAvailableDates join booking in bulkbookings on date equals booking.Date into lj from subbook in lj.DefaultIfEmpty() select new AvailabilityModel { Date = date, AvailableSeats = subbook?.AvailableSeats ?? bulkSeatCount }).ToList()); }
public decimal GetPrice(CustomerTypes customerType, SeatTypes seatType) { decimal price = 0; switch (seatType) { case SeatTypes.Stalls: price = StallPrice; break; case SeatTypes.Orchestra: price = OrchestraPrice; break; case SeatTypes.Back: price = BackPrice; break; } switch (customerType) { case CustomerTypes.Adult: price = price - price * (decimal)AdultDiscount / 100.0m; break; case CustomerTypes.Child: price = price - price * (decimal)ChildDiscount / 100.0m; break; case CustomerTypes.Senior: price = price - price * (decimal)SeniorDiscount / 100.0m; break; case CustomerTypes.Student: price = price - price * (decimal)StudentDiscount / 100.0m; break; } return(price); }
protected Flight() { //Flight Barcode var random = new Random(); FlightBarcode = random.Next(12345678, 99999999); //Seat state PlaceStates = new SeatStates[SeatAmount]; for (int i = 0; i < PlaceStates.Length; i++) { PlaceStates[i] = SeatStates.Available; } //Seat type PlaceTypes = new SeatTypes[SeatAmount]; for (int i = 0; i < PlaceTypes.Length; i++) { PlaceTypes[i] = SeatTypes.Economy; } }
public async Task <ActionResult <List <Seat> > > GetAvailabileSeats(SeatTypes seatType, DateTime availableOn) { var result = await _availabilityService.GetAvailabileSeatsAsync(seatType, availableOn); return(Ok(result)); }
public async Task <ActionResult <List <AvailabilityModel> > > GetAvailability(SeatTypes seatType) { var result = await _availabilityService.GetAvailabilityAsync(seatType); return(Ok(result)); }