public async Task <IActionResult> Edit(int id, [Bind("BusBookingID,NumOfGuest,DateToBook,SpecialRequirement,UserID,BusID")] BusBooking busBooking)
        {
            if (id != busBooking.BusBookingID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(busBooking);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BusBookingExists(busBooking.BusBookingID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusID"] = new SelectList(_context.Bus, "BusID", "BusID", busBooking.BusID);
            return(View(busBooking));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Booking Application");
            Console.WriteLine("Enter 1 to Book Flights");
            Console.WriteLine("Enter 2 to Book Buses");
            Console.WriteLine("Enter 3 to Book Cruise");
            string         userInput = Console.ReadLine();
            VehicleBooking booking   = null;

            if (booking != null)
            {
                Console.WriteLine(booking.Destination);
            }

            if (userInput == "1")
            {
                booking = new FlightBooking("HYD", "BNG");
            }
            else if (userInput == "2")
            {
                booking = new BusBooking("HYD", "BNG");
            }
            else
            {
                booking = new CruiseBooking.CruiseBooking("MUM", "CHE");
            }
            Console.WriteLine("Enter Number of Seats");
            string input = Console.ReadLine();

            try
            {
                int numberOfSeats = int.Parse(input);
                booking.Book(numberOfSeats);
                booking.PricePerPerson(numberOfSeats);
                //throw new DivideByZeroException();

                Console.WriteLine("Your Booking Amount is $" + booking.GetBookingAmount(numberOfSeats));
            }

            catch (DivideByZeroException ex)
            {
                Console.WriteLine("Invalid Input");
            }
            catch (FormatException ex)
            {
                Console.WriteLine("Invalid format");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
            finally
            {
                Console.WriteLine("Thanks");
            }
        }
Ejemplo n.º 3
0
        //This method work to initalize each individual object which will be stored in the list
        public BusBooking getBusBookingFromReader(SqlDataReader reader)
        {
            BusBooking newBus = new BusBooking();

            newBus.BusBookingId = reader.GetInt32(0);
            newBus.BusId        = reader.GetInt32(1);
            newBus.StaffId      = reader.GetInt32(2);
            return(newBus);
        }
        public async Task <IActionResult> Create([Bind("BusBookingID,NumOfGuest,DateToBook,SpecialRequirement,UserID,BusID")] BusBooking busBooking)
        {
            if (ModelState.IsValid)
            {
                busBooking.BookingConfirmed = false;
                _context.Add(busBooking);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Booked), new { id = busBooking.BusBookingID }));
            }
            ViewData["BusID"] = new SelectList(_context.Bus, "BusID", "BusID", busBooking.BusID);
            return(View(busBooking));
        }