public ActionResult DeleteRoomType(HotelRoomCategoryViewModel hotelRoomCategoryViewModel) { HotelRoomBind hotelRoomBind = AutoMapper.Mapper.Map <HotelRoomCategoryViewModel, HotelRoomBind>(hotelRoomCategoryViewModel); //Deleting Hotel Details hotelDetails.DeleteRoomType(hotelRoomBind.HotelRoomId); return(RedirectToAction("AddRoomCategory", "Hotel")); }
public ActionResult UpdateRoomType([Bind(Exclude = "RoomCategory,Hotel")] HotelRoomCategoryViewModel hotelRoomCategoryViewModel) { Byte[] bytes = null; HotelRoomBind hotelRoomBind = new HotelRoomBind(); if (hotelRoomCategoryViewModel.RoomImages != null) { Stream fs = hotelRoomCategoryViewModel.RoomImages.InputStream; BinaryReader br = new BinaryReader(fs); bytes = br.ReadBytes((Int32)fs.Length); hotelRoomCategoryViewModel.RoomImage = bytes; } else { hotelRoomBind = hotelDetails.GetRoomCategoryDetail(hotelRoomCategoryViewModel.HotelRoomId); hotelRoomCategoryViewModel.RoomImage = hotelRoomBind.RoomImage; } hotelRoomCategoryViewModel.UploadDate = DateTime.Now; hotelRoomBind = AutoMapper.Mapper.Map <HotelRoomCategoryViewModel, HotelRoomBind>(hotelRoomCategoryViewModel); //Updating Hotel Details hotelDetails.UpdateRoomType(hotelRoomBind); if (User.IsInRole("Admin")) { return(RedirectToAction("ManageHotel", "Hotel", new { Approved = "Approved" })); } else { return(RedirectToAction("ManageHotel", "Hotel", new { MyHotel = "MyHotel" })); } }
public void AddRoomCategoryForHotel(HotelRoomBind hotelRoomCategory) { using (UserContext userContext = new UserContext()) { userContext.HotelRooms.Add(hotelRoomCategory); //Adding RoomCategories userContext.SaveChanges(); } }
public HotelRoomBind GetRoomTypeDetails(int HotelRoomId) { using (UserContext userContext = new UserContext()) { HotelRoomBind hotelRoomDetails = userContext.HotelRooms.Where(model => model.HotelRoomId == HotelRoomId).SingleOrDefault(); return(hotelRoomDetails); } }
public void UpdateRoomType(HotelRoomBind hotelRoomBind) { using (UserContext userContext = new UserContext()) { //For Updating the details of room type userContext.Entry(hotelRoomBind).State = EntityState.Modified; userContext.SaveChanges(); } }
public ActionResult EditRoomType(HotelRoomCategoryViewModel hotelRoomCategoryViewModel) { List <RoomCategory> roomCategory = hotelDetails.GetCategory(); List <SelectListItem> categoryList = new List <SelectListItem>(); foreach (RoomCategory detail in roomCategory) //For Getting list of Categories { categoryList.Add(new SelectListItem { Text = @detail.RoomType, Value = @detail.RoomId.ToString() }); } ViewBag.list = categoryList; HotelRoomBind hotelRoomBind = hotelDetails.GetRoomTypeDetails(hotelRoomCategoryViewModel.HotelRoomId); hotelRoomCategoryViewModel = AutoMapper.Mapper.Map <HotelRoomBind, HotelRoomCategoryViewModel>(hotelRoomBind); return(View(hotelRoomCategoryViewModel)); }
public ActionResult AddRoomCategory(RoomViewModel roomViewModel, HotelRoomCategoryViewModel hotelRoomCategoryViewModel, string Save) { Byte[] bytes = null; if (roomViewModel.RoomImages.FileName != null) { Stream fs = roomViewModel.RoomImages.InputStream; BinaryReader br = new BinaryReader(fs); bytes = br.ReadBytes((Int32)fs.Length); roomViewModel.HotelRoomCategoryViewModel.RoomImage = bytes; roomViewModel.HotelRoomCategoryViewModel.UploadDate = DateTime.Now; } TempData["HotelId"] = roomViewModel.HotelRoomCategoryViewModel.HotelId; List <RoomCategory> list = hotelDetails.GetCategory(); List <SelectListItem> categoryList = new List <SelectListItem>(); foreach (RoomCategory details in list) { categoryList.Add(new SelectListItem { Text = @details.RoomType, Value = @details.RoomId.ToString() }); } ViewBag.List = categoryList; if (ModelState.IsValid) { HotelRoomBind hotel = AutoMapper.Mapper.Map <HotelRoomCategoryViewModel, HotelRoomBind>(roomViewModel.HotelRoomCategoryViewModel); hotelDetails.AddRoomCategoryForHotel(hotel); //Adding RoomCategories TempData["HotelId"] = hotel.HotelId; if (Save != null) { if (User.IsInRole("Admin")) { return(RedirectToAction("ManageHotel", "Hotel", new { Approved = "Approved" })); } else { return(RedirectToAction("ManageHotel", "Hotel", new { MyHotel = "MyHotel" })); } } return(RedirectToAction("AddRoomCategory", "Hotel")); } return(View(roomViewModel)); }
public ActionResult AddRoomCategory(HotelRoomCategoryViewModel hotelRoomCategory) { List <RoomCategory> list = hotelDetails.GetCategory(); List <SelectListItem> categoryList = new List <SelectListItem>(); foreach (RoomCategory details in list) { categoryList.Add(new SelectListItem { Text = @details.RoomType, Value = @details.RoomId.ToString() }); } if (ModelState.IsValid) { HotelRoomBind hotel = AutoMapper.Mapper.Map <HotelRoomCategoryViewModel, HotelRoomBind>(hotelRoomCategory); hotelDetails.AddRoomCategoryForHotel(hotel); return(RedirectToAction("ManageHotel", "Admin")); } //ViewBag.RoomCategory = new SelectList(HotelRepository.GetCategories(), "RoomId", "RoomType"); return(View()); }
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)); }
public void UpdateRoomType(HotelRoomBind hotelRoomBind) { hotelRepository.UpdateRoomType(hotelRoomBind); }
public void AddRoomCategoryForHotel(HotelRoomBind hotelRoomCategory) { hotelRepository.AddRoomCategoryForHotel(hotelRoomCategory); }