public ActionResult Edit(EditViewModel editViewModel) { if (editViewModel == null) { throw new HttpException(400, "Bad Request"); } var roomType = RoomTypeService.FindById(editViewModel.RoomTypeId); if (roomType == null) { throw new HttpException(404, "Not Found"); } roomType.Name = editViewModel.Name; roomType.Description = editViewModel.Description; RoomTypeService.UpdateRoomType(roomType); TempData["RoomTypeId"] = roomType.RoomTypeId; TempData["RoomTypeName"] = roomType.Name; TempData["Message"] = RoomTypesMessage.EditSuccess; return RedirectToAction("index", "roomtypes"); }
public ActionResult Edit(int? id) { if (id == null) { throw new HttpException(400, "Bad Request"); } var roomType = RoomTypeService.FindById(id.Value); if (roomType == null) { throw new HttpException(404, "Not Found"); } var editViewModel = new EditViewModel() { RoomTypeId = roomType.RoomTypeId, Name = roomType.Name, Description = roomType.Description, }; return View(editViewModel); }