Compare commits

..

No commits in common. "9521f66bac8b09a7a6191e12519585c3ce1d1e9b" and "cef3b24efdbab9a4060dbef936fd737da8871a36" have entirely different histories.

3 changed files with 10 additions and 50 deletions

View File

@ -1,13 +1,3 @@
namespace API.APIEndpointRecords;
public record NewLibraryRecord(string path, string name)
{
public bool Validate()
{
if (path.Length < 1) //TODO Better Path validation
return false;
if (name.Length < 1)
return false;
return true;
}
}
public record NewLibraryRecord(string path, string name);

View File

@ -29,33 +29,6 @@ public class LocalLibrariesController(PgsqlContext context) : Controller
return Ok(library);
}
[HttpPatch("{LibraryId}")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status400BadRequest)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult UpdateLocalLibrary(string LibraryId, [FromBody]NewLibraryRecord record)
{
LocalLibrary? library = context.LocalLibraries.Find(LibraryId);
if (library is null)
return NotFound();
if (record.Validate() == false)
return BadRequest();
try
{
library.LibraryName = record.name;
library.BasePath = record.path;
context.SaveChanges();
return Ok();
}
catch (Exception e)
{
return StatusCode(500, e.Message);
}
}
[HttpPatch("{LibraryId}/ChangeBasePath")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
@ -112,12 +85,9 @@ public class LocalLibrariesController(PgsqlContext context) : Controller
[HttpPut]
[ProducesResponseType<LocalLibrary>(Status200OK, "application/json")]
[ProducesResponseType(Status400BadRequest)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateNewLibrary([FromBody]NewLibraryRecord library)
public IActionResult CreateNewLibrary([FromBody] NewLibraryRecord library)
{
if (library.Validate() == false)
return BadRequest();
try
{
LocalLibrary newLibrary = new (library.path, library.name);

View File

@ -1,8 +1,8 @@
using API.MangaDownloadClients;
using System.Text.Json.Nodes;
using API.MangaDownloadClients;
using API.Schema;
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using static Microsoft.AspNetCore.Http.StatusCodes;
namespace API.Controllers;
@ -17,10 +17,10 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<JObject>(Status200OK, "application/json")]
[ProducesResponseType<string>(StatusCodes.Status200OK, "application/json")]
public IActionResult GetSettings()
{
return Ok(JObject.Parse(TrangaSettings.Serialize()));
return Ok(TrangaSettings.Serialize());
}
/// <summary>
@ -142,9 +142,9 @@ public class SettingsController(PgsqlContext context) : Controller
[HttpPatch("ImageCompression")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status400BadRequest)]
public IActionResult SetImageCompression([FromBody]int level)
public IActionResult SetImageCompression(int level)
{
if (level < 1 || level > 100)
if (level < 0 || level > 100)
return BadRequest();
TrangaSettings.UpdateCompressImages(level);
return Ok();
@ -168,7 +168,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// <response code="200"></response>
[HttpPatch("BWImages")]
[ProducesResponseType(Status200OK)]
public IActionResult SetBwImagesToggle([FromBody]bool enabled)
public IActionResult SetBwImagesToggle(bool enabled)
{
TrangaSettings.UpdateBwImages(enabled);
return Ok();
@ -194,7 +194,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// <response code="200"></response>
[HttpPatch("AprilFoolsMode")]
[ProducesResponseType(Status200OK)]
public IActionResult SetAprilFoolsMode([FromBody]bool enabled)
public IActionResult SetAprilFoolsMode(bool enabled)
{
TrangaSettings.UpdateAprilFoolsMode(enabled);
return Ok();