mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-01 16:34:17 +02:00
WIP: Manga can be linked to multiple Connectors
This commit is contained in:
37
API/Schema/Jobs/JobWithDownloading.cs
Normal file
37
API/Schema/Jobs/JobWithDownloading.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using API.Schema.MangaConnectors;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace API.Schema.Jobs;
|
||||
|
||||
public abstract class JobWithDownloading : Job
|
||||
{
|
||||
[StringLength(32)] [Required] public string MangaConnectorName { get; private set; } = null!;
|
||||
[JsonIgnore] private MangaConnector? _mangaConnector;
|
||||
[JsonIgnore]
|
||||
public MangaConnector MangaConnector
|
||||
{
|
||||
get => LazyLoader.Load(this, ref _mangaConnector) ?? throw new InvalidOperationException();
|
||||
init
|
||||
{
|
||||
MangaConnectorName = value.Name;
|
||||
_mangaConnector = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected JobWithDownloading(string jobId, JobType jobType, ulong recurrenceMs, MangaConnector mangaConnector, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||
: base(jobId, jobType, recurrenceMs, parentJob, dependsOnJobs)
|
||||
{
|
||||
this.MangaConnector = mangaConnector;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EF CORE ONLY!!!
|
||||
/// </summary>
|
||||
internal JobWithDownloading(ILazyLoader lazyLoader, string jobId, JobType jobType, ulong recurrenceMs, string mangaConnectorName, string? parentJobId)
|
||||
: base(lazyLoader, jobId, jobType, recurrenceMs, parentJobId)
|
||||
{
|
||||
this.MangaConnectorName = mangaConnectorName;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user