@@ -8,6 +8,7 @@ namespace DocuSign.CodeExamples.ESignature.Controllers
88 using DocuSign . CodeExamples . Common ;
99 using DocuSign . CodeExamples . Controllers ;
1010 using DocuSign . CodeExamples . Models ;
11+ using DocuSign . eSign . Model ;
1112 using Microsoft . AspNetCore . Mvc ;
1213 using Newtonsoft . Json ;
1314
@@ -17,7 +18,7 @@ public class DeleteRestoreEnvelope : EgController
1718 {
1819 private const string DeleteFolderId = "recyclebin" ;
1920
20- private const string RestoreFolderId = "sentitems " ;
21+ private const string SentItemsFolderName = "Sent Items " ;
2122
2223 public DeleteRestoreEnvelope ( DsConfiguration config , LauncherTexts launcherTexts , IRequestItemsService requestItemsService )
2324 : base ( config , launcherTexts , requestItemsService )
@@ -61,9 +62,11 @@ public IActionResult DeleteEnvelopeAction(string envelopeId)
6162 this . ViewBag . h1 = this . CodeExampleText . ExampleName ;
6263 this . ViewBag . ConfirmAdditionalLink = nameof ( this . GetRestoreEnvelope ) ;
6364 this . ViewBag . OnlyConfirmAdditionalLink = true ;
64- this . ViewBag . message = this . CodeExampleText . AdditionalPages
65- . FirstOrDefault ( x => x . Name . Equals ( "envelope_is_deleted" ) )
66- ? . ResultsPageText ;
65+ this . ViewBag . message = string . Format (
66+ this . CodeExampleText . AdditionalPages
67+ . FirstOrDefault ( x => x . Name . Equals ( "envelope_is_deleted" ) )
68+ ? . ResultsPageText ,
69+ envelopeId ) ;
6770
6871 return this . View ( "example_done" ) ;
6972 }
@@ -75,9 +78,10 @@ public IActionResult DeleteEnvelopeAction(string envelopeId)
7578 [ HttpPost ]
7679 [ Route ( "RestoreEnvelopeAction" ) ]
7780 [ SetViewBag ]
78- public IActionResult RestoreEnvelopeAction ( )
81+ public IActionResult RestoreEnvelopeAction ( string folderName )
7982 {
8083 bool tokenOk = this . CheckToken ( 3 ) ;
84+ folderName = folderName ?? SentItemsFolderName ;
8185
8286 if ( ! tokenOk )
8387 {
@@ -89,16 +93,38 @@ public IActionResult RestoreEnvelopeAction()
8993 string accessToken = this . RequestItemsService . User . AccessToken ;
9094 string accountId = this . RequestItemsService . Session . AccountId ;
9195
96+ FoldersResponse availableFolders = global ::ESignature . Examples . DeleteRestoreEnvelope . GetFolders (
97+ accessToken ,
98+ basePath ,
99+ accountId ) ;
100+ Folder folder = global ::ESignature . Examples . DeleteRestoreEnvelope . GetFolderIdByName (
101+ availableFolders . Folders ,
102+ folderName ) ;
103+
104+ if ( folder == null )
105+ {
106+ this . ViewBag . h1 = this . CodeExampleText . ExampleName ;
107+ this . ViewBag . message = string . Format ( this . CodeExampleText . AdditionalPages [ 1 ] . ResultsPageText , folderName ) ;
108+ this . ViewBag . ConfirmAdditionalLink = nameof ( this . GetRestoreEnvelope ) ;
109+ this . ViewBag . OnlyConfirmAdditionalLink = true ;
110+
111+ return this . View ( "example_done" ) ;
112+ }
113+
92114 global ::ESignature . Examples . DeleteRestoreEnvelope . MoveEnvelopeToFolder (
93115 accessToken ,
94116 basePath ,
95117 accountId ,
96118 this . RequestItemsService . EnvelopeId ,
97- RestoreFolderId ,
119+ folder . FolderId ,
98120 DeleteFolderId ) ;
99121
100122 this . ViewBag . h1 = this . CodeExampleText . ExampleName ;
101- this . ViewBag . message = this . CodeExampleText . ResultsPageText ;
123+ this . ViewBag . message = string . Format (
124+ this . CodeExampleText . ResultsPageText ,
125+ this . RequestItemsService . EnvelopeId ,
126+ folder . Type ,
127+ folderName ) ;
102128
103129 return this . View ( "example_done" ) ;
104130 }
0 commit comments