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();
        }
Exemplo n.º 2
0
        public void AssingPassengerToSeat(Passenger passenger, string column, int row)
        {
            var seat = Seats.FirstOrDefault(p => p.Col == column && p.Row == row);

            if (seat == null)
            {
                throw new ArgumentException("seat not found");
            }
            seat.Passenger = passenger;
            passenger.Seat = seat;
        }
Exemplo n.º 3
0
        public void ClickButton(SeatModel selected)
        {
            var seat = Seats.FirstOrDefault(x => x.Id == selected.Id);

            if (seat.Number != -1)
            {
                Seats.First(x => x.Id == selected.Id).Number = -1;
            }
            else
            {
                Seats.First(x => x.Id == selected.Id).Number = 1;
            }
        }
Exemplo n.º 4
0
        public Result TryBuy(string userId, string seatId)
        {
            if (Seats.Where(x => x.Id != seatId).Any(s => s.IsBoughtBy(userId)))
            {
                return(Result.Fail("You already have your seat!"));
            }

            var seat = Seats.FirstOrDefault(s => s.Id == seatId);

            if (seat == null)
            {
                return(Result.Fail("Seat not found"));
            }

            if (!seat.CanBuy(userId))
            {
                return(Result.Fail("Seat is busy"));
            }

            FreeSeats(userId);
            seat.Buy(userId);
            return(Result.Success());
        }
Exemplo n.º 5
0
 /// <summary>
 ///依据玩家Id返回座位
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ISeat GetSeatByPlayerId(int id)
 {
     return(Seats.FirstOrDefault(s => s.IPlayer != null && s.IPlayer.Id == id));
 }
        public bool GetSeatStatus(int selectedSeatId)
        {
            SeatingModel seatingModel = Seats.FirstOrDefault(x => x.Seat.Id == selectedSeatId);

            return(seatingModel.IsSelected);
        }
Exemplo n.º 7
0
 private Passenger FindPassenger(string userId) => Seats.FirstOrDefault(p => p.Passenger?.Id == userId)?.Passenger;
Exemplo n.º 8
0
 public Seat FindSeatOfPassenger(string userID) => Seats.FirstOrDefault(p => p.Passenger.Id == userID);
Exemplo n.º 9
0
 public Seat FindSeatOfPassenger(Passenger user) => Seats.FirstOrDefault(p => p.Passenger.Id == user.Id);