diff --git a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs index b308f11df..16d70a2cd 100644 --- a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs +++ b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs @@ -45,6 +45,7 @@ namespace ErsatzTV.Core.Scheduling { var collectionKeys = playout.ProgramSchedule.Items .Map(CollectionKeyForItem) + .Distinct() .ToList(); IEnumerable>> tuples = await collectionKeys.Map( diff --git a/ErsatzTV/Pages/TelevisionEpisodeList.razor b/ErsatzTV/Pages/TelevisionEpisodeList.razor index 7a2875388..74743c512 100644 --- a/ErsatzTV/Pages/TelevisionEpisodeList.razor +++ b/ErsatzTV/Pages/TelevisionEpisodeList.razor @@ -5,6 +5,8 @@ @using ErsatzTV.Application.MediaCards.Queries @using ErsatzTV.Application.MediaCollections @using ErsatzTV.Application.MediaCollections.Commands +@using ErsatzTV.Application.ProgramSchedules +@using ErsatzTV.Application.ProgramSchedules.Commands @inject IMediator Mediator @inject IDialogService Dialog @inject NavigationManager NavigationManager @@ -31,6 +33,13 @@ OnClick="@AddToCollection"> Add To Collection + + Add To Schedule + @@ -94,5 +103,20 @@ NavigationManager.NavigateTo($"/media/collections/{collection.Id}"); } } + + + private async Task AddToSchedule() + { + var parameters = new DialogParameters { { "EntityType", "season" }, { "EntityName", $"{_season.Title} - {_season.Plot}" } }; + var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; + + IDialogReference dialog = Dialog.Show("Add To Schedule", parameters, options); + DialogResult result = await dialog.Result; + if (!result.Cancelled && result.Data is ProgramScheduleViewModel schedule) + { + await Mediator.Send(new AddProgramScheduleItem(schedule.Id, StartType.Dynamic, null, PlayoutMode.One, ProgramScheduleItemCollectionType.TelevisionSeason, null, null, SeasonId, null, null, null)); + NavigationManager.NavigateTo($"/schedules/{schedule.Id}/items"); + } + } } \ No newline at end of file diff --git a/ErsatzTV/Pages/TelevisionSeasonList.razor b/ErsatzTV/Pages/TelevisionSeasonList.razor index b9fa4bdbe..e7b11e38b 100644 --- a/ErsatzTV/Pages/TelevisionSeasonList.razor +++ b/ErsatzTV/Pages/TelevisionSeasonList.razor @@ -5,6 +5,8 @@ @using ErsatzTV.Application.MediaCards.Queries @using ErsatzTV.Application.MediaCollections @using ErsatzTV.Application.MediaCollections.Commands +@using ErsatzTV.Application.ProgramSchedules +@using ErsatzTV.Application.ProgramSchedules.Commands @inject IMediator Mediator @inject IDialogService Dialog @inject NavigationManager NavigationManager @@ -31,6 +33,13 @@ OnClick="@AddToCollection"> Add To Collection + + Add To Schedule + @@ -91,4 +100,18 @@ } } + private async Task AddToSchedule() + { + var parameters = new DialogParameters { { "EntityType", "show" }, { "EntityName", _show.Title } }; + var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; + + IDialogReference dialog = Dialog.Show("Add To Schedule", parameters, options); + DialogResult result = await dialog.Result; + if (!result.Cancelled && result.Data is ProgramScheduleViewModel schedule) + { + await Mediator.Send(new AddProgramScheduleItem(schedule.Id, StartType.Dynamic, null, PlayoutMode.One, ProgramScheduleItemCollectionType.TelevisionShow, null, ShowId, null, null, null, null)); + NavigationManager.NavigateTo($"/schedules/{schedule.Id}/items"); + } + } + } \ No newline at end of file diff --git a/ErsatzTV/Shared/AddToScheduleDialog.razor b/ErsatzTV/Shared/AddToScheduleDialog.razor new file mode 100644 index 000000000..1468ccfed --- /dev/null +++ b/ErsatzTV/Shared/AddToScheduleDialog.razor @@ -0,0 +1,58 @@ +@using ErsatzTV.Application.ProgramSchedules +@using ErsatzTV.Application.ProgramSchedules.Queries +@inject IMediator Mediator + + + + + + + + @foreach (ProgramScheduleViewModel schedule in _schedules) + { + @schedule.Name + } + + + + Cancel + + Add To Schedule + + + + +@code { + + [CascadingParameter] + MudDialogInstance MudDialog { get; set; } + + [Parameter] + public string EntityType { get; set; } + + [Parameter] + public string EntityName { get; set; } + + [Parameter] + public string DetailText { get; set; } + + [Parameter] + public string DetailHighlight { get; set; } + + private List _schedules; + + private ProgramScheduleViewModel _selectedSchedule; + + protected override async Task OnParametersSetAsync() => + _schedules = await Mediator.Send(new GetAllProgramSchedules()); + + private string FormatText() => $"Select the schedule to add the {EntityType} {EntityName}"; + + private void Submit() => MudDialog.Close(DialogResult.Ok(_selectedSchedule)); + + private void Cancel() => MudDialog.Cancel(); + +} \ No newline at end of file