Example #1
0
        public async Task <string> UploadDocument(string clientId, string type, string fileName, string mime, byte[] data,
                                                  string changer)
        {
            var documentBeforeTask = _kycDocumentsRepository.GetAsync(clientId);
            var kycDocument        = await _kycDocumentsRepository.AddAsync(KycDocument.Create(clientId, type, mime, fileName));

            await _kycDocumentsScansRepository.AddDocument(kycDocument.DocumentId, data);

            await UpdateKycProfileSettings(clientId);

            var documentBefore = (await documentBeforeTask)?
                                 .OrderByDescending(x => x.DateTime)
                                 .FirstOrDefault(x => x.Type == type);

            await _auditLogRepository.AddAuditRecordAsync(clientId, documentBefore, kycDocument,
                                                          AuditRecordType.KycDocument, changer);

            return(kycDocument.DocumentId);
        }