public ActionResult AddFolder(ImportFolder folder) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (folder.ImportFolderLocation != string.Empty) { try { // TODO Do this correctly without calling APIv1 CL_Response <ImportFolder> response = new ShokoServiceImplementation().SaveImportFolder(folder); if (string.IsNullOrEmpty(response.ErrorMessage)) { return(APIStatus.OK()); } return(new APIMessage(500, response.ErrorMessage)); } catch { return(APIStatus.InternalError()); } } return(new APIMessage(400, "Bad Request: The Folder path must not be Empty")); }
public ActionResult EditFolder(ImportFolder folder) { if (!String.IsNullOrEmpty(folder.ImportFolderLocation) && folder.ImportFolderID != 0) { try { // TODO Do this correctly without calling APIv1 if (folder.IsDropDestination == 1 && folder.IsDropSource == 1) { return(new APIMessage(409, "The Import Folder can't be both Destination and Source")); } if (folder.ImportFolderID == 0) { return(new APIMessage(409, "The Import Folder must have an ID")); } CL_Response <ImportFolder> response = new ShokoServiceImplementation().SaveImportFolder(folder); if (!string.IsNullOrEmpty(response.ErrorMessage)) { return(new APIMessage(500, response.ErrorMessage)); } return(APIStatus.OK()); } catch { return(APIStatus.InternalError()); } } return(new APIMessage(400, "ImportFolderLocation and ImportFolderID missing")); }
public ActionResult EditFolder(ImportFolder folder) { if (String.IsNullOrEmpty(folder.ImportFolderLocation) || folder.ImportFolderID == 0) { return(new APIMessage(400, "ImportFolderLocation and ImportFolderID missing")); } if (folder.IsDropDestination == 1 && folder.IsDropSource == 1) { return(new APIMessage(StatusCodes.Status409Conflict, "The Import Folder can't be both Destination and Source")); } if (folder.ImportFolderID == 0) { return(new APIMessage(StatusCodes.Status409Conflict, "The Import Folder must have an ID")); } try { RepoFactory.ImportFolder.SaveImportFolder(folder); return(Ok()); } catch (Exception e) { return(APIStatus.InternalError(e.Message)); } }
public ActionResult PatchImportFolder(int id, [FromBody] JsonPatchDocument <ImportFolder> folder) { if (folder == null) { return(BadRequest("object is invalid.")); } var existing = RepoFactory.ImportFolder.GetByID(id); if (existing == null) { return(BadRequest("No Import Folder with ID")); } var patchModel = new ImportFolder(existing); folder.ApplyTo(patchModel, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var serverModel = patchModel.GetServerModel(); RepoFactory.ImportFolder.SaveImportFolder(serverModel); return(Ok()); }
public ActionResult <ImportFolder> AddFolder(ImportFolder folder) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (folder.ImportFolderLocation == string.Empty) { return(new APIMessage(StatusCodes.Status400BadRequest, "Bad Request: The Folder path must not be Empty")); } try { return(RepoFactory.ImportFolder.SaveImportFolder(folder)); } catch (Exception e) { return(APIStatus.InternalError(e.Message)); } }
public ActionResult EditFolder(ImportFolder folder) { if (string.IsNullOrEmpty(folder.Path)) { return(BadRequest("Path missing. Import Folders must be a location that exists on the server")); } if (folder.ID == 0) { return(BadRequest("ID missing. If this is a new Folder, then use POST")); } try { RepoFactory.ImportFolder.SaveImportFolder(folder.GetServerModel()); return(Ok()); } catch (Exception e) { return(InternalError(e.Message)); } }
public ActionResult <ImportFolder> AddFolder(ImportFolder folder) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (folder.Path == string.Empty) { return(BadRequest("The Folder path must not be Empty")); } try { Shoko.Models.Server.ImportFolder import = folder.GetServerModel(); var newFolder = RepoFactory.ImportFolder.SaveImportFolder(import); return(new ImportFolder(newFolder)); } catch (Exception e) { return(InternalError(e.Message)); } }