public void Can_Get_Landmark_Paging() { var landmarkRequest = new LandmarkRequest { Page = 1, PageSize = 20 }; // Act var sut = _landmarkService.GetLandmarks(landmarkRequest); Assert.NotNull(sut); Assert.IsAssignableFrom <PagedResultModel <LandmarkModel> >(sut); var item = sut.Results.First(); Assert.NotNull(item); Assert.IsType <LandmarkModel>(item); }
public IEnumerable <LandmarkModel> GetLandmarks([FromQuery] LandmarkRequestModel query, int limit, int page) { long totalRecords = 0; var request = new LandmarkRequest { PageSize = limit, Page = page, SortColumn = !string.IsNullOrEmpty(query.Sort) ? query.Sort : "LP_NUMBER", SortOrder = !string.IsNullOrEmpty(query.Order) ? query.Order : "asc", LPCNumber = query.LPCNumber, }; var records = _landmarkService.GetLandmarks(request); totalRecords = records.Total; HttpContext.Response.Headers.Add("X-InlineCount", totalRecords.ToString()); return(records.Results); }
public IActionResult GetLandmarks([FromQuery] LandmarkRequestModel query, int limit, int page) { long totalRecords; var request = new LandmarkRequest { PageSize = limit, Page = page, SortColumn = !string.IsNullOrEmpty(query.Sort) ? query.Sort : "LP_NUMBER", SortOrder = !string.IsNullOrEmpty(query.Order) ? query.Order : "asc", LpcNumber = query.LpcNumber, }; var records = _landmarkService.GetLandmarks(request); totalRecords = records.Total; HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "X-InlineCount"); HttpContext.Response.Headers.Add("X-InlineCount", totalRecords.ToString()); return(Ok(records.Results.OrderBy(x => x.Street).ThenBy(x => x.Number))); }
public IHttpActionResult GetMapOptions() { var path = HttpContext.Current.Server.MapPath(Resources.LandmarksMapData); if (path == null) { return(NotFound()); } string data = File.ReadAllText(path); StringBuilder sb = new StringBuilder(data); var landmarks = JsonConvert .SerializeObject(_landmarkService.GetLandmarks() .AsQueryable() .ProjectTo <LandmarkToMapDto>()); sb.Insert(data.Length - 1, $",locations: {landmarks}"); return(Ok(JsonConvert.DeserializeObject(sb.ToString()))); }