Skip to content

Commit

Permalink
Prosp advance setting and auto selected assets (#799)
Browse files Browse the repository at this point in the history
* Prosp advance setting and auto selected assets
  • Loading branch information
ahmedoabdi authored Oct 24, 2022
1 parent 77749b6 commit 3f106ab
Show file tree
Hide file tree
Showing 18 changed files with 2,033 additions and 139 deletions.
3 changes: 2 additions & 1 deletion backend/api/Adapters/CaseAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static Case Convert(CaseDto caseDto)
WaterInjectorCount = caseDto.WaterInjectorCount,
FacilitiesAvailability = caseDto.FacilitiesAvailability,
SharepointFileId = caseDto.SharepointFileId,
SharepointFileName = caseDto.SharepointFileName
SharepointFileName = caseDto.SharepointFileName,
SharepointFileUrl = caseDto.SharepointFileUrl,
};
}

Expand Down
4 changes: 4 additions & 0 deletions backend/api/Adapters/CaseDtoAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static CaseDto Convert(Case case_)
FacilitiesAvailability = case_.FacilitiesAvailability,
SharepointFileId = case_.SharepointFileId,
SharepointFileName = case_.SharepointFileName,
SharepointFileUrl = case_.SharepointFileUrl,
};

return caseDto;
Expand All @@ -52,6 +53,7 @@ public static CessationCostDto Convert(CessationCost? opexCost)
{
return null!;
}

return new CessationCostDto
{
Id = opexCost.Id,
Expand All @@ -68,6 +70,7 @@ public static OpexCostProfileDto Convert(OpexCostProfile? opexCost)
{
return null!;
}

return new OpexCostProfileDto
{
Id = opexCost.Id,
Expand All @@ -84,6 +87,7 @@ public static StudyCostProfileDto Convert(StudyCostProfile? studyCost)
{
return null!;
}

return new StudyCostProfileDto
{
Id = studyCost.Id,
Expand Down
49 changes: 4 additions & 45 deletions backend/api/Controllers/PROSPController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using api.Dtos;
using api.Models;
using api.Services;

using Api.Authorization;
Expand All @@ -14,11 +13,10 @@ namespace api.Controllers;
[ApiController]
[Authorize]
[RequiresApplicationRoles(
ApplicationRole.Admin,
ApplicationRole.ReadOnly,
ApplicationRole.User
)]
ApplicationRole.Admin,
ApplicationRole.ReadOnly,
ApplicationRole.User
)]
public class PROSPController : ControllerBase
{
private const string isCheckedAsset = "true";
Expand Down Expand Up @@ -74,45 +72,6 @@ public List<DriveItemDto> GetSharePointFileNamesAndId([FromBody] urlDto dto)
}
}

[HttpPost("local", Name = "Upload")]
[DisableRequestSizeLimit]
public async Task<ProjectDto?> Upload([FromQuery] Guid projectId, [FromQuery] Guid sourceCaseId)
{
try
{
var formCollection = await Request.ReadFormAsync();
var file = formCollection.Files.First();
var assets = new Dictionary<string, bool>
{
{ nameof(Surf), false },
{ nameof(Topside), false },
{ nameof(Substructure), false },
{ nameof(Transport), false }
};

if (file.Length > 0)
{
foreach (var item in assets)
{
if (formCollection.TryGetValue(nameof(item.Key), out var asset) && asset == isCheckedAsset)
{
assets[nameof(asset)] = true;
}
}

var dto = _prospExcelImportService.ImportProsp(file, sourceCaseId, projectId, assets);
return dto;
}

return null;
}
catch (Exception e)
{
_logger.LogError(e.Message);
return _projectService.GetProjectDto(projectId);
}
}

public class urlDto
{
public string? url { get; set; }
Expand Down
15 changes: 12 additions & 3 deletions backend/api/Dtos/CaseDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ public class CaseDto
public CessationCostDto? CessationCost { get; set; }
public string? SharepointFileId { get; set; }
public string? SharepointFileName { get; set; }
public string? SharepointFileUrl { get; set; }
}

public class CessationCostDto : TimeSeriesCostDto { }
public class OpexCostProfileDto : TimeSeriesCostDto { }
public class StudyCostProfileDto : TimeSeriesCostDto { }
public class CessationCostDto : TimeSeriesCostDto
{
}

public class OpexCostProfileDto : TimeSeriesCostDto
{
}

public class StudyCostProfileDto : TimeSeriesCostDto
{
}

public class CapexYear
{
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Dtos/DriveItemDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class DriveItemDto
{
public string? Name { get; set; }
public string? Id { get; set; }
public string? WebUrl { get; set; }
public string? SharepointFileUrl { get; set; }
public DateTimeOffset? CreatedDateTime { get; set; }
public Stream? Content { get; set; }
public Int64? Size { get; set; }
Expand Down
1 change: 0 additions & 1 deletion backend/api/Dtos/SharePointImportDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class SharePointImportDto
public bool Substructure { get; set; }
public bool Topside { get; set; }
public bool Transport { get; set; }
public string SharePointFileName { get; set; } = null!;
public string SharePointFileId { get; set; } = null!;
public string? SharePointSiteUrl { get; set; }
}
Loading

0 comments on commit 3f106ab

Please sign in to comment.