Beispiel #1
0
        public async Task <SigningRequest> CreateSigningRequestAsync(SigningRequest signingRequest)
        {
            var signingRequestTableEntity = _mapper.Map <SigningRequestTableEntity>(signingRequest);

            var table = await GetTableReferenceAsync();

            await table.ExecuteAsync(TableOperation.Insert(signingRequestTableEntity));

            return(signingRequest);
        }
Beispiel #2
0
        public async Task <SigningRequestResult> CreateSigningRequestAsync(DocumentCreate document)
        {
            // TODO: Validate document
            var template = await _templateRepository.GetTemplateAsync(document.TemplateId);

            var signingRequest = new SigningRequest()
            {
                Id              = Guid.NewGuid().ToString(),
                TemplateId      = template.Id,
                TemplateVersion = template.Version,
                InputValues     = document.InputValues,
                Signatories     = _documentExportsFactory
                                  .Create(template, document.InputValues)
                                  .ListSignatories()
                                  .Select(s => s.Id)
            };

            await _signingRequestRepository.CreateSigningRequestAsync(signingRequest);

            var signingKeysDecodedByEmail = signingRequest.Signatories.ToDictionary(
                email => email,
                email => new SigningKey()
            {
                SignatoryEmail   = email,
                SigningRequestId = signingRequest.Id
            });

            var signingUrlsByEmail = signingKeysDecodedByEmail.ToDictionary(
                kvp => kvp.Key,
                kvp => $"{_hostOptions.Signing}/{_signingKeyEncoder.Encode(kvp.Value)}?v=1");

            await _signingNotifier.NotifyAsync(signingUrlsByEmail);

            return(new SigningRequestResult()
            {
                Type = _signingNotifier.NotificationTypeId,
                TypeData = signingUrlsByEmail
            });
        }