mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-30 07:54:16 +02:00
MetadataFetching:
- Jikan (MAL) linking, fetching/updating
This commit is contained in:
38
API/Schema/MetadataFetchers/MetadataFetcher.cs
Normal file
38
API/Schema/MetadataFetchers/MetadataFetcher.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using API.Schema.Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Schema.MetadataFetchers;
|
||||
|
||||
[PrimaryKey("MetadataFetcherName")]
|
||||
public abstract class MetadataFetcher
|
||||
{
|
||||
// ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
|
||||
public string MetadataFetcherName { get; init; }
|
||||
|
||||
protected MetadataFetcher()
|
||||
{
|
||||
this.MetadataFetcherName = this.GetType().Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EFCORE ONLY!!!
|
||||
/// </summary>
|
||||
internal MetadataFetcher(string metadataFetcherName)
|
||||
{
|
||||
this.MetadataFetcherName = metadataFetcherName;
|
||||
}
|
||||
|
||||
public abstract MetadataEntry? FindLinkedMetadataEntry(Manga manga);
|
||||
|
||||
public bool TryGetMetadataEntry(Manga manga, [NotNullWhen(true)] out MetadataEntry? metadataEntry)
|
||||
{
|
||||
metadataEntry = FindLinkedMetadataEntry(manga);
|
||||
return metadataEntry != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the Manga linked in the MetadataEntry
|
||||
/// </summary>
|
||||
public abstract void UpdateMetadata(MetadataEntry metadataEntry, PgsqlContext dbContext);
|
||||
}
|
Reference in New Issue
Block a user