-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.cs
74 lines (58 loc) · 1.83 KB
/
Customer.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore;
namespace ECommercePersistence.Model;
public class Customer
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? Email { get; set; }
public string? Password { get; set; }
public string? Role { get; set; }
public DateTimeOffset? VerifiedOn { get; set; }
public DateTimeOffset? UpdatedOn { get; set; }
public DateTimeOffset CreatedOn { get; set; }
[JsonIgnore]
public ICollection<Address>? Addresses { get; set; }
internal static void Builder(ModelBuilder x)
{
x.Entity<Customer>().HasKey(c => c.Id);
x.Entity<Customer>()
.Property(c => c.Id)
.HasMaxLength(36)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.Name)
.HasMaxLength(50)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.FirstName)
.HasMaxLength(50)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.LastName)
.HasMaxLength(50)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.Email)
.HasMaxLength(150)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.Password)
.HasMaxLength(255)
.IsRequired();
x.Entity<Customer>()
.Property(c => c.Role)
.HasMaxLength(50)
.IsRequired();
x.Entity<Customer>()
.HasIndex(c => c.Id)
.IsUnique();
x.Entity<Customer>()
.HasIndex(c => c.Email)
.IsUnique();
x.Entity<Customer>()
.HasIndex(c => c.Role);
}
}