Rename WebApi project to Vegasco.Server.Api
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
And update all references including comments etc.
This commit is contained in:
42
src/Vegasco.Server.Api/Cars/Car.cs
Normal file
42
src/Vegasco.Server.Api/Cars/Car.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Vegasco.Server.Api.Consumptions;
|
||||
using Vegasco.Server.Api.Users;
|
||||
|
||||
namespace Vegasco.Server.Api.Cars;
|
||||
|
||||
public class Car
|
||||
{
|
||||
public CarId Id { get; set; } = CarId.New();
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public string UserId { get; set; } = "";
|
||||
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Consumption> Consumptions { get; set; } = [];
|
||||
}
|
||||
|
||||
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.Id)
|
||||
.HasConversion<CarId.EfCoreValueConverter>();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(NameMaxLength);
|
||||
|
||||
builder.Property(x => x.UserId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.User)
|
||||
.WithMany(x => x.Cars);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user