* 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
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
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>());
|
|
}
|
|
}
|