コード例 #1
0
        public override IActionResult Detail(Booking Booking)
        {
            Logger.LogWarning(Booking.VoyageId.ToString());
            var voyage = voyageRepository.Single(Booking.VoyageId ?? default(int));

            voyage.RemainingSeat--;
            voyageRepository.Update(voyage);
            voyageRepository.Save();
            Repository.Update(Booking);
            Repository.Save();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public void AddBookings()
        {
            if (_bookingRepository.GetAll().Any())
            {
                return;
            }

            var v1 = _voyageRepository.Single(v => v.EndPlace == "School");
            var v2 = _voyageRepository.Single(v => v.EndPlace == "EverGreenTerrace");
            var p1 = _personRepository.Single(p => p.FirstName == "Bart");
            var p2 = _personRepository.Single(p => p.FirstName == "Lisa");
            var p3 = _personRepository.Single(p => p.FirstName == "Maggie");

            _logger.LogWarning("Bookings Added");

            #region 3 booking random
            var b1 = new Booking()
            {
                Comment   = "I Hate School ",
                Voyage    = v1,
                Passenger = (Passenger)p1
            };
            var b2 = new Booking()
            {
                Comment   = "I Love School",
                Voyage    = v1,
                Passenger = (Passenger)p2
            };
            var b3 = new Booking()
            {
                Comment   = "Twig Twig",
                Voyage    = v2,
                Passenger = (Passenger)p1
            };
            #endregion
            _bookingRepository.UpdateRange(b1, b2, b3);
            _bookingRepository.Save();
            _logger.LogWarning("Booking added");
        }
コード例 #3
0
        public IActionResult DetailWithVoyageId(int id)
        {
            ViewData["VoyageId"] = id;

            var reservation = Repository.Single(e => e.VoyageId == id);

            var voyage = _voyageRepository.Single(id);

            ViewBag.CurrentDepart      = voyage.Depart;
            ViewBag.CurrentDestination = voyage.Destination;
            ViewBag.CurrentDate        = voyage.Date.ToString();

            return(View("Detail"));
        }