public EnvelopeSummary SignThroughEmail(DocusignSigningInfo signingInfo)
        {
            try
            {
                this.DocusignAuthenticator.Authenticate(ApiClient);

                // var templatesApi = new TemplatesApi(ApiClient.Configuration);
                var envelopeApi = new EnvelopesApi(ApiClient.Configuration);

                var envelopeDefinition = this.CreateEnvelopeFromTemplate(signingInfo.EnvelopeTemplate, signingInfo.Customer);

                // This will send the document to the signer through email. We will use the webhook to detect when it was signed.
                var result = envelopeApi.CreateEnvelope(this.AccountId, envelopeDefinition);
                return(result);
            }
            catch (Exception e)
            {
                this.Logger.LogError(e.Message);
                throw;
            }
        }
        public ViewUrl SignThroughEmbedding(HttpRequest httpRequest, DocusignSigningInfo signingInfo)
        {
            try
            {
                this.DocusignAuthenticator.Authenticate(ApiClient);

                var envelopeApi        = new EnvelopesApi(ApiClient.Configuration);
                var envelopeDefinition = this.CreateEnvelopeFromTemplate(signingInfo.EnvelopeTemplate, signingInfo.Customer);
                var envelope           = envelopeApi.CreateEnvelope(this.AccountId, envelopeDefinition);

                var viewRequest = this.MakeRecipientViewRequest(httpRequest, signingInfo.Customer, envelope.EnvelopeId);

                // This will send the document to the signer through browser embedding. We will use the webhook to detect when it was signed.
                var result = envelopeApi.CreateRecipientView(this.AccountId, envelope.EnvelopeId, viewRequest);

                return(result);
            }
            catch (Exception e)
            {
                this.Logger.LogError(e.Message);
                throw;
            }
        }
        public IActionResult EmbeddedSigning(DocusignSigningInfo signingInfo)
        {
            var result = this.DocusignService.SignThroughEmbedding(this.Request, signingInfo);

            return(this.Redirect(result.Url));
        }
        public IActionResult Send(DocusignSigningInfo signingInfo)
        {
            var result = this.DocusignService.SignThroughEmail(signingInfo);

            return(View("DocumentSendResult", result));
        }