public ActionResult Create(CreateViewModel createViewModel) { if (!ModelState.IsValid) { return View(createViewModel); } ; var selectedRoomType = RoomTypeService.FindById(createViewModel.Dropdownlist_RoomType_Property.SelectedRoomType); var selectedRoomClass = RoomClassService.FindById(createViewModel.Dropdownlist_RoomClass_Property.SelectedRoomClass); var selectedCruise = CruiseService.FindById(createViewModel.Dropdownlist_Cruise_Property.SelectedCruise); var room = new Room() { Name = createViewModel.Name, Description = createViewModel.Description, RoomClass = selectedRoomClass, RoomClassId = RoomClassService.FindById(createViewModel.Dropdownlist_RoomClass_Property.SelectedRoomClass) != null ? (int?)RoomClassService.FindById(createViewModel.Dropdownlist_RoomClass_Property.SelectedRoomClass).RoomClassId : null, RoomType = selectedRoomType, RoomTypeId = RoomTypeService.FindById(createViewModel.Dropdownlist_RoomType_Property.SelectedRoomType) != null ? (int?)RoomTypeService.FindById(createViewModel.Dropdownlist_RoomType_Property.SelectedRoomType).RoomTypeId : null, Cruise = selectedCruise, CruiseId = CruiseService.FindById(createViewModel.Dropdownlist_Cruise_Property.SelectedCruise) != null ? (int?)CruiseService.FindById(createViewModel.Dropdownlist_Cruise_Property.SelectedCruise).CruiseId : null }; RoomService.CreateRoom(room); TempData["RoomId"] = room.RoomId; TempData["RoomName"] = room.Name; TempData["Message"] = RoomsMessage.CreateSuccess; return RedirectToAction("index", "rooms"); }
public void UpdateRoom(Room room) { RoomRepository.Update(room); SaveRoom(); }
public void DeleteRoom(Room room) { RoomRepository.Delete(room); SaveRoom(); }
public void CreateRoom(Room room) { RoomRepository.Add(room); SaveRoom(); }