Skip to content

Commit

Permalink
add OtpConfirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
emrecoskun705 committed Sep 10, 2023
1 parent e9ea32a commit aa86552
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .idea/.idea.Unitagram/.idea/efCoreCommonOptions.xml

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

10 changes: 10 additions & 0 deletions Unitagram.Domain/OtpConfirmation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Unitagram.Domain;

public class OtpConfirmation
{
public Guid UserId { get; set; }
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public int RetryCount { get; set; }
public DateTime? RetryDateTime { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Unitagram.Domain;

namespace Unitagram.Persistence.Configurations;

public class OtpConfirmationConfiguration : IEntityTypeConfiguration<OtpConfirmation>
{
public void Configure(EntityTypeBuilder<OtpConfirmation> builder)
{
builder.HasKey(o => new { o.UserId, o.Name});

builder.Property(o => o.Name)
.HasMaxLength(50);

builder.Property(o => o.RetryCount)
.HasColumnType("tinyint")
.HasDefaultValue((byte)0)
.IsRequired();

builder.Property(o => o.Value)
.IsRequired()
.HasMaxLength(10);

builder.Property(o => o.RetryDateTime)
.IsRequired(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected UnitagramDatabaseContext()

public DbSet<University> University { get; set; }
public DbSet<UniversityUser> UniversityUser { get; set; }
public DbSet<OtpConfirmation> OtpConfirmation { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
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,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Unitagram.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddOtpConfirmation : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OtpConfirmation",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Value = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
RetryCount = table.Column<byte>(type: "tinyint", nullable: false, defaultValue: (byte)0),
RetryDateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_OtpConfirmation", x => new { x.UserId, x.Name });
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OtpConfirmation");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@ protected override void BuildModel(ModelBuilder modelBuilder)

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("Unitagram.Domain.OtpConfirmation", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");

b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");

b.Property<byte>("RetryCount")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint")
.HasDefaultValue((byte)0);

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

b.Property<string>("Value")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");

b.HasKey("UserId", "Name");

b.ToTable("OtpConfirmation");
});

modelBuilder.Entity("Unitagram.Domain.University", b =>
{
b.Property<Guid>("UniversityId")
Expand Down

0 comments on commit aa86552

Please sign in to comment.