Added playlist repository logic.
This commit is contained in:
22
Harmonia.Core/Data/PlaylistRepository.cs
Normal file
22
Harmonia.Core/Data/PlaylistRepository.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Harmonia.Core.Models;
|
||||
|
||||
namespace Harmonia.Core.Data;
|
||||
|
||||
public class PlaylistRepository : JsonFileRepository<Playlist>
|
||||
{
|
||||
protected override string DirectoryName => string.Empty;
|
||||
|
||||
protected override string GetNewFileName()
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
string shortFileName = $"Playlist{i.ToString().PadLeft(3, '0')}.{Extension}";
|
||||
string filePath = Path.Combine(DirectoryName, shortFileName);
|
||||
|
||||
if (File.Exists(filePath) == false)
|
||||
return shortFileName;
|
||||
}
|
||||
|
||||
throw new Exception("Unable to determine new fileName");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user