basics
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaPhotoImageBackgroundConfiguration : IEntityTypeConfiguration<MediaPhotoImageBackground>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaPhotoImageBackground> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsUniversalBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.FirstGradientColor)
|
||||
.IsRequired()
|
||||
.HasMaxLength(3);
|
||||
|
||||
builder.Property(x => x.SecondGradientColor)
|
||||
.IsRequired()
|
||||
.HasMaxLength(3);
|
||||
}
|
||||
}
|
||||
@@ -33,12 +33,8 @@ public class MediaPhotoImageConfiguration : IEntityTypeConfiguration<MediaPhotoI
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.IsMediaBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.IsUniversalBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
builder.HasOne(x => x.MediaPhotoImageBackground)
|
||||
.WithOne(x => x.MediaPhotoImage)
|
||||
.HasForeignKey<MediaPhotoImageBackground>();
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,8 +9,6 @@ public class MediaPhotoImage
|
||||
public required byte[] Image { get; set; }
|
||||
public required string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
public bool IsMediaBackground { get; set; }
|
||||
public bool IsUniversalBackground { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -19,6 +17,7 @@ public class MediaPhotoImage
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
public virtual MediaPhotoImageBackground? MediaPhotoImageBackground { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaPhotoImageBackground
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public required Guid Id { get; set; }
|
||||
public required bool IsUniversalBackground { get; set; }
|
||||
public required byte[] FirstGradientColor { get; set; }
|
||||
public required byte[] SecondGradientColor { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaPhotoImage MediaPhotoImage { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user