public static SoftwareStatementSchema ToStmtSchema(this DataSchema schema) { var result = new SoftwareStatementSchema(); result.public_id = schema.PublicID; result.name = schema.Name; result.description = schema.Description; result.is_aggregate = schema.IsAggregate; return(result); }
private SchemaValidationResult GetValidationResult(SoftwareStatementSchema schemaDetails, Application consumerApp, LoggedInApplication loggedInApp) { var providerApp = _applications.FirstOrDefault(i => i.ID == loggedInApp.ID); var schema = _dataSchemas.FirstOrDefault(i => i.PublicID == schemaDetails.public_id); // Return error if schema with such id was not found if (schema == null) { var errorMessage = $" Provided schema '{schemaDetails.public_id}' does not exist."; return(GetErrorValidationResult(schemaDetails.public_id, errorMessage)); } // Get consumer approved requests var consumerRequests = _consumerRegistrationRequests.Where(i => i.ConsumerApplicationID == consumerApp.ID) .Where(i => i.Status == (int)ConsumerProviderRegistrationStatus.Approved); // Check whether there is a consumer request linked the provider & schema if (GetRequestThatForProvider(consumerRequests, schema.ID, providerApp.ID) != null) { return(GetSuccessValidationResult(schema.PublicID)); } // Both parties must have published data agreement which must match return(ConsumerRequestHasToBeApproved(schemaDetails.licenseId, consumerApp, providerApp, schema)); }