Skip to content

Commit

Permalink
Add providerAddress into BuilderDTO (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdenHide authored Nov 19, 2024
1 parent 96aeb64 commit 8b91cab
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DispenserProvider.DataBase/DispenserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
entity.HasKey(e => e.Id);

entity.Property(x => x.ProviderAddress)
.HasConversion(
x => x.ConvertToChecksumAddress(null),
x => new EthereumAddress(x)
);

entity.HasOne(e => e.TransactionDetail)
.WithMany(e => e.Builders)
.HasForeignKey(e => e.TransactionDetailId)
Expand Down
3 changes: 3 additions & 0 deletions src/DispenserProvider.DataBase/Models/BuilderDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public class BuilderDTO
{
public long Id { get; set; }

[Column(TypeName = "nvarchar(42)")]
public string ProviderAddress { get; set; } = null!;

[Column(TypeName = "decimal(36,18)")]
public decimal Amount { get; set; }

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DispenserProvider.DataBase.Migrations
{
/// <inheritdoc />
public partial class AddProviderAddressToBuilderDTO : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ProviderAddress",
table: "Builders",
type: "nvarchar(42)",
nullable: false,
defaultValue: "");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProviderAddress",
table: "Builders");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<DateTime?>("FinishTime")
.HasColumnType("datetime2(0)");

b.Property<string>("ProviderAddress")
.IsRequired()
.HasColumnType("nvarchar(42)");

b.Property<DateTime?>("StartTime")
.HasColumnType("datetime2(0)");

Expand Down

0 comments on commit 8b91cab

Please sign in to comment.