Adding business-line specific metadata to a service request
In the following example, you'll see how to store business-line specific metadata with a service request, so it can be retrieved on the application dashboard.
Example 1 - Storing metadata
// Provide some metadata that helps to describe this particular service request.
var metadata = new BusinessLineMetadata() {
VesselManufacturer = "Princecraft",
MIC = "CA-QJT",
VesselYear = "2019"
};
// Create the service request artifact documents
await _documentManager.Create(document, metadata, document.DisplayNameEn, document.DisplayNameFr, MyDocumentVersion, serviceRequestId, CurrentUser.Id);
Example 2- Retrieving metadata on the dashboard
ICollection<ServiceRequest> serviceRequests = await _serviceRequestManager.Get<DTO.BusinessLineMetadata>(CurrentUser.Id, page, pageSize);
var dashboardViewModel = new MyRequestsViewModel
{
Requests = serviceRequests.Select(x =>
{
var serviceMetadata = (DTO.BusinessLineMetadata)x.Metadata;
return new ServiceRequestViewModel()
{
VesselManufacturer= serviceMetadata.VesselManufacturer,
MIC = serviceMetadata.MIC,
VesselYear = serviceMetadata.VesselYear
};
}).ToList()
};
return PartialView("MyRequests", dashboardViewModel);