public ActionResult Create(HotelDTO hotel) { string error = ""; // hotelRepository.ValidateSave(hotel); ReturnUrlSet(); if (error.Length == 0) { hotelService.Save(hotel); return RedirectToAction("Success", "Hotel", new { message = "Successfully saved the Hotel." }); } else { TempData["ValidationError"] = error; TempData["HotelChainSelectedId"] = hotel.HotelChain.Id; return RedirectToAction("Add", "Hotel", hotel); } }
public ActionResult Add(HotelDTO hotel) { List<HotelChainDTO> hotelChains = hotelChainService.GetAll().ToList(); hotelChains.Insert(0, new HotelChainDTO { Id = 0, Name = String.Empty }); SelectList hotelChainList; if (hotel == null || TempData["HotelChainSelectedId"] == null) { hotelChainList = new SelectList(hotelChains, "Id", "Name"); hotel = new HotelDTO(); } else { hotelChainList = new SelectList(hotelChains, "Id", "Name", TempData["HotelChainSelectedId"]); ViewBag.ValidationError = TempData["ValidationError"]; } ViewBag.HotelChainList = hotelChainList; ReturnUrlSet(); return View("Add", hotel); }
public ActionResult Delete(HotelDTO hotel, int? id) { string error = ""; // hotelRepository.ValidateDelete(hotel); ReturnUrlSet(); if (error.Length == 0) { hotel = hotelService.GetHotel(hotel.Id); hotelService.Delete(hotel); return View("Success", (object)"Hotel deleted successfully."); } else { return Redirect((string)TempData["ReturnUrl"]); } }
public void Save(HotelDTO obj) { hotelRepository.Save(Mapper.Map<HotelDTO, Hotel>(obj)); }
public void Delete(HotelDTO obj) { hotelRepository.Delete(Mapper.Map<HotelDTO, Hotel>(obj)); }