@@ -7,19 +7,19 @@ namespace PostgresDBService
77 /// Provides file management operations backed by a PostgreSQL database using Entity Framework Core.
88 /// Implements methods to get files, delete files, get file details, search, and copy files.
99 /// </summary>
10- public class PostgresDocumentManager
10+ public class PostgresDocumentStorageService
1111 {
1212 private readonly DocumentContext _documentContext ;
1313
14- public PostgresDocumentManager ( DocumentContext context )
14+ public PostgresDocumentStorageService ( DocumentContext context )
1515 {
1616 _documentContext = context ;
1717 }
1818
1919 /// <summary>
2020 /// Retrieves all files in the database formatted for a file manager UI.
2121 /// </summary>
22- public async Task < object > GetFilesAsync ( )
22+ public async Task < object > GetDocumentsAsync ( )
2323 {
2424 var documents = await _documentContext . Documents . AsNoTracking ( )
2525 . Select ( d => new
@@ -56,72 +56,11 @@ public async Task<object> GetFilesAsync()
5656
5757 return response ;
5858 }
59-
60- /// <summary>
61- /// Deletes the specified files from the database.
62- /// </summary>
63- public async Task < object > DeleteAsync ( string path , string [ ] names , params FileManagerDirectoryContent [ ] data )
64- {
65- if ( data == null || data . Length == 0 )
66- {
67- return new
68- {
69- cwd = ( object ) null ,
70- details = ( object ) null ,
71- error = new { message = "No files to delete." } ,
72- files = new List < object > ( )
73- } ;
74- }
75-
76- var idsToDelete = data
77- . Where ( d => ! string . IsNullOrEmpty ( d . Id ) )
78- . Select ( d => d . Id )
79- . ToList ( ) ;
80-
81- var documents = await _documentContext . Documents
82- . Where ( d => idsToDelete . Contains ( d . Id . ToString ( ) ) )
83- . ToListAsync ( ) ;
84-
85- if ( documents . Count == 0 )
86- {
87- return new
88- {
89- cwd = ( object ) null ,
90- details = ( object ) null ,
91- error = new { message = "No matching files found." } ,
92- files = new List < object > ( )
93- } ;
94- }
95-
96- _documentContext . Documents . RemoveRange ( documents ) ;
97- await _documentContext . SaveChangesAsync ( ) ;
98-
99- // Prepare Syncfusion-style response
100- var deletedFiles = data . Select ( d => new
101- {
102- name = d . Name ,
103- size = d . Size ,
104- dateCreated = d . DateCreated ,
105- dateModified = d . DateModified ,
106- hasChild = d . HasChild ,
107- isFile = d . IsFile ,
108- type = d . Type ,
109- filterPath = d . FilterPath
110- } ) ;
111-
112- return new
113- {
114- cwd = ( object ) null ,
115- details = ( object ) null ,
116- error = ( object ) null ,
117- files = deletedFiles
118- } ;
119- }
120-
59+
12160 /// <summary>
12261 /// Retrieves file details for the specified document.
12362 /// </summary>
124- public async Task < object > GetDetailsAsync ( string path , string [ ] names , FileManagerDirectoryContent [ ] data )
63+ public async Task < object > GetDocumentDetailsAsync ( string path , string [ ] names , FileManagerDirectoryContent [ ] data )
12564 {
12665 if ( data ? . Length == 0 )
12766 {
@@ -184,6 +123,67 @@ public async Task<object> GetDetailsAsync(string path, string[] names, FileManag
184123 } ;
185124 }
186125
126+ /// <summary>
127+ /// Deletes the specified files from the database.
128+ /// </summary>
129+ public async Task < object > DeleteAsync ( string path , string [ ] names , params FileManagerDirectoryContent [ ] data )
130+ {
131+ if ( data == null || data . Length == 0 )
132+ {
133+ return new
134+ {
135+ cwd = ( object ) null ,
136+ details = ( object ) null ,
137+ error = new { message = "No files to delete." } ,
138+ files = new List < object > ( )
139+ } ;
140+ }
141+
142+ var idsToDelete = data
143+ . Where ( d => ! string . IsNullOrEmpty ( d . Id ) )
144+ . Select ( d => d . Id )
145+ . ToList ( ) ;
146+
147+ var documents = await _documentContext . Documents
148+ . Where ( d => idsToDelete . Contains ( d . Id . ToString ( ) ) )
149+ . ToListAsync ( ) ;
150+
151+ if ( documents . Count == 0 )
152+ {
153+ return new
154+ {
155+ cwd = ( object ) null ,
156+ details = ( object ) null ,
157+ error = new { message = "No matching files found." } ,
158+ files = new List < object > ( )
159+ } ;
160+ }
161+
162+ _documentContext . Documents . RemoveRange ( documents ) ;
163+ await _documentContext . SaveChangesAsync ( ) ;
164+
165+ // Prepare Syncfusion-style response
166+ var deletedFiles = data . Select ( d => new
167+ {
168+ name = d . Name ,
169+ size = d . Size ,
170+ dateCreated = d . DateCreated ,
171+ dateModified = d . DateModified ,
172+ hasChild = d . HasChild ,
173+ isFile = d . IsFile ,
174+ type = d . Type ,
175+ filterPath = d . FilterPath
176+ } ) ;
177+
178+ return new
179+ {
180+ cwd = ( object ) null ,
181+ details = ( object ) null ,
182+ error = ( object ) null ,
183+ files = deletedFiles
184+ } ;
185+ }
186+
187187 /// <summary>
188188 /// Searches documents by name.
189189 /// </summary>
0 commit comments