add alternate schedule system (#1105)
* start to add program schedule alternates * edit days of the week * editor improvements * save changes * build playouts using alternate schedules * reset playout as needed * add priority message
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.Data.Configurations;
|
||||
|
||||
public class ProgramScheduleAlternateConfiguration : IEntityTypeConfiguration<ProgramScheduleAlternate>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ProgramScheduleAlternate> builder)
|
||||
{
|
||||
builder.ToTable("ProgramScheduleAlternate");
|
||||
|
||||
var intCollectionValueConverter = new ValueConverter<ICollection<int>, string>(
|
||||
i => string.Join(",", i),
|
||||
s => string.IsNullOrWhiteSpace(s)
|
||||
? Array.Empty<int>()
|
||||
: s.Split(new[] { ',' }).Select(int.Parse).ToArray());
|
||||
|
||||
var intCollectionValueComparer = new CollectionValueComparer<int>();
|
||||
|
||||
builder.Property(t => t.DaysOfMonth)
|
||||
.HasConversion(intCollectionValueConverter)
|
||||
.Metadata.SetValueComparer(intCollectionValueComparer);
|
||||
|
||||
builder.Property(t => t.MonthsOfYear)
|
||||
.HasConversion(intCollectionValueConverter)
|
||||
.Metadata.SetValueComparer(intCollectionValueComparer);
|
||||
|
||||
builder.Property(t => t.DaysOfWeek)
|
||||
.HasConversion(new EnumCollectionJsonValueConverter<DayOfWeek>())
|
||||
.Metadata.SetValueComparer(new CollectionValueComparer<DayOfWeek>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user