public void AddToCart(SeatingModel selectedSeat)
        {
            SeatingModel seatingModel = Seats.FirstOrDefault(x => x.Seat.Id == selectedSeat.Seat.Id);

            seatingModel.IsSelected = !seatingModel.IsSelected;

            SelectedSeats.Clear();

            IEnumerable <SeatingModel> selectedSeats = Seats.Where(x => x.IsSelected);

            string seatPriceWithVat = _pricingService.GetTotalWithVatAmount(Screening.Pricing.Price);

            foreach (var seat in selectedSeats)
            {
                SelectedSeatViewModel selectedSeatViewModel = new SelectedSeatViewModel
                {
                    SeatingModel = seat,
                    Description  = $"{Screening.Pricing.Name} Seat {seat.Seat.Label} - {seatPriceWithVat} {Currency}"
                };

                SelectedSeats.Add(selectedSeatViewModel);
            }

            CalculateTotals();
        }
예제 #2
0
        public async Task <List <SeatingModel> > GetSeatingAsync(int id)
        {
            Screening screening = await _screeningRepo.GetAsync(id);

            IEnumerable <Reservation> screeningReservations = await _reservationRepo.GetByScreeningIdAsync(id);

            //gets reserved seats first
            List <SeatingModel> screeningSeats = screeningReservations.SelectMany(x => x.SeatReservations)
                                                 .Select(x => new SeatingModel
            {
                IsReserved = true,
                Seat       = _mapper.Map <SeatDto>(x.Seat)
            }).ToList();

            //gets all seats
            IEnumerable <Seat> hallSeats = await _seatRepo.GetAsync(x => x.HallId == screening.HallId);

            IEnumerable <Seat> freeSeats = hallSeats.Where(x => !screeningSeats.Select(y => y.Seat.Id).Contains(x.Id)).ToList();

            foreach (Seat seat in freeSeats)
            {
                SeatingModel seatingModel = new SeatingModel
                {
                    IsReserved = false,
                    Seat       = _mapper.Map <SeatDto>(seat)
                };

                screeningSeats.Add(seatingModel);
            }

            return(screeningSeats.OrderBy(x => x.Seat.SeatNumber).ToList());
        }
        public void RemoveFromCart(int seatId)
        {
            SelectedSeatViewModel selectedSeatViewModel = SelectedSeats.FirstOrDefault(x => x.SeatingModel.Seat.Id == seatId);
            SeatingModel          seatingModel          = selectedSeatViewModel.SeatingModel;

            seatingModel.IsSelected = false;

            SelectedSeats.Remove(selectedSeatViewModel);
            CalculateTotals();
        }
        private void AddToCart(Button button, SeatingModel seat)
        {
            model.AddToCart(seat);

            AdjustSelectedSeats(button, seat);

            if (!this.NewReservationButton.IsEnabled)
            {
                SetReserveButton();
            }
        }
        private void AdjustSelectedSeats(Button button, SeatingModel seat)
        {
            bool seatStatus = model.GetSeatStatus(seat.Seat.Id);

            button.TextColor       = GetButtonTextColor(seatStatus);
            button.BackgroundColor = GetButtonBackgroundColor(seatStatus);

            int selectedSeatsCount = model.SelectedSeats.Count;

            this.SelectedSeatsListView.HeightRequest = selectedSeatsCount * _selectedSeatsRowHeight;
        }
 public static int GetSeatColumn(this SeatingModel seat, Hall hall)
 {
     if (seat.Seat.SeatNumber % hall.NumberOfColumns == 0)
     {
         return(hall.NumberOfColumns);
     }
     else
     {
         return(seat.Seat.SeatNumber % hall.NumberOfColumns);
     }
 }
        private Button CreateButton(SeatingModel seat)
        {
            Button button = new Button
            {
                BindingContext  = seat,
                Text            = seat.Seat.Label,
                IsEnabled       = !seat.IsReserved,
                BackgroundColor = seat.IsReserved ? Color.Gray : Color.White,
                TextColor       = seat.IsReserved ? Color.White : Color.Gray,
                CornerRadius    = 2,
                BorderColor     = Color.Gray,
                WidthRequest    = 45
            };

            if (!seat.IsReserved)
            {
                button.Command = new Command(() => AddToCart(button, seat));
            }

            return(button);
        }
        public bool GetSeatStatus(int selectedSeatId)
        {
            SeatingModel seatingModel = Seats.FirstOrDefault(x => x.Seat.Id == selectedSeatId);

            return(seatingModel.IsSelected);
        }
 public static int GetSeatRow(this SeatingModel seat, Hall hall)
 {
     return((seat.Seat.SeatNumber - 1) / hall.NumberOfColumns);
 }