Currency creation and minting with basis of transactions

This commit is contained in:
2023-08-19 15:04:10 -04:00
parent 401c75a4f9
commit 658bd7ca2a
13 changed files with 594 additions and 34 deletions

View File

@ -79,10 +79,7 @@ namespace IO.Swagger.Controllers
public virtual async Task<IActionResult> LoginUser([FromBody]AuthLoginBody body) public virtual async Task<IActionResult> LoginUser([FromBody]AuthLoginBody body)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
var errors = ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage));
return BadRequest(errors);
}
var user = await repository.LoginUser(body); var user = await repository.LoginUser(body);
return user == null ? Unauthorized() : Ok(new { token = jwt.GenerateJwt(user.Id) }); return user == null ? Unauthorized() : Ok(new { token = jwt.GenerateJwt(user.Id) });
} }
@ -102,10 +99,7 @@ namespace IO.Swagger.Controllers
public async Task<IActionResult> RegisterUser([FromBody]AuthRegisterBody body) public async Task<IActionResult> RegisterUser([FromBody]AuthRegisterBody body)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
var errors = ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage));
return BadRequest(errors);
}
var user = await repository.RegisterUser(body); var user = await repository.RegisterUser(body);
return user == null ? StatusCode(409) : Ok(new { token = jwt.GenerateJwt(user.Id) }); return user == null ? StatusCode(409) : Ok(new { token = jwt.GenerateJwt(user.Id) });

View File

@ -18,6 +18,10 @@ using IO.Swagger.Attributes;
using IO.Swagger.Security; using IO.Swagger.Security;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using IO.Swagger.Models.dto; using IO.Swagger.Models.dto;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using IO.Swagger.Repositories;
namespace IO.Swagger.Controllers namespace IO.Swagger.Controllers
{ {
@ -27,6 +31,13 @@ namespace IO.Swagger.Controllers
[ApiController] [ApiController]
public class CurrencyApiController : ControllerBase public class CurrencyApiController : ControllerBase
{ {
private readonly ICurrencyRepository repo;
public CurrencyApiController(ICurrencyRepository repo)
{
this.repo = repo ?? throw new ArgumentNullException(nameof(repo));
}
/// <summary> /// <summary>
/// Add a digital asset to the user&#x27;s collection /// Add a digital asset to the user&#x27;s collection
/// </summary> /// </summary>
@ -86,23 +97,23 @@ namespace IO.Swagger.Controllers
/// <response code="201">Currency type created successfully</response> /// <response code="201">Currency type created successfully</response>
/// <response code="400">Bad Request</response> /// <response code="400">Bad Request</response>
/// <response code="401">Unauthorized</response> /// <response code="401">Unauthorized</response>
/// <response code="422">Unprocessable Content</response>
[HttpPost] [HttpPost]
[Route("/v1/api/currency/create")] [Route("/v1/api/currency/create")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState] [ValidateModelState]
[SwaggerOperation("CreateCurrency")] [SwaggerOperation("CreateCurrency")]
public virtual IActionResult CreateCurrency([FromBody]CurrencyCreateBody body) public virtual async Task<IActionResult> CreateCurrency([FromBody]CurrencyCreateBody body)
{ {
//TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
// return StatusCode(201); if (!int.TryParse(userIdString, out int userId))
return Unauthorized();
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (!ModelState.IsValid)
// return StatusCode(400); return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... var createdCurr = await repo.CreateCurrency(body, userId);
// return StatusCode(401); return createdCurr ? StatusCode(201) : StatusCode(422);
throw new NotImplementedException();
} }
/// <summary> /// <summary>
@ -112,23 +123,22 @@ namespace IO.Swagger.Controllers
/// <response code="200">Successful minting</response> /// <response code="200">Successful minting</response>
/// <response code="400">Bad Request</response> /// <response code="400">Bad Request</response>
/// <response code="401">Unauthorized</response> /// <response code="401">Unauthorized</response>
/// <response code="409">Conflict - User is not owner or currency does not exist</response>
[HttpPost] [HttpPost]
[Route("/v1/api/currency/mint")] [Route("/v1/api/currency/mint")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState] [ValidateModelState]
[SwaggerOperation("MintCurrency")] [SwaggerOperation("MintCurrency")]
public virtual IActionResult MintCurrency([FromBody]CurrencyMintBody body) public virtual async Task<IActionResult> MintCurrency([FromBody]CurrencyMintBody body)
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
// return StatusCode(200); if (!int.TryParse(userIdString, out int userId))
return Unauthorized();
if (!ModelState.IsValid)
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... var minted = await repo.MintCurrency(body, userId);
// return StatusCode(400); return minted ? Ok() : StatusCode(409);
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(401);
throw new NotImplementedException();
} }
} }
} }

