public async Task <HotelBindingModel> AddHotelAsync([FromBody][Required] HotelBindingModel hotel) { IEnumerable <Hotel> hotelsByCity = await UnitOfWork.Hotel.GetByCityAsync(hotel.City); if (hotelsByCity.Any(h => h.name == hotel.Name)) { throw new Exception("Hotel already exists"); } Hotel hotelInfo = new Hotel() { //id = Guid.NewGuid(), name = hotel.Name, phone = hotel.Phone, address = hotel.Address, city = hotel.City, state = hotel.State, zip = hotel.Zip, }; await UnitOfWork.Hotel.AddAsync(hotelInfo); hotel.HotelId = hotelInfo.id; return(hotel); }
public HotelByCity(Hotel hotel) { city = hotel.city; hotel_id = hotel.id; hotel_info = hotel; }