mirror of
https://github.com/XFox111/MuiCharts.git
synced 2026-04-22 06:51:05 +03:00
- Added /Import endpoints
- Minor refactoring and improved validation
This commit is contained in:
@@ -138,6 +138,29 @@ public class TracksController(
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imports tracks.
|
||||
/// </summary>
|
||||
/// <param name="requests">The requests containing the track details.</param>
|
||||
/// <returns>An <see cref="IActionResult"/> representing the asynchronous operation result.</returns>
|
||||
[HttpPost("Import")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesDefaultResponseType(typeof(ProblemDetails))]
|
||||
public async Task<IActionResult> ImportTracksAsync(Track[] requests)
|
||||
{
|
||||
Logger.LogInformation("Importing tracks");
|
||||
|
||||
ErrorOr<IEnumerable<Track>> importResult = await _repository.AddTracksRangeAsync(requests);
|
||||
|
||||
if (importResult.IsError)
|
||||
return Problem(importResult.Errors);
|
||||
|
||||
Logger.LogInformation("Tracks imported");
|
||||
|
||||
return Ok(importResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a track with the specified first point ID and second point ID.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user