View File

@ -0,0 +1,177 @@
// <auto-generated />
using System;
using IO.Swagger.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IO.Swagger.Migrations
{
[DbContext(typeof(BankDbContext))]
[Migration("20230819185130_Started transactions and currencies")]
partial class Startedtransactionsandcurrencies
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.Property<int>("CurrencyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CurrencyId"));
b.Property<string>("Name")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("Symbol")
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("CurrencyId");
b.HasIndex("UserId");
b.ToTable("Currencies");
});
modelBuilder.Entity("IO.Swagger.Models.db.Transaction", b =>
{
b.Property<int>("TransactionId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TransactionId"));
b.Property<float>("Amount")
.HasColumnType("real");
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("FromUserId")
.HasColumnType("int");
b.Property<string>("Memo")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<int>("ToUserId")
.HasColumnType("int");
b.Property<DateTime>("TransactionTime")
.HasColumnType("datetime2");
b.HasKey("TransactionId");
b.HasIndex("CurrencyId");
b.HasIndex("FromUserId");
b.HasIndex("ToUserId");
b.ToTable("Transactions");
});
modelBuilder.Entity("IO.Swagger.Models.db.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("LastName")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("Salt")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.HasOne("IO.Swagger.Models.db.User", "User")
.WithMany("Currencies")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("IO.Swagger.Models.db.Transaction", b =>
{
b.HasOne("IO.Swagger.Models.db.Currency", "Currency")
.WithMany("Transactions")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("IO.Swagger.Models.db.User", "FromUser")
.WithMany("TransactionsFrom")
.HasForeignKey("FromUserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("IO.Swagger.Models.db.User", "ToUser")
.WithMany("TransactionsTo")
.HasForeignKey("ToUserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("Currency");
b.Navigation("FromUser");
b.Navigation("ToUser");
});
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.Navigation("Transactions");
});
modelBuilder.Entity("IO.Swagger.Models.db.User", b =>
{
b.Navigation("Currencies");
b.Navigation("TransactionsFrom");
b.Navigation("TransactionsTo");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,98 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IO.Swagger.Migrations
{
/// <inheritdoc />
public partial class Startedtransactionsandcurrencies : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Currencies",
columns: table => new
{
CurrencyId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
Symbol = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: true),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Currencies", x => x.CurrencyId);
table.ForeignKey(
name: "FK_Currencies_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Transactions",
columns: table => new
{
TransactionId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FromUserId = table.Column<int>(type: "int", nullable: false),
ToUserId = table.Column<int>(type: "int", nullable: false),
Amount = table.Column<float>(type: "real", nullable: false),
Memo = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
CurrencyId = table.Column<int>(type: "int", nullable: false),
TransactionTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Transactions", x => x.TransactionId);
table.ForeignKey(
name: "FK_Transactions_Currencies_CurrencyId",
column: x => x.CurrencyId,
principalTable: "Currencies",
principalColumn: "CurrencyId");
table.ForeignKey(
name: "FK_Transactions_Users_FromUserId",
column: x => x.FromUserId,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Transactions_Users_ToUserId",
column: x => x.ToUserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Currencies_UserId",
table: "Currencies",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_CurrencyId",
table: "Transactions",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_FromUserId",
table: "Transactions",
column: "FromUserId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_ToUserId",
table: "Transactions",
column: "ToUserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Transactions");
migrationBuilder.DropTable(
name: "Currencies");
}
}
}

View File

@ -1,4 +1,5 @@
// <auto-generated /> // <auto-generated />
using System;
using IO.Swagger.Services; using IO.Swagger.Services;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
@ -21,6 +22,71 @@ namespace IO.Swagger.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.Property<int>("CurrencyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CurrencyId"));
b.Property<string>("Name")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("Symbol")
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("CurrencyId");
b.HasIndex("UserId");
b.ToTable("Currencies");
});
modelBuilder.Entity("IO.Swagger.Models.db.Transaction", b =>
{
b.Property<int>("TransactionId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TransactionId"));
b.Property<float>("Amount")
.HasColumnType("real");
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("FromUserId")
.HasColumnType("int");
b.Property<string>("Memo")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<int>("ToUserId")
.HasColumnType("int");
b.Property<DateTime>("TransactionTime")
.HasColumnType("datetime2");
b.HasKey("TransactionId");
b.HasIndex("CurrencyId");
b.HasIndex("FromUserId");
b.HasIndex("ToUserId");
b.ToTable("Transactions");
});
modelBuilder.Entity("IO.Swagger.Models.db.User", b => modelBuilder.Entity("IO.Swagger.Models.db.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -50,6 +116,58 @@ namespace IO.Swagger.Migrations
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.HasOne("IO.Swagger.Models.db.User", "User")
.WithMany("Currencies")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("IO.Swagger.Models.db.Transaction", b =>
{
b.HasOne("IO.Swagger.Models.db.Currency", "Currency")
.WithMany("Transactions")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("IO.Swagger.Models.db.User", "FromUser")
.WithMany("TransactionsFrom")
.HasForeignKey("FromUserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("IO.Swagger.Models.db.User", "ToUser")
.WithMany("TransactionsTo")
.HasForeignKey("ToUserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("Currency");
b.Navigation("FromUser");
b.Navigation("ToUser");
});
modelBuilder.Entity("IO.Swagger.Models.db.Currency", b =>
{
b.Navigation("Transactions");
});
modelBuilder.Entity("IO.Swagger.Models.db.User", b =>
{
b.Navigation("Currencies");
b.Navigation("TransactionsFrom");
b.Navigation("TransactionsTo");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace IO.Swagger.Models.db
{
public class Currency
{
public int CurrencyId { get; set; }
[StringLength(32, MinimumLength = 1)]
public string Name { get; set; }
[StringLength(4, MinimumLength = 1)]
public string Symbol { get; set; }
[ForeignKey("FK_Currency_UserId")]
public int UserId { get; set; }
public User User { get; set; }
public ICollection<Transaction> Transactions { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic;
using System;
using System.ComponentModel.DataAnnotations;
namespace IO.Swagger.Models.db
{
public class Transaction
{
public int TransactionId { get; set; }
public int FromUserId { get; set; }
public User FromUser { get; set; }
public int ToUserId { get; set; }
public User ToUser { get; set; }
[Range(0.01, float.MaxValue)]
public float Amount { get; set; }
[Required]
[StringLength(32, MinimumLength = 2)]
public string Memo { get; set; }
public Currency Currency { get; set; }
public int CurrencyId { get; set; }
public DateTime TransactionTime { get; set; } = DateTime.UtcNow;
}
}

View File

@ -1,4 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace IO.Swagger.Models.db namespace IO.Swagger.Models.db
{ {
@ -12,6 +14,11 @@ namespace IO.Swagger.Models.db
public string LastName { get; set; } public string LastName { get; set; }
public string PasswordHash { get; set; } public string PasswordHash { get; set; }
public string Salt { get; set; } public string Salt { get; set; }
public ICollection<Currency> Currencies { get; set; }
public ICollection<Transaction> TransactionsFrom { get; set; }
public ICollection<Transaction> TransactionsTo { get; set; }
} }
} }

View File

@ -31,14 +31,16 @@ namespace IO.Swagger.Models.dto
/// </summary> /// </summary>
[DataMember(Name = "currencyId")] [DataMember(Name = "currencyId")]
public int? CurrencyId { get; set; } [Required]
public int CurrencyId { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Amount /// Gets or Sets Amount
/// </summary> /// </summary>
[Required]
[DataMember(Name = "amount")] [DataMember(Name = "amount")]
public decimal? Amount { get; set; } public float Amount { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object

View File

@ -0,0 +1,55 @@
using IO.Swagger.Models.db;
using IO.Swagger.Models.dto;
using IO.Swagger.Services;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IO.Swagger.Repositories
{
public class CurrencyRepository : ICurrencyRepository
{
BankDbContext context;
public CurrencyRepository(BankDbContext context)
{
this.context = context ?? throw new ArgumentNullException(nameof(context));
}
public async Task<bool> CreateCurrency(CurrencyCreateBody request, int userId)
{
request.Symbol = request.Symbol.Trim();
request.Name = request.Name.Trim();
if (await context.Currencies.AnyAsync(c => c.Symbol == request.Symbol || c.Name.ToLower() == request.Name.ToLower()))
return false;
await context.Currencies.AddAsync(new Currency
{
Name = request.Name,
Symbol = request.Symbol,
UserId = userId
});
return await context.SaveChangesAsync() > 0;
}
public async Task<bool> MintCurrency(CurrencyMintBody request, int userId)
{
var existsAndIsOwner = await context.Currencies.AnyAsync(c => c.CurrencyId == request.CurrencyId && c.UserId == userId);
if (!existsAndIsOwner)
return false;
await context.Transactions.AddAsync(new Transaction
{
Amount = request.Amount,
CurrencyId = request.CurrencyId,
ToUserId = userId,
FromUserId = userId,
Memo = "Minting"
});
return await context.SaveChangesAsync() > 0;
}
}
}

View File

@ -0,0 +1,11 @@
using IO.Swagger.Models.dto;
using System.Threading.Tasks;
namespace IO.Swagger.Repositories
{
public interface ICurrencyRepository
{
Task<bool> CreateCurrency(CurrencyCreateBody request, int userId);
Task<bool> MintCurrency(CurrencyMintBody request, int userId);
}
}

View File

@ -11,7 +11,44 @@ namespace IO.Swagger.Services
} }
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<Currency> Currencies { get; set; }
public DbSet<Transaction> Transactions { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// currency -> user FK
modelBuilder.Entity<User>()
.HasMany(u => u.Currencies)
.WithOne(c => c.User)
.HasForeignKey(c => c.UserId)
.HasPrincipalKey(u => u.Id)
.OnDelete(DeleteBehavior.NoAction);
// transaction -> from user
modelBuilder.Entity<User>()
.HasMany(u => u.TransactionsFrom)
.WithOne(t => t.FromUser)
.HasForeignKey(t => t.FromUserId)
.HasPrincipalKey(u => u.Id)
.OnDelete(DeleteBehavior.NoAction);
// transaction -> to user
modelBuilder.Entity<User>()
.HasMany(u => u.TransactionsTo)
.WithOne(t => t.ToUser)
.HasForeignKey(t => t.ToUserId)
.HasPrincipalKey(u => u.Id)
.OnDelete(DeleteBehavior.NoAction);
// transaction -> currency
modelBuilder.Entity<Transaction>()
.HasOne(t => t.Currency)
.WithMany(c => c.Transactions)
.HasForeignKey(t => t.CurrencyId)
.HasPrincipalKey(c => c.CurrencyId)
.OnDelete(DeleteBehavior.NoAction);
}
} }
} }

View File

@ -140,7 +140,7 @@ namespace IO.Swagger
} }
Console.WriteLine(connectionString); Console.WriteLine(connectionString);
services.AddScoped<IUserRepository, UserRepository>(); services.AddScoped<IUserRepository, UserRepository>();
//services.AddScoped<ICurrencyRepository, CurrencyRepository>(); services.AddScoped<ICurrencyRepository, CurrencyRepository>();
services.AddDbContext<BankDbContext>(x => x.UseSqlServer(connectionString: connectionString)); services.AddDbContext<BankDbContext>(x => x.UseSqlServer(connectionString: connectionString));
services.AddSingleton<JwtService>(); services.AddSingleton<JwtService>();
} }