// GET Province public IHttpActionResult Get([FromUri] ProvinceQuery request) { var list = ProvinceService.List(request); var mapped = list.Map <Province, ProvinceModel>(); // Returns a 200 status with custom headers (paging) return(Page(mapped)); }
/// <summary> /// Search by criteria /// </summary> /// <param name="request">Filter, pagination, sorting parameters</param> /// <returns>Paged result (sorted)</returns> public PagedList <Province> List(ProvinceQuery request) { var query = base.List(); // Build que query if (!string.IsNullOrWhiteSpace(request.Name)) { query = query.Where(i => i.Name.Contains(request.Name)); } if (request.CountryId != null) { query = query.Where(i => i.CountryId == request.CountryId); } // Apply paging and sorting var result = query.ToPaged(request); return(result); }