mirror of https://github.com/ErsatzTV/ErsatzTV.git
8 changed files with 228 additions and 60 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
namespace ErsatzTV.Core.Domain.Scheduling; |
||||
|
||||
public class DecoBreakContent |
||||
{ |
||||
public int Id { get; set; } |
||||
public int DecoId { get; set; } |
||||
public Deco Deco { get; set; } |
||||
public ProgramScheduleItemCollectionType CollectionType { get; set; } |
||||
public int? CollectionId { get; set; } |
||||
public Collection Collection { get; set; } |
||||
public int? MediaItemId { get; set; } |
||||
public MediaItem MediaItem { get; set; } |
||||
public int? MultiCollectionId { get; set; } |
||||
public MultiCollection MultiCollection { get; set; } |
||||
public int? SmartCollectionId { get; set; } |
||||
public SmartCollection SmartCollection { get; set; } |
||||
public DecoBreakPlacement Placement { get; set; } |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
namespace ErsatzTV.Core.Domain.Scheduling; |
||||
|
||||
[Flags] |
||||
public enum DecoBreakPlacement |
||||
{ |
||||
BlockStart, |
||||
BlockFinish, |
||||
BetweenBlockItems, |
||||
ChapterMarkers |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
using ErsatzTV.Core.Domain.Scheduling; |
||||
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
||||
namespace ErsatzTV.Infrastructure.Data.Configurations.Scheduling; |
||||
|
||||
public class DecoBreakContentConfiguration : IEntityTypeConfiguration<DecoBreakContent> |
||||
{ |
||||
public void Configure(EntityTypeBuilder<DecoBreakContent> builder) |
||||
{ |
||||
builder.ToTable("DecoBreakContent"); |
||||
|
||||
builder.HasOne(d => d.Collection) |
||||
.WithMany() |
||||
.HasForeignKey(d => d.CollectionId) |
||||
.OnDelete(DeleteBehavior.Cascade) |
||||
.IsRequired(false); |
||||
|
||||
builder.HasOne(d => d.MediaItem) |
||||
.WithMany() |
||||
.HasForeignKey(d => d.MediaItemId) |
||||
.OnDelete(DeleteBehavior.Cascade) |
||||
.IsRequired(false); |
||||
|
||||
builder.HasOne(d => d.MultiCollection) |
||||
.WithMany() |
||||
.HasForeignKey(d => d.MultiCollectionId) |
||||
.OnDelete(DeleteBehavior.Cascade) |
||||
.IsRequired(false); |
||||
|
||||
builder.HasOne(d => d.SmartCollection) |
||||
.WithMany() |
||||
.HasForeignKey(d => d.SmartCollectionId) |
||||
.OnDelete(DeleteBehavior.Cascade) |
||||
.IsRequired(false); |
||||
} |
||||
} |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
using System.ComponentModel; |
||||
using System.Runtime.CompilerServices; |
||||
using ErsatzTV.Application.MediaCollections; |
||||
using ErsatzTV.Application.MediaItems; |
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.ViewModels; |
||||
|
||||
public class DecoBreakContentEditViewModel : INotifyPropertyChanged |
||||
{ |
||||
private ProgramScheduleItemCollectionType _collectionType; |
||||
|
||||
public int Id { get; set; } |
||||
public int Index { get; set; } |
||||
|
||||
public ProgramScheduleItemCollectionType CollectionType |
||||
{ |
||||
get => _collectionType; |
||||
set |
||||
{ |
||||
if (_collectionType != value) |
||||
{ |
||||
_collectionType = value; |
||||
|
||||
Collection = null; |
||||
MultiCollection = null; |
||||
MediaItem = null; |
||||
SmartCollection = null; |
||||
|
||||
OnPropertyChanged(nameof(Collection)); |
||||
OnPropertyChanged(nameof(MultiCollection)); |
||||
OnPropertyChanged(nameof(MediaItem)); |
||||
OnPropertyChanged(nameof(SmartCollection)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public MediaCollectionViewModel Collection { get; set; } |
||||
public MultiCollectionViewModel MultiCollection { get; set; } |
||||
public SmartCollectionViewModel SmartCollection { get; set; } |
||||
public NamedMediaItemViewModel MediaItem { get; set; } |
||||
|
||||
public string CollectionName => CollectionType switch |
||||
{ |
||||
ProgramScheduleItemCollectionType.Collection => Collection?.Name, |
||||
ProgramScheduleItemCollectionType.TelevisionShow => MediaItem?.Name, |
||||
ProgramScheduleItemCollectionType.TelevisionSeason => MediaItem?.Name, |
||||
ProgramScheduleItemCollectionType.Artist => MediaItem?.Name, |
||||
ProgramScheduleItemCollectionType.MultiCollection => MultiCollection?.Name, |
||||
ProgramScheduleItemCollectionType.SmartCollection => SmartCollection?.Name, |
||||
_ => string.Empty |
||||
}; |
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => |
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||||
|
||||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null) |
||||
{ |
||||
if (EqualityComparer<T>.Default.Equals(field, value)) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
field = value; |
||||
OnPropertyChanged(propertyName); |
||||
return true; |
||||
} |
||||
} |
Loading…
Reference in new issue