Exemple #1
0
        public async Task GetLatestJobByUkprnAndContractReference_Success()
        {
            IContainer    container = Registrations();
            FileUploadJob result;

            using (var scope = container.BeginLifetimeScope())
            {
                // Create the schema in the database
                var options = scope.Resolve <DbContextOptions <JobQueueDataContext> >();
                using (var context = new JobQueueDataContext(options))
                {
                    context.Database.EnsureCreated();
                }

                IFileUploadJobManager manager = scope.Resolve <IFileUploadJobManager>();

                await manager.AddJob(new FileUploadJob()
                {
                    JobId          = 1,
                    Ukprn          = 10000116,
                    PeriodNumber   = 1,
                    FileName       = "10000116/SUPPDATA-10000116-ESF-2270-20181109-090919.csv",
                    CollectionName = "ESF"
                });

                await manager.AddJob(new FileUploadJob()
                {
                    JobId          = 2,
                    Ukprn          = 10000116,
                    PeriodNumber   = 2,
                    FileName       = "10000116/SUPPDATA-10000116-ESF-99999-20181109-090919.csv",
                    CollectionName = "ESF"
                });

                await manager.AddJob(new FileUploadJob()
                {
                    JobId          = 3,
                    Ukprn          = 10000119,
                    PeriodNumber   = 2,
                    FileName       = "10000119/SUPPDATA-10000119-ESF-2270-20181109-090919.csv",
                    CollectionName = "ESF"
                });

                result = await manager.GetLatestJobByUkprnAndContractReference(10000116, "ESF-2270", "ESF");
            }

            result.Should().NotBeNull();
            result.FileName.Should().Be("10000116/SUPPDATA-10000116-ESF-2270-20181109-090919.csv");
            result.Ukprn.Should().Be(10000116);
            result.JobId.Should().Be(1);
        }
Exemple #2
0
        public IActionResult GetLatestJob(long ukprn, string contractReference, string collectionName)
        {
            _logger.LogInfo($"Request received to get the with ukprn: {ukprn}, contract reference: {contractReference}, collection name :{collectionName}");

            if (ukprn == 0 || string.IsNullOrEmpty(collectionName) || string.IsNullOrEmpty(contractReference))
            {
                _logger.LogWarning($"Request received with ukprn {ukprn}, contract reference: {contractReference}, collection name :{collectionName}, returning bad request");
                return(BadRequest());
            }

            var job = _fileUploadJobManager.GetLatestJobByUkprnAndContractReference(ukprn, contractReference, collectionName);

            _logger.LogInfo($"Returning job successfully for ukprn :{ukprn}, contract reference: {contractReference}, collection name :{collectionName}");
            return(Ok(job));
        }