diff --git a/src/EPR.Calculator.API.UnitTests/Services/TransposePomAndOrgDataServiceTests.cs b/src/EPR.Calculator.API.UnitTests/Services/TransposePomAndOrgDataServiceTests.cs index 35102b9..bf2b449 100644 --- a/src/EPR.Calculator.API.UnitTests/Services/TransposePomAndOrgDataServiceTests.cs +++ b/src/EPR.Calculator.API.UnitTests/Services/TransposePomAndOrgDataServiceTests.cs @@ -1,4 +1,5 @@ using EPR.Calculator.API.Data.DataModels; +using EPR.Calculator.API.Dtos; using EPR.Calculator.API.Services; using EPR.Calculator.API.Tests.Controllers; using EPR.Calculator.API.Wrapper; @@ -38,7 +39,9 @@ public void Transpose_Should_Return_Correct_Producer_Detail() #pragma warning disable CS8604 // Possible null reference argument. var service = new TransposePomAndOrgDataService(dbContext); #pragma warning restore CS8604 // Possible null reference argument. - service.Transpose(3); + + var resultsRequestDto = new CalcResultsRequestDto { RunId = 3 }; + service.Transpose(resultsRequestDto); var producerDetail = dbContext.ProducerDetail.FirstOrDefault(); Assert.IsNotNull(producerDetail); @@ -78,7 +81,9 @@ public void Transpose_Should_Return_Correct_Producer_Reported_Material() #pragma warning disable CS8604 // Possible null reference argument. var service = new TransposePomAndOrgDataService(dbContext); #pragma warning restore CS8604 // Possible null reference argument. - service.Transpose(3); + + var resultsRequestDto = new CalcResultsRequestDto { RunId = 3 }; + service.Transpose(resultsRequestDto); var producerReportedMaterial = dbContext.ProducerReportedMaterial.FirstOrDefault(); Assert.IsNotNull(producerReportedMaterial); diff --git a/src/EPR.Calculator.API/Controllers/CalculatorInternalController.cs b/src/EPR.Calculator.API/Controllers/CalculatorInternalController.cs index 4e27e7e..a668183 100644 --- a/src/EPR.Calculator.API/Controllers/CalculatorInternalController.cs +++ b/src/EPR.Calculator.API/Controllers/CalculatorInternalController.cs @@ -150,7 +150,7 @@ public IActionResult UpdateRpdStatus([FromBody] UpdateRpdStatus request) [Route("prepareCalcResults")] public IActionResult PrepareCalcResults([FromBody] CalcResultsRequestDto resultsRequestDto) { - this.transposePomAndOrgDataService.Transpose(resultsRequestDto.RunId); + this.transposePomAndOrgDataService.Transpose(resultsRequestDto); var results = this.builder.Build(resultsRequestDto); this.exporter.Export(results); return new ObjectResult(null) { StatusCode = StatusCodes.Status201Created }; diff --git a/src/EPR.Calculator.API/Services/ITransposePomAndOrgDataService.cs b/src/EPR.Calculator.API/Services/ITransposePomAndOrgDataService.cs index 7fe9a71..26651c5 100644 --- a/src/EPR.Calculator.API/Services/ITransposePomAndOrgDataService.cs +++ b/src/EPR.Calculator.API/Services/ITransposePomAndOrgDataService.cs @@ -1,7 +1,9 @@ -namespace EPR.Calculator.API.Services +using EPR.Calculator.API.Dtos; + +namespace EPR.Calculator.API.Services { public interface ITransposePomAndOrgDataService { - public void Transpose(int runId); + public void Transpose(CalcResultsRequestDto resultsRequestDto); } } diff --git a/src/EPR.Calculator.API/Services/TransposePomAndOrgDataService.cs b/src/EPR.Calculator.API/Services/TransposePomAndOrgDataService.cs index 0cee492..a5874f2 100644 --- a/src/EPR.Calculator.API/Services/TransposePomAndOrgDataService.cs +++ b/src/EPR.Calculator.API/Services/TransposePomAndOrgDataService.cs @@ -1,6 +1,6 @@ using EPR.Calculator.API.Data; using EPR.Calculator.API.Data.DataModels; -using EPR.Calculator.API.Wrapper; +using EPR.Calculator.API.Dtos; namespace EPR.Calculator.API.Services { @@ -14,11 +14,11 @@ public TransposePomAndOrgDataService(ApplicationDBContext context) this.context = context; } - public void Transpose(int runId) + public void Transpose(CalcResultsRequestDto resultsRequestDto) { var materials = this.context.Material.ToList(); - var calculatorRun = this.context.CalculatorRuns.Single(cr => cr.Id == runId); + var calculatorRun = this.context.CalculatorRuns.Single(cr => cr.Id == resultsRequestDto.RunId); if (calculatorRun.CalculatorRunPomDataMasterId != null) { @@ -48,7 +48,7 @@ public void Transpose(int runId) { var producerDetail = new ProducerDetail { - CalculatorRunId = runId, + CalculatorRunId = resultsRequestDto.RunId, ProducerId = pom.OrganisationId.Value, SubsidiaryId = pom.SubsidaryId, ProducerName = producerName,