Implement all car endpoints

This commit is contained in:
2024-08-17 16:38:40 +02:00
parent a708ed25e7
commit 877e7989cd
22 changed files with 688 additions and 46 deletions

View File

@@ -1,4 +1,8 @@
namespace Vegasco.WebApi.Cars;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Vegasco.WebApi.Users;
namespace Vegasco.WebApi.Cars;
public class Car
{
@@ -6,5 +10,27 @@ public class Car
public string Name { get; set; } = "";
public Guid UserId { get; set; }
public string UserId { get; set; } = "";
public virtual User User { get; set; } = null!;
}
public class CarTableConfiguration : IEntityTypeConfiguration<Car>
{
public const int NameMaxLength = 50;
public void Configure(EntityTypeBuilder<Car> builder)
{
builder.HasKey(x => x.Id);
builder.Property(x => x.Name)
.IsRequired()
.HasMaxLength(NameMaxLength);
builder.Property(x => x.UserId)
.IsRequired();
builder.HasOne(x => x.User)
.WithMany(x => x.Cars);
}
}