60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using OnProfNext.Shared.Models;
|
|
|
|
namespace OnProfNext.Server.Configurations
|
|
{
|
|
public class OrderConfiguration : IEntityTypeConfiguration<Order>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Order> entity)
|
|
{
|
|
entity.ToTable("Orders");
|
|
|
|
entity.HasKey(o => o.Id);
|
|
|
|
entity.Property(o => o.Auftragsnummer)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(o => o.Titel)
|
|
.IsRequired()
|
|
.HasMaxLength(255);
|
|
|
|
entity.Property(o => o.Status)
|
|
.IsRequired()
|
|
.HasMaxLength(50)
|
|
.HasDefaultValue("Geplant");
|
|
|
|
entity.Property(o => o.Planstunden)
|
|
.HasPrecision(10, 2)
|
|
.HasDefaultValue(0);
|
|
|
|
entity.Property(o => o.Iststunden)
|
|
.HasPrecision(10, 2)
|
|
.HasDefaultValue(0);
|
|
|
|
entity.Property(o => o.MandantId)
|
|
.IsRequired();
|
|
|
|
entity.Property(o => o.CreatedAt)
|
|
.HasDefaultValueSql("GETUTCDATE()");
|
|
|
|
entity.Property(o => o.UpdatedAt)
|
|
.HasDefaultValueSql("GETUTCDATE()");
|
|
|
|
|
|
entity.HasOne(o => o.Project)
|
|
.WithMany(p => p.Orders)
|
|
.HasForeignKey(o => o.ProjectId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
|
entity.HasMany(o => o.OrderUsers)
|
|
.WithOne(ou => ou.Order)
|
|
.HasForeignKey(ou => ou.OrderId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
|
|
}
|
|
}
|