82 lines
3.6 KiB
C#
82 lines
3.6 KiB
C#
using Modules.Library.Domain.Entities;
|
|
using Modules.Library.Domain.Entities.MediaContent.CommonProperties;
|
|
using Modules.Library.Domain.Entities.MediaContent.Items.Anime;
|
|
using Modules.Library.Domain.Gateways;
|
|
using Modules.Library.Domain.Interactors.MediaContent.Anime.Title;
|
|
|
|
namespace Modules.Library.Domain.Interactors.MediaContent.Anime.Season;
|
|
|
|
public class CreateInteractor : InteractorBase
|
|
{
|
|
private readonly IAnimeTitleGateway _gateway;
|
|
|
|
public CreateInteractor(IAnimeTitleGateway gateway, ILanguageGateway languageGateway, IGenreGateway genreGateway) : base(gateway, languageGateway, genreGateway)
|
|
{
|
|
this._gateway = gateway;
|
|
}
|
|
|
|
public async Task<Guid> Create(Guid animeTitleId, string nameOriginal, Guid nameOriginalLanguageId)
|
|
{
|
|
var title = await GetTitle(animeTitleId);
|
|
var season = new AnimeSeason(nameOriginal, nameOriginalLanguageId);
|
|
title.Items.Add(season);
|
|
await _gateway.UpdateAsync(title);
|
|
return season.Id;
|
|
}
|
|
|
|
public async Task AddName(Guid animeTitleId, Guid? animeSeasonId, NameType nameType, Guid languageId, string value)
|
|
{
|
|
var title = await GetTitle(animeTitleId);
|
|
await _commonPropertiesService.AddName(title, animeSeasonId, null, nameType, languageId, value);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
internal async Task AddDescription(Guid animeTitleId, Guid? animeSeasonId, Guid languageId, bool isOriginal, string value)
|
|
{
|
|
var title = await GetTitle(animeTitleId);
|
|
await _commonPropertiesService.AddDescription(title, animeSeasonId, null, languageId, isOriginal, value);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
internal async Task AddRelatedContent(Guid animeTitleId, Guid animeSeasonId, string url, MediaInfoType type)
|
|
{
|
|
var title = await GetTitle(animeTitleId);
|
|
CommonPropertiesService.AddRelatedContent(title, animeSeasonId, null, url, type);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
internal async Task AddGenreProportionToAnimeTitle(Guid animeTitleId, Guid genreId, decimal? proportion)
|
|
{
|
|
var title = await GetTitle(animeTitleId);
|
|
await _commonPropertiesService.AddGenre(title, null, null, genreId, proportion);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
|
|
internal async Task SetAnnouncementDate(Guid animeTitleId, Guid animeSeasonId, DateTimeOffset value)
|
|
{
|
|
var title = await _gateway.GetByIdAsync(animeTitleId);
|
|
CommonPropertiesService.SetAnnouncementDate(title, animeSeasonId, null, value);
|
|
var season = title.Items.OfType<AnimeSeason>().First(q => q.Id == animeSeasonId);
|
|
OnStructureActionCompleted(title, season);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
internal async Task SetEstimatedReleaseDate(Guid animeTitleId, Guid animeSeasonId, DateTimeOffset value)
|
|
{
|
|
var title = await _gateway.GetByIdAsync(animeTitleId);
|
|
CommonPropertiesService.SetEstimatedReleaseDate(title, animeSeasonId, null, value);
|
|
var season = title.Items.OfType<AnimeSeason>().First(q => q.Id == animeSeasonId);
|
|
OnStructureActionCompleted(title, season);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
|
|
internal async Task SetReleaseDate(Guid animeTitleId, Guid animeSeasonId, DateTimeOffset value)
|
|
{
|
|
var title = await _gateway.GetByIdAsync(animeTitleId);
|
|
CommonPropertiesService.SetReleaseDate(title, animeSeasonId, null, value);
|
|
var season = title.Items.OfType<AnimeSeason>().First(q => q.Id == animeSeasonId);
|
|
OnStructureActionCompleted(title, season);
|
|
await _gateway.UpdateAsync(title);
|
|
}
|
|
} |