private async Task CreateSelfDeclarationDocuments(int enrolleeId, ICollection <SelfDeclaration> newDeclarations) { if (newDeclarations == null) { return; } foreach (var declaration in newDeclarations.Where(d => d.DocumentGuids != null)) { foreach (var documentGuid in declaration.DocumentGuids) { var filename = await _documentClient.FinalizeUploadAsync(documentGuid, "self_declarations"); if (string.IsNullOrWhiteSpace(filename)) { throw new InvalidOperationException($"Could not find a document upload with GUID {documentGuid}"); } _context.SelfDeclarationDocuments.Add(new SelfDeclarationDocument { EnrolleeId = enrolleeId, SelfDeclarationTypeCode = declaration.SelfDeclarationTypeCode, DocumentGuid = documentGuid, Filename = filename, UploadedDate = DateTimeOffset.Now }); } } }
public async Task <BusinessLicenceDocument> AddOrReplaceBusinessLicenceDocumentAsync(int businessLicenceId, Guid documentGuid) { var businessLicence = await _context.BusinessLicences .Include(bl => bl.BusinessLicenceDocument) .SingleOrDefaultAsync(bl => bl.Id == businessLicenceId); if (businessLicence.BusinessLicenceDocument != null) { _context.BusinessLicenceDocuments.Remove(businessLicence.BusinessLicenceDocument); } var filename = await _documentClient.FinalizeUploadAsync(documentGuid, "business_licences"); if (string.IsNullOrWhiteSpace(filename)) { return(null); } var bld = new BusinessLicenceDocument { DocumentGuid = documentGuid, Filename = filename, UploadedDate = DateTimeOffset.Now, BusinessLicenceId = businessLicence.Id }; _context.BusinessLicenceDocuments.Add(bld); await _context.SaveChangesAsync(); return(bld); }
public async Task <BusinessLicenceDocument> AddBusinessLicenceAsync(int siteId, Guid documentGuid) { var filename = await _documentClient.FinalizeUploadAsync(documentGuid, "business_licences"); if (string.IsNullOrWhiteSpace(filename)) { return(null); } var businessLicence = new BusinessLicenceDocument { DocumentGuid = documentGuid, SiteId = siteId, Filename = filename, UploadedDate = DateTimeOffset.Now }; _context.BusinessLicenceDocuments.Add(businessLicence); await _context.SaveChangesAsync(); return(businessLicence); }
public async Task <SignedAgreementDocument> AddSignedAgreementAsync(int organizationId, int agreementId, Guid documentGuid) { var filename = await _documentClient.FinalizeUploadAsync(documentGuid, "signed_org_agreements"); if (string.IsNullOrWhiteSpace(filename)) { return(null); } var signedAgreement = new SignedAgreementDocument { DocumentGuid = documentGuid, AgreementId = agreementId, Filename = filename, UploadedDate = DateTimeOffset.Now }; _context.SignedAgreementDocuments.Add(signedAgreement); await _context.SaveChangesAsync(); return(signedAgreement); }
public async Task <string> FinalizeDocumentUpload(Guid documentGuid, string filePath) { return(await _documentManagerClient.FinalizeUploadAsync(documentGuid, filePath)); }