Ejemplo n.º 1
0
        public void ConfigureSeats(int BusId)
        {
            TicketBookingModelEntities db = new TicketBookingModelEntities();

            var bus = db.Buses.Find(BusId);

            this.SeatsAvailable = bus.NrSeats;
        }
Ejemplo n.º 2
0
        public bool NewReservation(int id, string un)
        {
            TicketBookingModelEntities db = new TicketBookingModelEntities();
            Tour tour = db.Tours.Find(id);

            if (tour != null)
            {
                if (tour.SeatsAvailable > 0)
                {
                    Reservation res = new Reservation
                    {
                        ReservationDate = DateTime.Now,
                        TourId          = tour.TourId,
                        UserName        = un
                    };
                    tour.SeatsAvailable--;
                    db.Reservations.Add(res);
                    db.SaveChangesAsync();
                    return(true);
                }
            }
            return(false);
        }