public NHResult <Hotel> Create(HotelDTO dto) { var hotel = new Hotel { Name = dto.Name, Address = dto.Address, Location = dto.Location, Sort = dto.Sort }; var mManager = new RoomTypeManager(); var roomTypes = mManager.GetByIds(dto.RoomTypes.Select(m => m.Id), true); hotel.RoomTypes = roomTypes.ToList(); var result = base.SaveOrUpdate(hotel); return(result); }
public NHResult <Hotel> Update(HotelDTO dto) { var hotel = base.GetById(dto.Id); hotel.Name = dto.Name; hotel.Address = dto.Address; hotel.Location = dto.Location; hotel.Sort = dto.Sort; var mManager = new RoomTypeManager(); var roomTypes = mManager.GetByIds(dto.RoomTypes.Select(m => m.Id), true); hotel.RoomTypes.Clear(); foreach (var r in roomTypes) { hotel.RoomTypes.Add(r); } var result = base.SaveOrUpdate(hotel); return(result); }