private ProviderMatch SetupComparedProviderDetails(OrganizationLicense orgLicense, List <ClauseMatch> comparedClauses)
        {
            // Get provider endpoint
            var endpoint = _providerEndpoints.FirstOrDefault(i => i.ID == orgLicense.ProviderEndpointID);

            // Get provider application
            var app = _applicationService.FirstOrDefault(i => i.ID == endpoint.ApplicationId);

            // Get provider organization
            var org = _organisations.FirstOrDefault(i => i.ID == app.OrganizationID);

            // Setup result
            var result = new ProviderMatch();

            result.Clauses           = new List <ClauseMatch>();
            result.OrganizationName  = org.Name;
            result.EndpointName      = endpoint.Name;
            result.EndpointId        = endpoint.ID;
            result.ProviderLicenseId = orgLicense.ID;

            // Setup compared clauses
            result.Clauses = comparedClauses;

            // Setup provider match flag
            result.IsMatch = !comparedClauses.Any(i => i.IsMatched == false);
            //result.IsMatch = true;

            // Return result
            return(result);
        }
        private List <ProviderMatch> GetAllSchemaProviders(int schemaId)
        {
            // Define result
            var result = new List <ProviderMatch>();

            var providerLicenses = _licenseService.Where(i => i.Status == (int)PublishStatus.Published)
                                   .Where(i => i.ProviderEndpointID != 0 && i.DataSchemaID == schemaId);

            if (!providerLicenses.Any())
            {
                // TODO: show notification message before user made license choices instead
                throw new BaseException("No providers who have published licenses for this schema based on current license template.");
            }

            // Process each published provider license
            foreach (var license in providerLicenses)
            {
                // Get provider endpoint
                var endpoint = _providerEndpoints.FirstOrDefault(i => i.ID == license.ProviderEndpointID);

                // Get provider application
                var app = _applicationService.FirstOrDefault(i => i.ID == endpoint.ApplicationId);

                // Get provider organization
                var org = _organisations.FirstOrDefault(i => i.ID == app.OrganizationID);

                // Setup provider details
                var match = new ProviderMatch();
                match.OrganizationName  = org.Name;
                match.EndpointName      = endpoint.Name;
                match.EndpointId        = endpoint.ID;
                match.ProviderLicenseId = license.ID;
                match.IsMatch           = true;

                // Add details to result
                result.Add(match);
            }

            // Return result
            return(result);
        }