2023-09-24 14:36:36 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
2024-03-02 00:43:56 +00:00
|
|
|
using OliverBooth.Common.Data.Web.Projects;
|
2023-09-24 14:36:36 +01:00
|
|
|
|
2024-03-02 00:43:56 +00:00
|
|
|
namespace OliverBooth.Common.Data.Web.Configuration;
|
2023-09-24 14:36:36 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents the configuration for the <see cref="Project" /> entity.
|
|
|
|
/// </summary>
|
|
|
|
internal sealed class ProjectConfiguration : IEntityTypeConfiguration<Project>
|
|
|
|
{
|
|
|
|
/// <inheritdoc />
|
|
|
|
public void Configure(EntityTypeBuilder<Project> builder)
|
|
|
|
{
|
|
|
|
builder.ToTable("Project");
|
|
|
|
builder.HasKey(e => e.Id);
|
|
|
|
|
|
|
|
builder.Property(e => e.Id).IsRequired();
|
|
|
|
builder.Property(e => e.Rank).IsRequired();
|
|
|
|
builder.Property(e => e.Slug).IsRequired();
|
|
|
|
builder.Property(e => e.Name).IsRequired();
|
|
|
|
builder.Property(e => e.HeroUrl).IsRequired();
|
|
|
|
builder.Property(e => e.Description).IsRequired();
|
2023-12-24 12:20:03 +00:00
|
|
|
builder.Property(e => e.Details).IsRequired();
|
2023-09-24 14:36:36 +01:00
|
|
|
builder.Property(e => e.Status).HasConversion<EnumToStringConverter<ProjectStatus>>().IsRequired();
|
|
|
|
builder.Property(e => e.RemoteUrl);
|
|
|
|
builder.Property(e => e.RemoteTarget);
|
2023-12-24 12:20:03 +00:00
|
|
|
builder.Property(e => e.Tagline);
|
|
|
|
builder.Property(e => e.Languages).HasConversion(
|
|
|
|
v => string.Join(' ', v),
|
|
|
|
s => s.Split(' ', StringSplitOptions.None));
|
2023-09-24 14:36:36 +01:00
|
|
|
}
|
|
|
|
}
|