Skip to content

Commit

Permalink
duplicate company certificate method removed
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuragNagpure committed Feb 14, 2024
1 parent 4a3f5d5 commit e3c0a24
Showing 1 changed file with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,45 +404,6 @@ private async Task HandleCompanyCertificateCreationAsync(CompanyCertificateTypeI
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}

/// <inheritdoc />
public async Task CreateCompanyCertificate(CompanyCertificateCreationData data, CancellationToken cancellationToken)
{
var documentContentType = data.Document.ContentType.ParseMediaTypeId();
documentContentType.CheckDocumentContentType(_settings.CompanyCertificateMediaTypes);

var companyCertificateRepository = _portalRepositories.GetInstance<ICompanyCertificateRepository>();
if (!await companyCertificateRepository.CheckCompanyCertificateType(data.CertificateType).ConfigureAwait(false))
{
throw new ControllerArgumentException($"{data.CertificateType} is not assigned to a certificate");
}

await HandleCompanyCertificateCreationAsync(data.CertificateType, data.Document, documentContentType, companyCertificateRepository, data.ExpiryDate, cancellationToken).ConfigureAwait(false);
}

private async Task HandleCompanyCertificateCreationAsync(CompanyCertificateTypeId companyCertificateTypeId,
IFormFile document,
MediaTypeId mediaTypeId,
ICompanyCertificateRepository companyCertificateRepository,
DateTimeOffset? expiryDate,
CancellationToken cancellationToken)
{
var (documentContent, hash) = await document.GetContentAndHash(cancellationToken).ConfigureAwait(false);
var doc = _portalRepositories.GetInstance<IDocumentRepository>().CreateDocument(document.FileName, documentContent,
hash, mediaTypeId, DocumentTypeId.COMPANY_CERTIFICATE, x =>
{
x.CompanyUserId = _identityData.IdentityId;
x.DocumentStatusId = DocumentStatusId.PENDING;
});

companyCertificateRepository.CreateCompanyCertificate(_identityData.CompanyId, companyCertificateTypeId, doc.Id,
x =>
{
x.ValidTill = expiryDate?.ToUniversalTime();
});

await _portalRepositories.SaveAsync().ConfigureAwait(false);
}

/// <inheritdoc />
public Task<Pagination.Response<CredentialDetailData>> GetCredentials(int page, int size, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, string? companyName, CompanySsiDetailSorting? sorting)
{
Expand Down

0 comments on commit e3c0a24

Please sign in to comment.