64 lines
2.8 KiB
C#
64 lines
2.8 KiB
C#
using Modules.Library.Domain.Gateways;
|
|
using Modules.Library.Domain.Entities.MediaContent.Items.Anime;
|
|
|
|
namespace Modules.Library.Application.Services.MediaContent;
|
|
|
|
public class AnimeSeasonService(IAnimeTitleGateway titleGateway)
|
|
{
|
|
// public async Task AddEpisode(Guid titleId, Guid seasonId, AnimeEpisodeType episodeType)
|
|
// {
|
|
// await StructureAction(titleId, seasonId, (title, season) =>
|
|
// {
|
|
// var lastOrder = season.Items.OrderByDescending(q => q.Order).FirstOrDefault()?.Order;
|
|
// var episode = AnimeEpisode.New(episodeType);
|
|
// season.AddItem(episode);
|
|
// episode.SetOrder(lastOrder.HasValue ? lastOrder.Value + 1 : 0);
|
|
// episode.SetNumber(season.Items.OfType<AnimeEpisode>().Select(q => q.Number).DefaultIfEmpty(0).Max() + 1);
|
|
// });
|
|
// }
|
|
|
|
// public async Task AddEpisodeAsVariant(Guid titleId, Guid seasonId, AnimeEpisodeType episodeType, uint order)
|
|
// {
|
|
// await StructureAction(titleId, seasonId, (title, season) =>
|
|
// {
|
|
// var lastVariant = season.Items.OrderByDescending(q => q.Variant).FirstOrDefault(q => q.Order == order)?.Variant ??
|
|
// throw new Exception($"Could not find episode with order [{order}]");
|
|
// var episode = AnimeEpisode.New(episodeType);
|
|
// season.AddItem(episode);
|
|
// episode.SetOrder(order);
|
|
// episode.SetVariant(lastVariant + 1);
|
|
// episode.SetNumber(season.Items.Where(q => q.Order == order).OfType<AnimeEpisode>().Select(q => q.Number).FirstOrDefault() ?? 0);
|
|
// });
|
|
// }
|
|
|
|
// public async Task RemoveEpisode(Guid titleId, Guid seasonId, Guid episodeId)
|
|
// {
|
|
// await StructureAction(titleId, seasonId, (title, season) =>
|
|
// {
|
|
// var episode = season.Items.OrderByDescending(q => q.Variant).FirstOrDefault(q => q.Id == episodeId) ??
|
|
// throw new Exception($"Could not find episode with Id [{episodeId}]");
|
|
// //season.RemoveItem(episode);
|
|
// episode.SetDeleted();
|
|
// });
|
|
// }
|
|
|
|
// private async Task StructureAction(Guid titleId, Guid seasonId, Action<AnimeTitle, AnimeSeason> action)
|
|
// {
|
|
// var title = await titleGateway.GetById(titleId);
|
|
// var season = await seasonRepository.GetById(seasonId);
|
|
// action.Invoke(title, season);
|
|
// season.CheckIfCompleted();
|
|
// title.CheckIfCompleted();
|
|
// }
|
|
|
|
|
|
|
|
// public async Task Edit(Guid seasonId, int? number, string? director, string? originCountry, TimeSpan? expirationTime)
|
|
// {
|
|
// var season = await seasonRepository.GetById(seasonId);
|
|
// season.SetNumber(number);
|
|
// season.SetDirector(director);
|
|
// season.SetOriginCountry(originCountry);
|
|
// season.SetExpirationTime(expirationTime ?? TimeSpan.Zero);
|
|
// }
|
|
} |