public async Task <ODMWorkspace> GetWorkspaceAsync(string ownerId, bool retrieveCached)
        {
            if (retrieveCached)
            {
                return(activeWorkspace);
            }
            else
            {
                List <ODMWorkspace> workspaceLockup = await workspaceRepo.GetItemsAsync(x => x.OwnerId == ownerId) as List <ODMWorkspace>;

                //No workspace found for OwnerId
                if (workspaceLockup.Count == 0)
                {
                    throw new InvalidOperationException("Owner workspace do not exist");
                }
                else
                {
                    //TODO: Add logic to handle multiple workspaces for same owner. for now only a single workspace for owner is supported.
                    activeWorkspace = workspaceLockup[0];
                }

                filesBlobContainer  = new AzureBlobStorageRepository(blobStorageName, blobStorageKey, activeWorkspace.FilesCotainerUri);
                modelsBlobContainer = new AzureBlobStorageRepository(blobStorageName, blobStorageKey, activeWorkspace.ModelCotainerUri);

                return(activeWorkspace);
            }
        }
        private async Task <ODMWorkspace> GetOrCreateWorkspaceAsync(string ownerId)
        {
            List <ODMWorkspace> workspaceLockup = await workspaceRepo.GetItemsAsync(x => x.OwnerId == ownerId) as List <ODMWorkspace>;

            //No workspace found for OwnerId
            if (workspaceLockup.Count == 0)
            {
                activeWorkspace = await CreateWorkspaceAsync(ownerId, new ModelPolicy());
            }
            else
            {
                //TODO: Add logic to handle multiple workspaces for same owner. for now only a single workspace for owner is supported.
                activeWorkspace = workspaceLockup[0];
            }

            filesBlobContainer  = new AzureBlobStorageRepository(blobStorageName, blobStorageKey, activeWorkspace.FilesCotainerUri);
            modelsBlobContainer = new AzureBlobStorageRepository(blobStorageName, blobStorageKey, activeWorkspace.ModelCotainerUri);

            return(activeWorkspace);
        }
        private async Task <ODMWorkspace> CreateWorkspaceAsync(string ownerId, ModelPolicy policy)
        {
            var newId = Guid.NewGuid().ToString();

            var result = new ODMWorkspace()
            {
                id               = newId,
                WorkspaceId      = newId,
                OwnerId          = ownerId,
                Policy           = new ModelPolicy(),
                CreationDate     = DateTime.UtcNow,
                IsActive         = true,
                ModelDefaultName = GlobalSettings.DefaultModelName,
                Files            = new List <TrainingFile>(),
                PartitionId      = GlobalSettings.DefaultPartitionId
            };

            result.FilesCotainerUri = $"{result.WorkspaceId}-files";
            result.ModelCotainerUri = $"{result.WorkspaceId}-models";

            await workspaceRepo.CreateItemAsync(result);

            return(result);
        }
 public async Task DeleteTrainingFile(ODMWorkspace workspace, TrainingFile file)
 {
     throw new NotImplementedException("Pending Implementation");
 }