-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Entity Type Configuration for all entities.
- Loading branch information
1 parent
e59d905
commit b5d5947
Showing
7 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/SwiftLink.Infrastructure/Persistence/Config/LinkConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace SwiftLink.Infrastructure.Persistence.Config; | ||
|
||
public class LinkConfig : IEntityTypeConfiguration<Link> | ||
{ | ||
public void Configure(EntityTypeBuilder<Link> builder) | ||
{ | ||
builder.ToTable(t => t.HasComment("Stores Original links and generated shortCode.")); | ||
|
||
builder.HasKey(t => t.Id) | ||
.HasName("PK_Base_Link"); | ||
|
||
builder.Property(x => x.OriginalUrl) | ||
.IsRequired() | ||
.HasMaxLength(1500); | ||
|
||
builder.Property(x => x.Description) | ||
.IsRequired() | ||
.HasMaxLength(250); | ||
|
||
builder.Property(x => x.Password) | ||
.IsRequired() | ||
.HasMaxLength(25); | ||
|
||
builder.Property(x => x.ShortCode) | ||
.IsRequired() | ||
.HasMaxLength(16); | ||
|
||
builder.HasMany(x => x.LinkVisits) | ||
.WithOne(x => x.Link) | ||
.HasPrincipalKey(x => x.Id) | ||
.HasForeignKey(x => x.LinkId); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/SwiftLink.Infrastructure/Persistence/Config/LinkVisitConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace SwiftLink.Infrastructure.Persistence.Config; | ||
|
||
public class LinkVisitConfig : IEntityTypeConfiguration<LinkVisit> | ||
{ | ||
public void Configure(EntityTypeBuilder<LinkVisit> builder) | ||
{ | ||
builder.ToTable(t => t.HasComment("analytics, providing insights into the number of users who clicked on a shortened link.")); | ||
|
||
builder.HasKey(t => t.Id) | ||
.HasName("PK_Base_LinkVisit"); | ||
|
||
builder.Property(x => x.ClientMetaData) | ||
.IsRequired() | ||
.HasMaxLength(500); | ||
|
||
builder.Property(x => x.Date) | ||
.IsRequired(); | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/SwiftLink.Infrastructure/Persistence/Config/SubscriberConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace SwiftLink.Infrastructure.Persistence.Config; | ||
|
||
public class SubscriberConfig : IEntityTypeConfiguration<Subscriber> | ||
{ | ||
public void Configure(EntityTypeBuilder<Subscriber> builder) | ||
{ | ||
builder.ToTable(t => t.HasComment("Only these subscribers are allowed to insert a URL to obtain a shorter one.")); | ||
|
||
builder.HasKey(t => t.Id) | ||
.HasName("PK_Base_Subscriber"); | ||
|
||
builder.Property(x => x.Name) | ||
.IsRequired() | ||
.HasMaxLength(50); | ||
|
||
builder.Property(x => x.Token) | ||
.IsRequired(); | ||
|
||
builder.Property(x => x.IsActive) | ||
.IsRequired(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...structure/Context/ApplicationDbContext.cs → ...rsistence/Context/ApplicationDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ture/Extensions/ModelBuilderExtentions.cs → ...ence/Extensions/ModelBuilderExtentions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters