public IHttpActionResult GetAdminHotelsByCity(RequestModel request) { ResponseModel response = new ResponseModel(); try { // if rate limit applied then return status forbidden // with rate limit message. if (_isRateLimitApplied) { return(Content(HttpStatusCode.Forbidden, RateLimit.RATE_LIMIT_APPLIED)); } // if modelstate is invalid then return status badrequest // with modalstate if (!ModelState.IsValid) { return(Content(HttpStatusCode.BadRequest, ModelState)); } var hotelsByCity = HotelsProvider.GetHotelsByCityId(request, out int total); response.HotelResponse = hotelsByCity; response.Total = total; response.Successful = total > 0 ? true : false; response.Code = total > 0 ? ResponseCode.Success : ResponseCode.Failed; return(Ok(response)); } catch (Exception ex) { Debug.WriteLine(string.Format("Error {0}", ex.Message)); return(Content(HttpStatusCode.InternalServerError, ModelState)); } }
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)); } }