Executes query on service requests.
Description
Executes a query on service requests by providing a ServiceRequest object which contain parameters to filter the results by the place of supply and/or the status.
Package Details
Interface
IServiceRequestManager
Syntax
Task<ICollection<ServiceRequest>> ExecuteQuery<T>(ServiceRequestQuery serviceRequestQuery)
Returns
Task<ICollection<ServiceRequest>>
API
POST
/api/servicerequests/query
Parameters
Parameter | Description | Parameter Type |
---|---|---|
excludeServiceRequests | True to include service requests in the result. False to exclude service requests in the result. | Query string |
ServiceRequestQuery | This object is used to define the filtering for the place of supply and status. | Request body |
Sample request body - filtering by place of supply and status for service id 11.
{ "UserId": 0, "ServiceId": 11, "OrganizationId": 0, "ExcludeMetadata": false, "ExcludeServiceRequests": false, "Page": 1, "PageSize": 25, "Filter": "PlaceOfSupply='ON' AND Status='InProgress'", "Version": 1 }
Sample request body - filtering by place of supply for service id 11.
{ "UserId": 0, "ServiceId": 11, "OrganizationId": 0, "ExcludeMetadata": false, "ExcludeServiceRequests": false, "Page": 1, "PageSize": 25, "Filter": "PlaceOfSupply='ON'", "Version": 1 }
Sample request body - filtering by status for service id 11.
{ "UserId": 0, "ServiceId": 11, "OrganizationId": 0, "ExcludeMetadata": false, "ExcludeServiceRequests": false, "Page": 1, "PageSize": 25, "Filter": "Status='InProgress'", "Version": 1 }
Returns
200 OK - Collection of service requests (with or without metadata)
400 Bad Request - Service requests couldn’t be retrieved
Example - Filtering by place of supply and status
//This is an exemple of a query using filtering for the place of supply and status. //This will filter all service requests for service id 11. const ServiceRequestStatus status = ServiceRequestStatus.InProgress; const string province = "ON"; var query = new ServiceRequestQuery { ServiceId = ServiceId, Page = 1, PageSize = 25, Version = 1.0F, Filter = $"PlaceOfSupply='{province}' AND Status='{status}'" }; // Get all service requests with metadata using the place of supply and status filter. var requestWithMetadata = await serviceRequestManager.ExecuteQuery<ServiceRequestMetadata>(query, false); // Get all service requests without metadata using the place of supply and status filter. var requestsNoMetadata = await serviceRequestManager.ExecuteQuery<NoMetadata>(query, true);
Example - Filtering by place of supply only
//This is an exemple of a query using filtering for the place of supply and status. //This will filter all service requests for service id 11. const string province = "ON"; var query = new ServiceRequestQuery { ServiceId = ServiceId, Page = 1, PageSize = 25, Version = 1.0F, Filter = $"PlaceOfSupply='{province}'" }; // Get all service requests with metadata using the place of supply and status filter. var requestWithMetadata = await serviceRequestManager.ExecuteQuery<ServiceRequestMetadata>(query, false); // Get all service requests without metadata using the place of supply and status filter. var requestsNoMetadata = await serviceRequestManager.ExecuteQuery<NoMetadata>(query, true);
Example - Filtering by service request status
//This is an exemple of a query using filtering for the place of supply and status. //This will filter all service requests for service id 11. const ServiceRequestStatus status = ServiceRequestStatus.InProgress; var query = new ServiceRequestQuery { ServiceId = ServiceId, Page = 1, PageSize = 25, Version = 1.0F, Filter = $"Status='{status}'" }; // Get all service requests with metadata using the place of supply and status filter. var requestWithMetadata = await serviceRequestManager.ExecuteQuery<ServiceRequestMetadata>(query, false); // Get all service requests without metadata using the place of supply and status filter. var requestsNoMetadata = await serviceRequestManager.ExecuteQuery<NoMetadata>(query, true);
ServiceRequestQuery
Name | Type | Description |
UserId | Integer | User id associated to service request. Default value is 0. |
ServiceId | Integer | Service id associated to service request. Default value is 0. |
OrganizationId | Integer | Organization id associated to service request. Default is 0. |
ExcludeMetadata | Boolean | True to include the service request meta data be included in the result. False to exclude the service request meta data be included in the result. |
ExcludeServiceRequests | Boolean | True to include service requests in the result. False to exclude service requests in the result. This is currently not used in the code. |
Page | Integer | The page number. If the value provided is 0 then it will default to 1. |
PageSize | Integer | The page size. If the value provided is 0 then it will default to 25. |
Filter | String | This is used to filter the results by place of supply and/or status. Note: Place of supply Note: Status Note: Place of supply and status Example: List of service request statuses.
Valid values are in upper case: |
Version | Number | Filter version number. This is currently not used in the code. |