Skip to content

Commit

Permalink
Generate profiles when saving
Browse files Browse the repository at this point in the history
- Generate profiles on save for profiles affected by updated assets

This solves AB#709
  • Loading branch information
taustad committed Feb 15, 2023
1 parent da1d520 commit fe7a011
Show file tree
Hide file tree
Showing 23 changed files with 552 additions and 158 deletions.
2 changes: 1 addition & 1 deletion backend/api/Controllers/CaseWithAssetsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public CaseWithAssetsController(ICaseWithAssetsService caseWithAssetsService)
}

[HttpPut(Name = "UpdateCaseWithAssets")]
public async Task<ActionResult<ProjectDto>> UpdateCaseWithAssetsAsync([FromBody] CaseWithAssetsWrapperDto caseWrapperDto)
public async Task<ActionResult<ProjectWithGeneratedProfilesDto>> UpdateCaseWithAssetsAsync([FromBody] CaseWithAssetsWrapperDto caseWrapperDto)
{
var dto = await _caseWithAssetsService.UpdateCaseWithAssetsAsync(caseWrapperDto);
return Ok(dto);
Expand Down
24 changes: 20 additions & 4 deletions backend/api/Controllers/GenerateProfileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ public GenerateProfileController(IGenerateGAndGAdminCostProfile generateGAndGAdm
}

[HttpPost("{caseId}/generateGAndGAdminCost", Name = "GenerateGAndGAdminCost")]
public GAndGAdminCostDto GenerateGAndGAdminCost(Guid caseId)
public async Task<ActionResult<GAndGAdminCostDto>> GenerateGAndGAdminCostAsync(Guid caseId)
{
return _generateGAndGAdminCostProfile.Generate(caseId);
try
{
var dto = await _generateGAndGAdminCostProfile.GenerateAsync(caseId);
return Ok(dto);
}
catch (NotFoundInDBException)
{
return NotFound();
}
}

[HttpPost("{caseId}/generateOpex", Name = "GenerateOpex")]
Expand Down Expand Up @@ -121,9 +129,17 @@ public async Task<ActionResult<NetSalesGasDto>> GenerateNetSaleGasAsync(Guid cas
}

[HttpPost("{caseId}/generateFuelFlaringLosses", Name = "GenerateFuelFlaringLosses")]
public FuelFlaringAndLossesDto GenerateFuelFlaringLosses(Guid caseId)
public async Task<ActionResult<FuelFlaringAndLossesDto>> GenerateFuelFlaringLossesAsync(Guid caseId)
{
return _generateFuelFlaringLossessProfile.Generate(caseId);
try
{
var dto = await _generateFuelFlaringLossessProfile.GenerateAsync(caseId);
return Ok(dto);
}
catch (NotFoundInDBException)
{
return NotFound();
}
}

[HttpPost("{caseId}/generateCo2Emissions", Name = "GenerateCo2Emissions")]
Expand Down
9 changes: 9 additions & 0 deletions backend/api/Dtos/ProjectWithGeneratedProfilesDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using static api.Services.CaseWithAssetsService;

namespace api.Dtos;

public class ProjectWithGeneratedProfilesDto
{
public ProjectDto ProjectDto { get; set; } = null!;
public GeneratedProfilesDto GeneratedProfilesDto { get; set; } = null!;
}
12 changes: 12 additions & 0 deletions backend/api/Dtos/STEACaseDtoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,18 @@ private static void AddExploration(ProjectDto p, STEACaseDto sTEACaseDto, CaseDt
{
costProfileDtos.Add(exploration.SidetrackCostProfile);
}
if (exploration.GAndGAdminCost?.Values.Length > 0)
{
costProfileDtos.Add(exploration.GAndGAdminCost);
}
if (exploration.SeismicAcquisitionAndProcessing?.Values.Length > 0)
{
costProfileDtos.Add(exploration.SeismicAcquisitionAndProcessing);
}
if (exploration.CountryOfficeCost?.Values.Length > 0)
{
costProfileDtos.Add(exploration.CountryOfficeCost);
}

var costProfile = TimeSeriesCostDto.MergeCostProfilesList(costProfileDtos);

Expand Down
Loading

0 comments on commit fe7a011

Please sign in to comment.