Skip to content

Commit

Permalink
Prettier agreement edit (#543)
Browse files Browse the repository at this point in the history
Co-authored-by: Magnus Dahl <[email protected]>
Co-authored-by: md <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent a189537 commit ceb5b6e
Show file tree
Hide file tree
Showing 19 changed files with 1,438 additions and 587 deletions.
21 changes: 14 additions & 7 deletions backend/Api/Agreements/AgreementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public async Task<ActionResult<AgreementReadModel>> GetAgreement([FromRoute] str
Files: agreement.Files.Select(f => new FileReferenceReadModel(
FileName: f.FileName,
BlobName: f.BlobName,
UploadedOn: f.UploadedOn
UploadedOn: f.UploadedOn,
UploadedBy: f.UploadedBy ?? "Unknown"
)).ToList()
);
return Ok(responseModel);
Expand Down Expand Up @@ -79,7 +80,8 @@ public async Task<ActionResult<List<AgreementReadModel>>> GetAgreementsByEngagem
Files: agreement.Files.Select(f => new FileReferenceReadModel(
FileName: f.FileName,
BlobName: f.BlobName,
UploadedOn: f.UploadedOn
UploadedOn: f.UploadedOn,
UploadedBy: f.UploadedBy ?? "Unknown"
)).ToList()
)).ToList();

Expand Down Expand Up @@ -113,7 +115,8 @@ public async Task<ActionResult<List<AgreementReadModel>>> GetAgreementsByCustome
Files: agreement.Files.Select(f => new FileReferenceReadModel(
FileName: f.FileName,
BlobName: f.BlobName,
UploadedOn: f.UploadedOn
UploadedOn: f.UploadedOn,
UploadedBy: f.UploadedBy ?? "Unknown"
)).ToList()
)).ToList();

Expand Down Expand Up @@ -174,7 +177,8 @@ public async Task<ActionResult<AgreementReadModel>> Post([FromRoute] string orgU
{
FileName = f.FileName,
BlobName = f.BlobName,
UploadedOn = f.UploadedOn
UploadedOn = f.UploadedOn,
UploadedBy = f.UploadedBy ?? "Unknown"
}).ToList()
};

Expand All @@ -195,7 +199,8 @@ public async Task<ActionResult<AgreementReadModel>> Post([FromRoute] string orgU
Files: agreement.Files.Select(f => new FileReferenceReadModel(
FileName: f.FileName,
BlobName: f.BlobName,
UploadedOn: f.UploadedOn
UploadedOn: f.UploadedOn,
UploadedBy: f.UploadedBy ?? "Unknown"
)).ToList()
);
cache.Remove($"consultantCacheKey/{orgUrlKey}");
Expand Down Expand Up @@ -271,7 +276,8 @@ public async Task<ActionResult<AgreementReadModel>> Put([FromRoute] string orgUr
{
FileName = f.FileName,
BlobName = f.BlobName,
UploadedOn = f.UploadedOn
UploadedOn = f.UploadedOn,
UploadedBy = f.UploadedBy ?? "Unknown"
}).ToList();

await agreementsRepository.UpdateAgreementAsync(agreement, ct);
Expand All @@ -291,7 +297,8 @@ public async Task<ActionResult<AgreementReadModel>> Put([FromRoute] string orgUr
Files: agreement.Files.Select(f => new FileReferenceReadModel(
FileName: f.FileName,
BlobName: f.BlobName,
UploadedOn: f.UploadedOn
UploadedOn: f.UploadedOn,
UploadedBy: f.UploadedBy ?? "Unknown"
)).ToList()
);

Expand Down
9 changes: 5 additions & 4 deletions backend/Api/Agreements/AgreementModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ List<FileReferenceReadModel> Files
public record FileReferenceReadModel(
string FileName,
string BlobName,
DateTime UploadedOn
DateTime UploadedOn,
string? UploadedBy
);

public record AgreementWriteModel(
Expand All @@ -34,7 +35,7 @@ public record AgreementWriteModel(
string? Options,
string? PriceAdjustmentProcess,
List<FileReferenceWriteModel> Files
): IValidatableObject
) : IValidatableObject
{
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
Expand All @@ -51,6 +52,6 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
public record FileReferenceWriteModel(
string FileName,
string BlobName,
DateTime UploadedOn
DateTime UploadedOn,
string? UploadedBy
);

36 changes: 19 additions & 17 deletions backend/Core/Agreements/Agreement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,36 @@
namespace Core.Agreements
{
public class Agreement
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string? Name { get; set; } = string.Empty;
public int? CustomerId { get; set; }
public Customer? Customer { get; set; }
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string? Name { get; set; } = string.Empty;
public int? CustomerId { get; set; }
public Customer? Customer { get; set; }

public int? EngagementId { get; set; }
public Engagement? Engagement { get; set; }
public int? EngagementId { get; set; }
public Engagement? Engagement { get; set; }

public ICollection<FileReference> Files { get; set; } = new List<FileReference>();
public ICollection<FileReference> Files { get; set; } = new List<FileReference>();

public DateTime? StartDate { get; set; }
public required DateTime EndDate { get; set; }
public DateTime? StartDate { get; set; }
public required DateTime EndDate { get; set; }

public DateTime? NextPriceAdjustmentDate { get; set; }
public DateTime? NextPriceAdjustmentDate { get; set; }

public string? PriceAdjustmentIndex { get; set; }
public string? Notes { get; set; } = string.Empty;
public string? Options { get; set; } = string.Empty;
public string? PriceAdjustmentProcess { get; set; } = string.Empty;
}
public string? PriceAdjustmentIndex { get; set; }
public string? Notes { get; set; } = string.Empty;
public string? Options { get; set; } = string.Empty;
public string? PriceAdjustmentProcess { get; set; } = string.Empty;
}


public class FileReference
{
public string FileName { get; set; } = string.Empty;
public string BlobName { get; set; } = string.Empty; // URI to the blob storage
public DateTime UploadedOn { get; set; }

public string? UploadedBy { get; set; } = string.Empty;
}
}
Loading

0 comments on commit ceb5b6e

Please sign in to comment.