/// <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); }
/// <summary> /// Get Hotels By CityId /// </summary> /// <param name="requestModel">HotelsRequestModel</param> /// <param name="totalRecordCount">int</param> /// <returns></returns> public static IList <HotelsResponseData> GetHotelsByCityId(HotelsRequestModel requestModel, out int totalRecordCount) { totalRecordCount = default(int); try { return(new HotelsRepository().GetHotelsByCityId(requestModel, out totalRecordCount)); } catch (Exception ex) { throw ex; } }
public IHttpActionResult GetByCityId_Authenticate(HotelsRequestModel model) { if (_isRateLimitApplied) { return(Content(HttpStatusCode.MethodNotAllowed, ApplicationConstant.RATE_LIMIT_APPLIED)); } if (!ModelState.IsValid) { return(Content(HttpStatusCode.BadRequest, ModelState)); } HotelsResponse response = new HotelsResponse(); try { var res = HotelsProvider.GetHotelsByCityId(model, out int totalRecordCount); response.Response = res; response.TotalRecordCount = totalRecordCount; if (totalRecordCount != 0) { response.Successful = true; response.ResponseCode = ResponseCode.Success; } else { response.Successful = false; response.ResponseCode = ResponseCode.Fail; } return(Ok(response)); } catch (Exception ex) { //Log exception in db Debug.WriteLine(string.Format("Error {0}", ex.Message)); return(Content(HttpStatusCode.InternalServerError, ModelState)); } }