Skip to content

Commit

Permalink
Merge branch 'main' into feature/187381-csv-export-by-month-view
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Api/Dfe.Complete.Api.Client/Generated/Contracts.g.cs
#	src/Api/Dfe.Complete.Api.Client/Generated/swagger.json
#	src/Core/Dfe.Complete.Domain/Entities/SignificantDateHistory.cs
#	src/Tests/Dfe.Complete.Domain.Tests/Aggregates/ProjectTests.cs
#	src/Tests/Dfe.Complete.Tests.Common/Customizations/Models/UserCustomization.cs
#	src/Tests/Dfe.Complete.Tests/Dfe.Complete.Tests.csproj
  • Loading branch information
Sukhvinder Bhullar authored and Sukhvinder Bhullar committed Feb 3, 2025
2 parents 64350a9 + 29545b8 commit 562a4b0
Show file tree
Hide file tree
Showing 76 changed files with 3,978 additions and 545 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Continuous Integration / Terraform

on:
push:
branches: [ main ]
paths:
- 'terraform/**.tf'
pull_request:
paths:
- 'terraform/**.tf'

jobs:
terraform-validate:
name: Validate
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Check for terraform version mismatch
run: |
DOTFILE_VERSION=$(cat terraform/.terraform-version)
TERRAFORM_IMAGE_REFERENCES=$(grep "uses: docker://hashicorp/terraform" .github/workflows/continuous-integration-terraform.yml | grep -v TERRAFORM_IMAGE_REFERENCES | wc -l | tr -d ' ')
if [ "$(grep "docker://hashicorp/terraform:${DOTFILE_VERSION}" .github/workflows/continuous-integration-terraform.yml | wc -l | tr -d ' ')" != "$TERRAFORM_IMAGE_REFERENCES" ]
then
echo -e "\033[1;31mError: terraform version in .terraform-version file does not match docker://hashicorp/terraform versions in .github/workflows/continuous-integration-terraform.yml"
exit 1
fi
- name: Validate Terraform docs
uses: terraform-docs/[email protected]
with:
working-dir: terraform
config-file: .terraform-docs.yml
output-file: README.md
output-method: inject
fail-on-diff: true

- name: Remove azure backend
run: rm ./terraform/backend.tf

- name: Run a Terraform init
uses: docker://hashicorp/terraform:1.9.8
with:
entrypoint: terraform
args: -chdir=terraform init

- name: Run a Terraform validate
uses: docker://hashicorp/terraform:1.9.8
with:
entrypoint: terraform
args: -chdir=terraform validate

- name: Run a Terraform format check
uses: docker://hashicorp/terraform:1.9.8
with:
entrypoint: terraform
args: -chdir=terraform fmt -check=true -diff=true

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.44.1

- name: Run TFLint
working-directory: terraform
run: tflint -f compact

- name: Run TFSec
uses: aquasecurity/[email protected]
with:
github_token: ${{ github.token }}
77 changes: 39 additions & 38 deletions src/Api/Dfe.Complete.Api.Client/Generated/Contracts.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public partial class ProjectDto
public Urn? AcademyUrn { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("tasksDataId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? TasksDataId { get; set; } = default!;
public TaskDataId? TasksDataId { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("tasksDataType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
Expand Down Expand Up @@ -370,7 +370,8 @@ public partial class ProjectDto
public string? NewTrustName { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("state", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int? State { get; set; } = default!;
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public ProjectState? State { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("prepareId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int? PrepareId { get; set; } = default!;
Expand Down Expand Up @@ -477,6 +478,27 @@ public enum Region

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class TaskDataId
{
[Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? Value { get; set; } = default!;

public string ToJson()
{

return Newtonsoft.Json.JsonConvert.SerializeObject(this, new Newtonsoft.Json.JsonSerializerSettings());

}
public static TaskDataId FromJson(string data)
{

return Newtonsoft.Json.JsonConvert.DeserializeObject<TaskDataId>(data, new Newtonsoft.Json.JsonSerializerSettings());

}

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum TaskType
{
Expand Down Expand Up @@ -555,6 +577,21 @@ public static ContactId FromJson(string data)

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum ProjectState
{

[System.Runtime.Serialization.EnumMember(Value = @"Active")]
Active = 0,

[System.Runtime.Serialization.EnumMember(Value = @"Completed")]
Completed = 1,

[System.Runtime.Serialization.EnumMember(Value = @"Cancelled")]
Cancelled = 2,

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ProjectGroupId
{
Expand Down Expand Up @@ -880,42 +917,6 @@ public static Project FromJson(string data)

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class TaskDataId
{
[Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? Value { get; set; } = default!;

public string ToJson()
{

return Newtonsoft.Json.JsonConvert.SerializeObject(this, new Newtonsoft.Json.JsonSerializerSettings());

}
public static TaskDataId FromJson(string data)
{

return Newtonsoft.Json.JsonConvert.DeserializeObject<TaskDataId>(data, new Newtonsoft.Json.JsonSerializerSettings());

}

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum ProjectState
{

[System.Runtime.Serialization.EnumMember(Value = @"Active")]
Active = 0,

[System.Runtime.Serialization.EnumMember(Value = @"Completed")]
Completed = 1,

[System.Runtime.Serialization.EnumMember(Value = @"Cancelled")]
Cancelled = 2,

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class Contact
{
Expand Down
60 changes: 31 additions & 29 deletions src/Api/Dfe.Complete.Api.Client/Generated/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,12 @@
]
},
"tasksDataId": {
"type": "string",
"format": "guid",
"nullable": true
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/TaskDataId"
}
]
},
"tasksDataType": {
"nullable": true,
Expand Down Expand Up @@ -605,8 +608,7 @@
"nullable": true
},
"state": {
"type": "integer",
"format": "int32"
"$ref": "#/components/schemas/ProjectState"
},
"prepareId": {
"type": "integer",
Expand Down Expand Up @@ -715,6 +717,16 @@
"SouthWest"
]
},
"TaskDataId": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": {
"type": "string",
"format": "guid"
}
}
},
"TaskType": {
"type": "string",
"description": "",
Expand Down Expand Up @@ -771,6 +783,20 @@
}
}
},
"ProjectState": {
"type": "string",
"description": "",
"x-enumNames": [
"Active",
"Completed",
"Cancelled"
],
"enum": [
"Active",
"Completed",
"Cancelled"
]
},
"ProjectGroupId": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -1229,30 +1255,6 @@
}
]
},
"TaskDataId": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": {
"type": "string",
"format": "guid"
}
}
},
"ProjectState": {
"type": "string",
"description": "",
"x-enumNames": [
"Active",
"Completed",
"Cancelled"
],
"enum": [
"Active",
"Completed",
"Cancelled"
]
},
"Contact": {
"type": "object",
"additionalProperties": false,
Expand Down
1 change: 0 additions & 1 deletion src/Api/Dfe.Complete.Api/Controllers/ProjectsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Dfe.Complete.Application.Projects.Commands.CreateProject;
using Dfe.Complete.Application.Projects.Model;
using Dfe.Complete.Application.Projects.Queries.CountAllProjects;
using Dfe.Complete.Domain.Entities;
using Dfe.Complete.Application.Projects.Queries.GetProject;
using Dfe.Complete.Application.Projects.Queries.ListAllProjects;
using Dfe.Complete.Application.Projects.Models;
Expand Down
1 change: 1 addition & 0 deletions src/Core/Dfe.Complete.Application/Mappers/AutoMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public AutoMapping()
{
CreateMap<Project, ProjectDto>();
CreateMap<ProjectGroup, ProjectGroupDto>();
CreateMap<User, UserDto>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Dfe.Complete.Domain.Interfaces.Repositories;
using Dfe.Complete.Domain.Entities;
using Dfe.Complete.Utils;
using Dfe.Complete.Application.Projects.Queries.GetProject;
using Dfe.Complete.Application.Projects.Queries.GetUser;

namespace Dfe.Complete.Application.Projects.Commands.CreateProject
{
Expand All @@ -26,16 +28,22 @@ public record CreateConversionProjectCommand(
public class CreateConversionProjectCommandHandler(
ICompleteRepository<Project> projectRepository,
ICompleteRepository<ConversionTasksData> conversionTaskRepository,
ICompleteRepository<ProjectGroup> projectGroupRepository,
ICompleteRepository<User> userRepository)
ISender sender)
: IRequestHandler<CreateConversionProjectCommand, ProjectId>
{
public async Task<ProjectId> Handle(CreateConversionProjectCommand request, CancellationToken cancellationToken)
{
// The user Team should be moved as a Claim or Group to the Entra (MS AD)
var projectUser = await GetUserByAdId(request.UserAdId);
var userRequest = await sender.Send(new GetUserByAdIdQuery(request.UserAdId), cancellationToken);

var projectUserTeam = projectUser.Team;
if (!userRequest.IsSuccess)
{
throw new Exception($"User retrieval failed: {userRequest.Error}");
}

var projectUser = userRequest.Value;

var projectUserTeam = projectUser?.Team;
var projectUserId = projectUser?.Id;

var projectTeam = EnumExtensions.FromDescription<ProjectTeam>(projectUserTeam);
Expand All @@ -47,7 +55,14 @@ public async Task<ProjectId> Handle(CreateConversionProjectCommand request, Canc

var conversionTask = new ConversionTasksData(new TaskDataId(conversionTaskId), createdAt, createdAt);

var groupId = await GetProjectGroupIdByIdentifierAsync(request.GroupReferenceNumber);
var projectGroupRequest = await sender.Send(new GetProjectGroupByGroupReferenceNumberQuery(request.GroupReferenceNumber), cancellationToken);

if (!projectGroupRequest.IsSuccess)
{
throw new Exception($"Project Group retrieval failed: {projectGroupRequest.Error}");
}

var groupId = projectGroupRequest.Value?.Id;

ProjectTeam team;
DateTime? assignedAt = null;
Expand Down Expand Up @@ -94,9 +109,5 @@ public async Task<ProjectId> Handle(CreateConversionProjectCommand request, Canc

return project.Id;
}

private async Task<User> GetUserByAdId(string? userAdId) => await userRepository.FindAsync(x => x.ActiveDirectoryUserId == userAdId);

private async Task<ProjectGroupId> GetProjectGroupIdByIdentifierAsync(string groupReferenceNumber) => (await projectGroupRepository.FindAsync(x => x.GroupIdentifier == groupReferenceNumber)).Id;
}
}
Loading

0 comments on commit 562a4b0

Please sign in to comment.