Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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);
            }
        }
Esempio n. 4
0
        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));
        }
Esempio n. 6
0
        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());
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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;
            }
        }
Esempio n. 9
0
        public async Task <ActionResult <List <Seat> > > GetAvailabileSeats(SeatTypes seatType, DateTime availableOn)
        {
            var result = await _availabilityService.GetAvailabileSeatsAsync(seatType, availableOn);

            return(Ok(result));
        }
Esempio n. 10
0
        public async Task <ActionResult <List <AvailabilityModel> > > GetAvailability(SeatTypes seatType)
        {
            var result = await _availabilityService.GetAvailabilityAsync(seatType);

            return(Ok(result));
        }