summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Tables/User.cs
blob: 9044439e33ce504dc3633d3f947f70d6e45430d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using WhatApi.Extras;

namespace WhatApi.Tables;

public class User : IAuditableEntity
{
    public Guid Id { get; set; }
    public required string Name { get; set; }
    public required string Email { get; set; }

    [AuditTrailIgnore]
    public required string Password { get; set; }
    public DateTimeOffset? LastSeen { get; set; }
    public IEnumerable<Place> Places { get; set; } = null!;
    public DateTimeOffset CreatedAtUtc { get; set; }
    public DateTimeOffset? UpdatedAtUtc { get; set; }
    public Guid CreatedBy { get; set; }
    public Guid? UpdatedBy { get; set; }
}

public class UserConfiguration : IEntityTypeConfiguration<User>
{
    public void Configure(EntityTypeBuilder<User> builder) {
        builder.HasKey(x => x.Id);
        builder.Property(x => x.Name).HasMaxLength(50);
        builder.Property(x => x.Email).HasMaxLength(100);
        builder.Property(x => x.Password).HasMaxLength(100);
        builder.HasMany(x => x.Places);
        builder.ToTable("user");
    }
}