public ActionResult ManageHotel(HotelTimingViewModel hotelTimingViewModel, string Status) { TempData["CheckIn"] = hotelTimingViewModel.TimingViewModel.CheckIn; TempData["CheckOut"] = hotelTimingViewModel.TimingViewModel.CheckOut; TempData.Keep(); List <Hotel> list = hotelDetails.GetHotelDetails(Status); List <HotelViewModel> hotelList = new List <HotelViewModel>(); foreach (Hotel detail in list) { HotelViewModel hotelViewModel; if (TempData["CheckIn"] != null) { int rooms = hotelDetails.GetAvailableRoomsCount(detail.HotelId, 0, Convert.ToString(TempData["CheckIn"]), Convert.ToString(TempData["CheckOut"])); hotelViewModel = AutoMapper.Mapper.Map <Hotel, HotelViewModel>(detail); hotelViewModel.AvailableRooms = rooms; } else { hotelViewModel = AutoMapper.Mapper.Map <Hotel, HotelViewModel>(detail); } hotelList.Add(hotelViewModel); //Displaying Hotel Details } TimingViewModel timing = new TimingViewModel(); hotelTimingViewModel.HotelViewModels = hotelList; hotelTimingViewModel.TimingViewModel = timing; return(View(hotelTimingViewModel)); }
public ActionResult DisplayRoomType(int Hotel, HotelTimingViewModel hotelTimingViewModel) { HotelViewModel hotelViewModel = new HotelViewModel(); ViewBag.CheckIn = TempData["CheckIn"]; ViewBag.CheckOut = TempData["CheckOut"]; ViewBag.Hotel = Hotel; hotelViewModel.HotelId = Hotel; TempData["HotelId"] = hotelViewModel.HotelId; Hotel hotel = hotelDetails.GetHotelDetailsById(hotelViewModel.HotelId); hotelViewModel = AutoMapper.Mapper.Map <Hotel, HotelViewModel>(hotel); List <HotelRoomBind> list = hotelDetails.GetRoomCategoryDetails(hotelViewModel.HotelId); List <HotelRoomCategoryViewModel> hotelList = new List <HotelRoomCategoryViewModel>(); TimingViewModel Timing = new TimingViewModel(); if ((hotelTimingViewModel.TimingViewModel) == null) { TempData["CheckIn"] = ViewBag.CheckIn; TempData["CheckOut"] = ViewBag.CheckOut; hotelTimingViewModel.TimingViewModel = Timing; if (TempData["CheckIn"] != null) { hotelTimingViewModel.TimingViewModel.CheckIn = Convert.ToDateTime(TempData["CheckIn"]); hotelTimingViewModel.TimingViewModel.CheckOut = Convert.ToDateTime(TempData["CheckOut"]); } else { hotelTimingViewModel.TimingViewModel.CheckIn = DateTime.Now; hotelTimingViewModel.TimingViewModel.CheckOut = DateTime.Now.AddDays(1); } } else { TempData["CheckIn"] = hotelTimingViewModel.TimingViewModel.CheckIn; TempData["CheckOut"] = hotelTimingViewModel.TimingViewModel.CheckOut; hotelTimingViewModel.TimingViewModel.CheckIn = Convert.ToDateTime(TempData["CheckIn"]); hotelTimingViewModel.TimingViewModel.CheckOut = Convert.ToDateTime(TempData["CheckOut"]); } foreach (HotelRoomBind detail in list) { HotelRoomCategoryViewModel hotelRoomCategoryViewModel; if (TempData["CheckIn"] != null) { int rooms = hotelDetails.GetAvailableRoomsCount(detail.HotelId, detail.RoomCategories.RoomId, Convert.ToString(TempData["CheckIn"]), Convert.ToString(TempData["CheckOut"])); hotelRoomCategoryViewModel = AutoMapper.Mapper.Map <HotelRoomBind, HotelRoomCategoryViewModel>(detail); hotelRoomCategoryViewModel.AvailableRooms = rooms; } else { hotelRoomCategoryViewModel = AutoMapper.Mapper.Map <HotelRoomBind, HotelRoomCategoryViewModel>(detail); } hotelList.Add(hotelRoomCategoryViewModel); //Displaying Room Categories } TempData["Hotel"] = ViewBag.Hotel; hotelTimingViewModel.HotelViewModel = hotelViewModel; hotelTimingViewModel.HotelRoomCategoryViewModels = hotelList; return(View(hotelTimingViewModel)); }
public ActionResult ManageHotel(string Status, string MyCart, string Approved, string Pending, string MyHotel, string Declined, List <Hotel> data) { List <Hotel> list = new List <Hotel>(); list = hotelDetails.GetHotelDetails(Status); if (TempData["data"] == null) { if (Approved != null) { list = hotelDetails.GetHotelDetails(Approved); } else if (Pending != null) { list = hotelDetails.GetHotelDetails(Pending); } else if (Declined != null) { list = hotelDetails.GetHotelDetails(Declined); } else if (MyHotel != null) { list = hotelDetails.GetHotelByName(User.Identity.Name); } } else { list = (List <Hotel>)TempData["data"]; } List <HotelViewModel> hotelList = new List <HotelViewModel>(); foreach (Hotel detail in list) { HotelViewModel hotelViewModel = AutoMapper.Mapper.Map <Hotel, HotelViewModel>(detail); hotelList.Add(hotelViewModel); //Displaying Hotel Details } TimingViewModel timing = new TimingViewModel(); HotelTimingViewModel hotelTimingViewModel = new HotelTimingViewModel(); hotelTimingViewModel.HotelViewModels = hotelList; hotelTimingViewModel.TimingViewModel = timing; UserRepository userDetails = new UserRepository(); User user = userDetails.GetUserDetailByName(User.Identity.Name); hotelTimingViewModel.UserViewModel = AutoMapper.Mapper.Map <User, UserViewModel>(user); return(View(hotelTimingViewModel)); }
public ActionResult BookingHotel(HotelTimingViewModel bookHotelViewModel) { BookHotel bookHotel = AutoMapper.Mapper.Map <BookViewModel, BookHotel>(bookHotelViewModel.BookViewModel); hotelDetails.UpdateRoomCount(bookHotelViewModel.BookViewModel.HotelRoomId); bookHotel.CheckIn = bookHotelViewModel.TimingViewModel.CheckIn; bookHotel.CheckOut = bookHotelViewModel.TimingViewModel.CheckOut; bookHotel.Gmail = bookHotelViewModel.BookViewModel.UserId; hotelDetails.BookHotel(bookHotel); Referral referral = hotelDetails.GetReferrerDetail(bookHotel.Gmail); if (referral != null) { hotelDetails.Reward(referral.ReferrerId); } TempData["alertMessage"] = "Booked Successfully"; return(RedirectToAction("ManageHotel", "Hotel", new { Approved = "Approved" })); }
public ActionResult BookHotel(HotelTimingViewModel hotelTimingViewModel, HotelRoomCategoryViewModel hotelRoom) { ViewBag.A = TempData["CheckIn"]; ViewBag.B = TempData["CheckOut"]; TempData["CheckIn"] = ViewBag.A; TempData["CheckOut"] = ViewBag.B; hotelTimingViewModel.BookViewModel = new BookViewModel(); hotelTimingViewModel.BookViewModel.HotelRoomId = hotelRoom.HotelRoomId; if (TempData["CheckIn"] != null) { hotelTimingViewModel.BookViewModel.CheckIn = Convert.ToDateTime(TempData["CheckIn"]); //DateTime.Parse(a); hotelTimingViewModel.BookViewModel.CheckOut = Convert.ToDateTime(TempData["CheckIn"]); //DateTime.Parse(b); } hotelTimingViewModel.BookViewModel.UserId = HttpContext.User.Identity.Name; HotelRoomBind hotelRooms = hotelDetails.GetRoomCategoryDetail(hotelRoom.HotelRoomId); Hotel hotel = hotelDetails.GetHotelDetailsById(hotelRooms.HotelId); hotelTimingViewModel.HotelViewModel = AutoMapper.Mapper.Map <Hotel, HotelViewModel>(hotel); hotelTimingViewModel.HotelRoomCategoryViewModel = AutoMapper.Mapper.Map <HotelRoomBind, HotelRoomCategoryViewModel>(hotelRooms); hotelTimingViewModel.HotelRoomCategoryViewModel.RoomCategories = new RoomCategory(); hotelTimingViewModel.HotelRoomCategoryViewModel.RoomCategories = (hotelDetails.GetCategoryById(hotelTimingViewModel.HotelRoomCategoryViewModel.RoomId)); return(View(hotelTimingViewModel)); }