コード例 #1
0
        /// <summary>
        /// Display reservation details (Hotle, room, reservation info, ...) when the user is authorized
        /// </summary>
        public ActionResult Details(int id)
        {
            //Check if session exist
            if (Session["IsAuthorized"] != null)
            {
                bool isAuthorized = Convert.ToBoolean(Session["IsAuthorized"]);

                //check session status, if true get data and display it
                if (isAuthorized)
                {
                    Reservation reservation = ReservationManager.GetReservation(id);

                    ReservationValidateVM reservationValidate = new ReservationValidateVM();
                    reservationValidate.Arrival    = reservation.Arrival;
                    reservationValidate.Departure  = reservation.Departure;
                    reservationValidate.TotalNight = ReservationManager.GetNumberOfNight(reservation.Arrival, reservation.Departure);
                    reservationValidate.FirstName  = reservation.Client.Firstname;
                    reservationValidate.LastName   = reservation.Client.Lastname;
                    reservationValidate.Rooms      = reservation.Rooms;
                    reservationValidate.TotalPrice = ReservationManager.CalculatePrice(reservation.Rooms, reservation.Arrival, reservation.Departure);
                    reservationValidate.RoomNumber = reservation.Rooms.Count();

                    ViewBag.ReservationValidate = reservationValidate;

                    return(View());
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Validate()
        {
            ReservationVM reservation = (ReservationVM)TempData["Reservation"];

            TempData["Reservation"] = reservation;

            List <Room> rooms = new List <Room>();

            foreach (int id in reservation.RoomIds)
            {
                Room room = RoomManager.GetRoom(id);
                rooms.Add(room);
            }

            ReservationValidateVM reservationValidate = new ReservationValidateVM();

            reservationValidate.Arrival    = reservation.Arrival;
            reservationValidate.Departure  = reservation.Departure;
            reservationValidate.TotalNight = ReservationManager.GetNumberOfNight(reservation.Arrival, reservation.Departure);
            reservationValidate.FirstName  = reservation.Firstname;
            reservationValidate.LastName   = reservation.Lastname;
            reservationValidate.Rooms      = rooms;
            reservationValidate.TotalPrice = ReservationManager.CalculatePrice(reservation.RoomIds, reservation.Arrival, reservation.Departure);
            reservationValidate.RoomNumber = rooms.Count();

            ViewBag.ReservationValidate = reservationValidate;

            return(View(reservation));
        }