public ActionResult DeleteConfirmed(int id)
        {
            HotelBookingVM hotelBookingVM = new HotelBookingVM(_hotelBookingRepository.GetWhereId(id));

            _hotelBookingRepository.Delete(hotelBookingVM.ToModel());

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(HotelBookingVM hotelBookingVM)
        {
            this.CheckIfYouCanBookRoom(hotelBookingVM);

            if (ModelState.IsValid)
            {
                _hotelBookingRepository.Edit(hotelBookingVM.ToModel());
                ChangeTamagotchiHotelRoom(hotelBookingVM);
                return(RedirectToAction("Index"));
            }

            var tamagotchi = this._tamagotchiRepository.GetAllTamagotchisALiveAndNoHotelRoom();

            ViewBag.TamagotchisIds = new MultiSelectList(tamagotchi, "TamagotchiId", "Name", hotelBookingVM.TamagotchisIds);

            hotelBookingVM = new HotelBookingVM(_hotelBookingRepository.GetWhereId(hotelBookingVM.HotelRoomId));

            return(View(hotelBookingVM));
        }
        public ActionResult Create(HotelBookingVM hotelBookingVM)
        {
            this.CheckIfYouCanBookRoom(hotelBookingVM);

            if (ModelState.IsValid)
            {
                _hotelBookingRepository.Add(hotelBookingVM.ToModel());
                ChangeTamagotchiHotelRoom(hotelBookingVM);
                return(RedirectToAction("Index"));
            }

            var hotelRoomsWithOutBooking = this._hotelRoomRepository.GetAllHotelRoomsWhereBookingIsNull();

            ViewBag.HotelRoomId = new SelectList(hotelRoomsWithOutBooking, "HotelRoomId", "HotelRoomName", hotelBookingVM.HotelRoomId);

            var tamagotchi = this._tamagotchiRepository.GetAllTamagotchisALiveAndNoHotelRoom();

            ViewBag.TamagotchisIds = new MultiSelectList(tamagotchi, "TamagotchiId", "Name", hotelBookingVM.TamagotchisIds);

            return(View(hotelBookingVM));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HotelBookingVM hotelBookingVM = new HotelBookingVM(_hotelBookingRepository.GetWhereId(id));

            _hotelBookingRepository.SetAllTamagotchiHotelRoomToNull(hotelBookingVM.ToModel());

            if (hotelBookingVM == null)
            {
                return(HttpNotFound());
            }

            var tamagotchi = this._tamagotchiRepository.GetAllTamagotchisALiveAndNoHotelRoom();

            ViewBag.TamagotchisIds = new MultiSelectList(tamagotchi, "TamagotchiId", "Name", hotelBookingVM.TamagotchisIds);

            return(View(hotelBookingVM));
        }