Ejemplo n.º 1
0
        public IActionResult Upsert(int?id)
        {
            ReservationVm reservationVm = new ReservationVm()
            {
                Reservation = new Reservation(),
                EventList   = _unitOfWork.Event.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Date + " " + i.StartTime + " " + i.Movie.Title,
                    Value = i.Id.ToString()
                }),
                SeatList = _unitOfWork.Seat.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Row.Hall.Name + " " + i.Row.Number + " " + i.Number,
                    Value = i.Id.ToString()
                })
            };

            if (id == null)
            {
                return(View(reservationVm));
            }

            reservationVm.Reservation = _unitOfWork.Reservation.Get(id.GetValueOrDefault());
            if (reservationVm.Reservation == null)
            {
                return(NotFound());
            }
            return(View(reservationVm));
        }
Ejemplo n.º 2
0
        public ActionResult EditReservaion(long id)
        {
            try
            {
                Roomregister  roomregister  = _hotelReservationService.GetRoomRegisterById(id);
                ReservationVm reservationVm = CastToVm(roomregister);

                List <SelectListItem> billingTypes = new List <SelectListItem>();
                billingTypes.Add(new SelectListItem()
                {
                    Text = "Cash", Value = "1"
                });
                billingTypes.Add(new SelectListItem()
                {
                    Text = "Card", Value = "2"
                });

                ViewBag.billingTypes = new SelectList(billingTypes, "Value", "Text", reservationVm.BillingType.ToString());

                IList <Roomtype> roomTypes = _hotelReservationService.LoadAllHotelTypes();
                ViewBag.roomTypes    = new SelectList(roomTypes, "Id", "Name");
                ViewBag.roomTypeList = roomTypes;
                IList <Room> rooms = _hotelReservationService.LoadAllRooms();
                ViewBag.roomList = rooms;

                return(View(reservationVm));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult SaveRoomBooking(string hotelReservationObj)
        {
            try
            {
                JavaScriptSerializer serializer        = new JavaScriptSerializer();
                ReservationVm        roomReservationVm = serializer.Deserialize <ReservationVm>(hotelReservationObj);

                Booking roomBooking = new Booking();
                roomBooking.Checkindate  = roomReservationVm.CheckinDate;
                roomBooking.Checkoutdate = roomReservationVm.CheckoutDate;
                roomBooking.Noofadult    = roomReservationVm.NoOfAdult;
                roomBooking.Noofchild    = roomReservationVm.NoOfChild;

                Bookingdetail bookingDetail = new Bookingdetail();
                bookingDetail.Advanceamount = roomReservationVm.AdvanceAmount;
                bookingDetail.Billingtype   = roomReservationVm.BillingType;
                bookingDetail.Contactno     = roomReservationVm.ContactNumber;
                bookingDetail.Creditcardno  = roomReservationVm.CreditCardNo;
                bookingDetail.Email         = roomReservationVm.Email;
                bookingDetail.Firstname     = roomReservationVm.FirstName;
                bookingDetail.Lastname      = roomReservationVm.LastName;
                bookingDetail.Noofnight     =
                    roomReservationVm.CheckoutDate.Subtract(roomReservationVm.CheckinDate).Days;
                bookingDetail.Status = Roomregisterdetail.EntityStatus.Booked;
                roomBooking.Bookingdetails.Add(bookingDetail);
                bookingDetail.Booking = roomBooking;

                Customer customer = new Customer();
                customer.Firstname     = roomReservationVm.FirstName;
                customer.Lastname      = roomReservationVm.LastName;
                customer.Dob           = roomReservationVm.Dob;
                customer.Contactnumber = roomReservationVm.ContactNumber;
                customer.Email         = roomReservationVm.Email;
                customer.Address       = roomReservationVm.Address;
                customer.Nationality   = roomReservationVm.Nationality;
                customer.Nid           = roomReservationVm.Nid;
                customer.Passport      = roomReservationVm.Passport;
                customer.Remarks       = roomReservationVm.Remarks;

                IList <Roomhistory> roomHistories = new List <Roomhistory>();
                foreach (var roomId in roomReservationVm.RoomIds)
                {
                    Room room = _hotelReservationService.GetRoomById(Convert.ToInt64(roomId));
                    roomBooking.Rooms.Add(room);
                    Roomhistory roomHistory = new Roomhistory();
                    roomHistory.Arrivaldate = roomBooking.Checkindate;
                    roomHistory.Leavedate   = roomBooking.Checkoutdate;
                    roomHistory.Booking     = roomBooking;
                    roomHistory.Room        = room;
                    roomHistories.Add(roomHistory);
                }
                _hotelReservationService.SaveBooking(roomBooking, bookingDetail, roomHistories, customer);
                return(RedirectToAction("Booking", new { message = "Room Booked Successfully", type = 1 }));
            }
            catch (Exception)
            {
                return(RedirectToAction("Booking", new { message = "Failed to Booked Room", type = 2 }));
            }
        }
Ejemplo n.º 4
0
        private ReservationVm CastToVm(Roomregister roomregister)
        {
            ReservationVm reservationVm = new ReservationVm();

            reservationVm.Address       = roomregister.Customer.Address;
            reservationVm.AdvanceAmount = (decimal)roomregister.Roomregisterdetails[0].Advanceamount;
            reservationVm.BillingType   = (int)roomregister.Roomregisterdetails[0].Billingtype;
            reservationVm.CheckinDate   = roomregister.Checkindate;
            reservationVm.CheckoutDate  = roomregister.Checkoutdate;
            reservationVm.CreditCardNo  = roomregister.Roomregisterdetails[0].Creditcardno;
            reservationVm.Dob           = roomregister.Customer.Dob;
            reservationVm.Email         = roomregister.Customer.Email;
            reservationVm.FirstName     = roomregister.Customer.Firstname;
            reservationVm.LastName      = roomregister.Customer.Lastname;
            reservationVm.Id            = roomregister.Id;
            reservationVm.Nationality   = roomregister.Customer.Nationality;
            reservationVm.Nid           = roomregister.Customer.Nid;
            reservationVm.NoOfAdult     = (int)roomregister.Noofadult;
            reservationVm.NoOfChild     = (int)roomregister.Noofchild;
            reservationVm.Passport      = roomregister.Customer.Passport;
            //reservationVm.Rooms = roomregister.Roomhistories;
            return(reservationVm);
        }
Ejemplo n.º 5
0
        public IActionResult Upsert(ReservationVm reservationVm)
        {
            if (ModelState.IsValid)
            {
                if (reservationVm.Reservation.Id == 0)
                {
                    _unitOfWork.Reservation.Add(reservationVm.Reservation);
                }
                else
                {
                    _unitOfWork.Reservation.Update(reservationVm.Reservation);
                }
                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                reservationVm.EventList = _unitOfWork.Event.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Date + " " + i.StartTime + " " + i.Movie.Title,
                    Value = i.Id.ToString()
                });

                reservationVm.SeatList = _unitOfWork.Seat.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Row.Hall.Name + " " + i.Row.Number + " " + i.Number,
                    Value = i.Id.ToString()
                });

                if (reservationVm.Reservation.Id != 0)
                {
                    reservationVm.Reservation = _unitOfWork.Reservation.Get(reservationVm.Reservation.Id);
                }
            }
            return(View(reservationVm));
        }