//Finding the Appropriate Hotel Id public int FindTheAppropriateHotelId(string hotelName) { List <int> hotelId = dbContext.hotelDetails.Where(x => x.hotelName == hotelName).Select(y => y.hotelId).ToList(); foreach (int id in hotelId) { HotelCityMapping details = dbContext.hotelCityMap.Find(id); if (details == null) { return(id); } } return(0); }
//Retrieving the hotelId using the details send by the admin and mapping it with cityId public bool CityIdHotelIdUpdate(int cityId, int hotelId) { if (cityId > 0 && hotelId > 0) { HotelCityMapping mapping = new HotelCityMapping(); mapping.cityId = cityId; mapping.hotelId = hotelId; dbContext.hotelCityMap.Add(mapping); dbContext.SaveChanges(); return(true); } else { return(false); } }