private async Task SaveDocumentsAsync(string projectId, string branchName, Stream stream)
        {
            var    stringBuilder = new StringBuilder();
            string pathToFile    = GetTempFilePath();

            stringBuilder.AppendLine($"[{DateTime.UtcNow}] Saving documentation ({projectId}/{branchName}) to file: {pathToFile}.");
            SaveDocumentsToTempFile(pathToFile, stream);
            stringBuilder.AppendLine($"[{DateTime.UtcNow}] Documentation saved ({projectId}/{branchName}) to file: {pathToFile}.");

            stringBuilder.AppendLine($"[{DateTime.UtcNow}] Enqueueing uploading documentation job ({projectId}/{branchName}/{pathToFile}).");
            BackgroundJob.Enqueue <IUploaderJob>(x => x.UploadBranchAsync(projectId, branchName, pathToFile));
            stringBuilder.AppendLine($"[{DateTime.UtcNow}] Uploading docuumentation job enqueued ({projectId}/{branchName}/{pathToFile}).");

            await _logsService.DeleteLogsAsync(projectId);

            await _logsService.AppendLogsAsync(projectId, new LogsDto { Message = stringBuilder.ToString() });
        }
Example #2
0
        public async Task <IActionResult> Delete(string projectId)
        {
            var projectFromStorage = await _projectsService.GetProjectAsync(projectId);

            if (projectFromStorage == null)
            {
                return(NotFound());
            }

            var authorization = await _authorizationService.AuthorizeAsync(User, projectFromStorage, Operations.Update);

            if (!authorization.Succeeded)
            {
                return(Forbid());
            }

            await _logsService.DeleteLogsAsync(projectId);

            return(Ok());
        }