public IList <HotelModel> GetHotelsByCityId(RequestModel request, out int total) { List <HotelModel> hotelsListByCityId = new List <HotelModel>(); total = 0; try { var allHotels = SingletonHotelsData.GetInstance().GetAllHotels; if (allHotels.Any()) { hotelsListByCityId = allHotels .Where(h => h.CityId.Equals(request.CityId, StringComparison.OrdinalIgnoreCase)) .Select(h => new HotelModel(request.SortDirection) { CityId = h.CityId, HotelId = h.HotelId, RoomName = h.RoomName, Price = h.Price }).ToList(); hotelsListByCityId.Sort(); total = hotelsListByCityId.Count; } } catch (Exception ex) { Debug.WriteLine(string.Format("Error {0}", ex.Message)); }; return(hotelsListByCityId); }
/// <summary> /// GetHotels By CityId /// </summary> /// <param name="requestModel">HotelsRequestModel</param> /// <param name="totalRecordCount">int</param> /// <returns></returns> public IList <HotelsResponseData> GetHotelsByCityId(HotelsRequestModel requestModel, out int totalRecordCount) { List <HotelsResponseData> response = new List <HotelsResponseData>(); totalRecordCount = default(Int32); try { var hotelsData = SingletonHotelsData.GetInstance().GetHotelsData; if (hotelsData != null) { response = (from h in hotelsData where (h.CityId.Equals(requestModel.CityId, StringComparison.OrdinalIgnoreCase)) select new HotelsResponseData(SortDirection.Desc) { CityId = h.CityId, HotelId = h.HotelId, RoomName = h.RoomName, Price = h.Price }) .ToList(); response.Sort(); totalRecordCount = (response != null) ? Convert.ToInt32(response.Count()) : 0; } } catch (Exception ex) { Debug.WriteLine(string.Format("Error {0}", ex.Message)); } return(response); }