public ResourceCatalogResult DeleteResource(Guid workspaceID, string resourceName, string type, bool deleteVersions) { var @lock = Common.GetWorkspaceLock(workspaceID); lock (@lock) { if (resourceName == "*") { var noWildcardsAllowedhResult = ResourceCatalogResultBuilder.CreateNoWildcardsAllowedhResult("<Result>Delete resources does not accept wildcards.</Result>."); return(noWildcardsAllowedhResult); } if (string.IsNullOrEmpty(resourceName) || string.IsNullOrEmpty(type)) { throw new InvalidDataContractException(ErrorResource.ResourceNameAndTypeMissing); } var workspaceResources = _resourceCatalog.GetResources(workspaceID); var resources = _resourceCatalog.GetResourcesBasedOnType(type, workspaceResources, r => string.Equals(r.ResourceName, resourceName, StringComparison.InvariantCultureIgnoreCase)); var commands = new Dictionary <int, ResourceCatalogResult>() { { 0, ResourceCatalogResultBuilder.CreateNoMatchResult($"<Result>{type} '{resourceName}' was not found.</Result>") }, { 1, DeleteImpl(workspaceID, resources, workspaceResources, deleteVersions) }, }; if (commands.ContainsKey(resources.Count)) { var resourceCatalogResult = commands[resources.Count]; return(resourceCatalogResult); } return(ResourceCatalogResultBuilder.CreateDuplicateMatchResult($"<Result>Multiple matches found for {type} '{resourceName}'.</Result>")); } }