Skip to content

Commit de113af

Browse files
committed
POST /folder/edit added
1 parent 686d71b commit de113af

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

JMMServer/API/APIv2_core_Module.cs

+47-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using JMMServer.Repositories;
1414
using System.Linq;
1515
using Newtonsoft.Json;
16-
using System.Dynamic;
1716
using System.IO;
1817

1918
namespace JMMServer.API
@@ -34,6 +33,7 @@ public APIv2_core_Module() : base("/api")
3433
Get["/folder/list"] = x => { return GetFolders(); };
3534
Get["/folder/count"] = x => { return CountFolders(); };
3635
Post["/folder/add"] = x => { return AddFolder(); };
36+
Post["/folder/edit"] = x => { return EditFolder(); };
3737
Post["/folder/delete"] = x => { return DeleteFolder(); };
3838
Get["/folder/import"] = _ => { return RunImport(); };
3939
Get["/cloud/list"] = x => { return null; };
@@ -206,6 +206,52 @@ private object AddFolder()
206206
}
207207
}
208208

209+
/// <summary>
210+
/// Edit folder giving fulll ImportFolder object with ID
211+
/// </summary>
212+
/// <returns></returns>
213+
private object EditFolder()
214+
{
215+
ImportFolder folder = this.Bind();
216+
if (folder.ImportFolderLocation != "")
217+
{
218+
try
219+
{
220+
if (folder.IsDropDestination == 1 && folder.IsDropSource == 1)
221+
{
222+
return HttpStatusCode.Conflict;
223+
}
224+
else
225+
{
226+
if (folder.ImportFolderID != 0 & folder.ToContract().ImportFolderID.HasValue)
227+
{
228+
Contract_ImportFolder_SaveResponse response = new JMMServiceImplementation().SaveImportFolder(folder.ToContract());
229+
if (!string.IsNullOrEmpty(response.ErrorMessage))
230+
{
231+
return HttpStatusCode.InternalServerError;
232+
}
233+
else
234+
{
235+
return HttpStatusCode.OK;
236+
}
237+
}
238+
else
239+
{
240+
return HttpStatusCode.Conflict;
241+
}
242+
}
243+
}
244+
catch
245+
{
246+
return HttpStatusCode.InternalServerError;
247+
}
248+
}
249+
else
250+
{
251+
return HttpStatusCode.BadRequest;
252+
}
253+
}
254+
209255
/// <summary>
210256
/// Delete Import Folder out of Import Folder Repository
211257
/// </summary>

0 commit comments

Comments
 (0)