diff --git a/Bank/Bank.sln b/Bank/Bank.sln
index fffc74a..9fa4c9b 100644
--- a/Bank/Bank.sln
+++ b/Bank/Bank.sln
@@ -5,7 +5,9 @@ VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataModels", "BankDataModels\BankDataModels.csproj", "{B74F0734-6D5B-41D5-AF9B-23CF7535C52F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankContracts", "BankContracts\BankContracts.csproj", "{59CDEA88-47C6-434D-84C6-40390E267858}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankContracts", "BankContracts\BankContracts.csproj", "{59CDEA88-47C6-434D-84C6-40390E267858}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankDatabaseImplement", "BankDatabaseImplement\BankDatabaseImplement.csproj", "{E038E32E-3601-4A3C-BB3D-301F9AE9B8E7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,10 @@ Global
{59CDEA88-47C6-434D-84C6-40390E267858}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59CDEA88-47C6-434D-84C6-40390E267858}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59CDEA88-47C6-434D-84C6-40390E267858}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E038E32E-3601-4A3C-BB3D-301F9AE9B8E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E038E32E-3601-4A3C-BB3D-301F9AE9B8E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E038E32E-3601-4A3C-BB3D-301F9AE9B8E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E038E32E-3601-4A3C-BB3D-301F9AE9B8E7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Bank/BankDatabaseImplement/BankDatabase.cs b/Bank/BankDatabaseImplement/BankDatabase.cs
new file mode 100644
index 0000000..8541955
--- /dev/null
+++ b/Bank/BankDatabaseImplement/BankDatabase.cs
@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace BankDatabaseImplement
+{
+ public class BankDatabase : DbContext
+ {
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ if (optionsBuilder.IsConfigured == false)
+ {
+ optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BankDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"
+ );
+ }
+ base.OnConfiguring(optionsBuilder);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Bank/BankDatabaseImplement/BankDatabaseImplement.csproj b/Bank/BankDatabaseImplement/BankDatabaseImplement.csproj
new file mode 100644
index 0000000..ca2d4cb
--- /dev/null
+++ b/Bank/BankDatabaseImplement/BankDatabaseImplement.csproj
@@ -0,0 +1,26 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Bank/BankDatabaseImplement/Models/Card.cs b/Bank/BankDatabaseImplement/Models/Card.cs
new file mode 100644
index 0000000..05bba95
--- /dev/null
+++ b/Bank/BankDatabaseImplement/Models/Card.cs
@@ -0,0 +1,78 @@
+using BankContracts.BindingModels;
+using BankContracts.ViewModels;
+using BankDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankDatabaseImplement.Models
+{
+ public class Card : ICardModel
+ {
+ public int Id { get; set; }
+ [Required]
+ public string Number { get; set; } = string.Empty;
+ [Required]
+ public string Cvv { get; set; } = string.Empty;
+ [Required]
+ public string Pin { get; set; } = string.Empty;
+ [Required]
+ public DateOnly ReleaseDate { get; set; }
+ [Required]
+ public DateOnly ExpirationDate { get; set; }
+ [Required]
+ public int ClientId { get; set; }
+ [Required]
+ public int? AccountId { get; set; } = null;
+ [ForeignKey("CardId")]
+ public virtual List CardRequests { get; set; } = new();
+ [ForeignKey("SenderCardId")]
+ public virtual List SenderOperations { get; set; } = new();
+ [ForeignKey("RecipientCardId")]
+ public virtual List RecipientOperations { get; set; } = new();
+
+ public static Card? Create(CardBindingModel model)
+ {
+ if (model == null) return null;
+ return new Card
+ {
+ Id = model.Id,
+ Number = model.Number,
+ Cvv = model.Cvv,
+ Pin = model.Pin,
+ ReleaseDate = model.ReleaseDate,
+ ExpirationDate = model.ExpirationDate,
+ ClientId = model.ClientId,
+ AccountId = model.AccountId,
+ };
+ }
+
+ public void Update(CardBindingModel model)
+ {
+ if (model == null) return;
+ Number = model.Number;
+ Cvv = model.Cvv;
+ Pin = model.Pin;
+ ReleaseDate = model.ReleaseDate;
+ ExpirationDate = model.ExpirationDate;
+ ClientId = model.ClientId;
+ AccountId = model.AccountId;
+ }
+
+ public CardViewModel GetViewModel => new()
+ {
+ Id = Id,
+ Number = Number,
+ Cvv = Cvv,
+ Pin = Pin,
+ ReleaseDate = ReleaseDate,
+ ExpirationDate = ExpirationDate,
+ ClientId = ClientId,
+ AccountId = AccountId,
+ };
+ }
+}
diff --git a/Bank/BankDatabaseImplement/Models/CardRequest.cs b/Bank/BankDatabaseImplement/Models/CardRequest.cs
new file mode 100644
index 0000000..06c6f04
--- /dev/null
+++ b/Bank/BankDatabaseImplement/Models/CardRequest.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankDatabaseImplement.Models
+{
+ public class CardRequest
+ {
+ }
+}
diff --git a/Bank/BankDatabaseImplement/Models/Client.cs b/Bank/BankDatabaseImplement/Models/Client.cs
new file mode 100644
index 0000000..21121ef
--- /dev/null
+++ b/Bank/BankDatabaseImplement/Models/Client.cs
@@ -0,0 +1,63 @@
+using BankContracts.BindingModels;
+using BankContracts.ViewModels;
+using BankDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankDatabaseImplement.Models
+{
+ public class Client : IClientModel
+ {
+ public int Id { get; set; }
+ [Required]
+ public string Fio { get; set; } = string.Empty;
+ [Required]
+ public string Email { get; set; } = string.Empty;
+ [Required]
+ public string Password { get; set; } = string.Empty;
+ [ForeignKey("ClientId")]
+ public virtual List Cards { get; set; } = new();
+
+ public static Client? Create(ClientBindingModel model)
+ {
+ if (model == null)
+ return null;
+ return new Client
+ {
+ Id = model.Id,
+ Fio = model.Fio,
+ Email = model.Email,
+ Password = model.Password,
+ };
+ }
+ public static Client Create(ClientViewModel model)
+ {
+ return new Client()
+ {
+ Id = model.Id,
+ Fio = model.Fio,
+ Email = model.Email,
+ Password = model.Password,
+ };
+ }
+ public void Update(ClientBindingModel model)
+ {
+ if (model == null) return;
+ Fio = model.Fio;
+ Email = model.Email;
+ Password = model.Password;
+ }
+ public ClientViewModel GetViewModel => new()
+ {
+ Id = Id,
+ Fio = Fio,
+ Email = Email,
+ Password = Password,
+ };
+ }
+}
diff --git a/Bank/BankDatabaseImplement/Models/Operation.cs b/Bank/BankDatabaseImplement/Models/Operation.cs
new file mode 100644
index 0000000..b74652c
--- /dev/null
+++ b/Bank/BankDatabaseImplement/Models/Operation.cs
@@ -0,0 +1,56 @@
+using Azure;
+using BankContracts.BindingModels;
+using BankContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankDatabaseImplement.Models
+{
+ public class Operation
+ {
+ public int Id { get; set; }
+ [Required]
+ public int Sum { get; set; }
+ [Required]
+ public DateTime OperationTime { get; set; }
+ [Required]
+ public int? SenderCardId { get; set; } = null;
+ [Required]
+ public int RecipientCardId { get; set; }
+
+ public static Operation? Create(OperationBindingModel model)
+ {
+ if (model == null) return null;
+ return new Operation
+ {
+ Id = model.Id,
+ Sum = model.Sum,
+ OperationTime = model.OperationTime,
+ SenderCardId = model.SenderCardId,
+ RecipientCardId = model.RecipientCardId,
+ };
+ }
+
+ public void Update(OperationBindingModel model)
+ {
+ if (model == null) return;
+ Sum = model.Sum;
+ OperationTime = model.OperationTime;
+ SenderCardId = model.SenderCardId;
+ RecipientCardId = model.RecipientCardId;
+ }
+
+ public OperationViewModel GetViewModel => new()
+ {
+ Id = Id,
+ Sum = Sum,
+ OperationTime = OperationTime,
+ SenderCardId = SenderCardId,
+ RecipientCardId = RecipientCardId,
+ };
+ }
+}