Пример #1
0
        public async Task ItUsesTheGovNotifyUrlEnvironmentVariable(string baseUrl)
        {
            SetupEnvironmentVariables(baseUrl, "cafe");

            var simulator = new FluentSimulator(baseUrl);

            simulator.Start();
            simulator.Post("/v2/notifications/email").Responds("{}");

            await _classUnderTest.SendUploadProcessedNotification(StubNotification(), CancellationToken.None);

            simulator.ReceivedRequests[0].Url.Should().Be($"{baseUrl}v2/notifications/email");
            simulator.Stop();
        }
        public async Task <IActionResult> Post(IList <IFormFile> files)
        {
            if (files == null || !EnumerableExtensions.Any(files))
            {
                return(BadRequest());
            }

            StringValues authorisationHeader = Request.Headers["Authorization"];
            string       email = GetEmailFromAuthorizationHeader(authorisationHeader);

            var request = await CreateSaveAssetRegisterFileRequest(files);

            await _backgroundProcessor.QueueBackgroundTask(
                async() =>
            {
                await _importAssetsUseCase.ExecuteAsync(request, _backgroundProcessor.GetCancellationToken()).ConfigureAwait(false);
                await _assetRegisterUploadProcessedNotifier.SendUploadProcessedNotification(
                    new UploadProcessedNotification
                {
                    Email = email,
                    UploadSuccessfullyProcessed = true
                },
                    _backgroundProcessor.GetCancellationToken());
            }
                );

            return(Ok());
        }