From 930f872ab7268baf53b19038dfbd452d94805244 Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:42:05 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B2=D1=81=D0=B5=20Storages=20=D0=B2=20BankDataBaseI?= =?UTF-8?q?mplement=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=BE=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=9F=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BankOperatorStorage.cs | 88 ++++++++++++++++++ .../Implements/CreditProgramStorage.cs | 89 +++++++++++++++++++ .../Implements/CurrencyPurchaseStorage.cs | 89 +++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs create mode 100644 Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs create mode 100644 Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs diff --git a/Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs b/Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs new file mode 100644 index 0000000..f890965 --- /dev/null +++ b/Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs @@ -0,0 +1,88 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Implements +{ + public class BankOperatorStorage : IBankOperatorStorage + { + public BankOperatorViewModel? Delete(BankOperatorBindingModel model) + { + using var context = new BankDatabase(); + var element = context.BankOperators.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.BankOperators.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public BankOperatorViewModel? GetElement(BankOperatorSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new BankDatabase(); + return context.BankOperators + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(BankOperatorSearchModel model) + { + if (!model.Id.HasValue) + { + return new(); + } + using var context = new BankDatabase(); + return context.BankOperators + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDatabase(); + return context.BankOperators + .Select(x => x.GetViewModel) + .ToList(); + } + + public BankOperatorViewModel? Insert(BankOperatorBindingModel model) + { + using var context = new BankDatabase(); + var newBankOperator = BankOperator.Create(model); + if (newBankOperator == null) + { + return null; + } + context.BankOperators.Add(newBankOperator); + context.SaveChanges(); + return newBankOperator.GetViewModel; + } + + public BankOperatorViewModel? Update(BankOperatorBindingModel model) + { + using var context = new BankDatabase(); + var bankOperator = context.BankOperators.FirstOrDefault(x => x.Id == model.Id); + if (bankOperator == null) + { + return null; + } + bankOperator.Update(model); + context.SaveChanges(); + return bankOperator.GetViewModel; + } + } +} diff --git a/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs b/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs new file mode 100644 index 0000000..16d2f6b --- /dev/null +++ b/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs @@ -0,0 +1,89 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Implements +{ + public class CreditProgramStorage : ICreditProgramStorage + { + public CreditProgramViewModel? Delete(CreditProgramBindingModel model) + { + using var context = new BankDatabase(); + var element = context.CreditPrograms.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.CreditPrograms.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public CreditProgramViewModel? GetElement(CreditProgramSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new BankDatabase(); + return context.CreditPrograms + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(CreditProgramSearchModel model) + { + if (!model.Id.HasValue) + { + return new(); + } + using var context = new BankDatabase(); + return context.CreditPrograms + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDatabase(); + return context.CreditPrograms + .Select(x => x.GetViewModel) + .ToList(); + } + + public CreditProgramViewModel? Insert(CreditProgramBindingModel model) + { + using var context = new BankDatabase(); + var newCreditProgram = CreditProgram.Create(context, model); + if (newCreditProgram == null) + { + return null; + } + context.CreditPrograms.Add(newCreditProgram); + context.SaveChanges(); + return newCreditProgram.GetViewModel; + } + + public CreditProgramViewModel? Update(CreditProgramBindingModel model) + { + using var context = new BankDatabase(); + var creditProgram = context.CreditPrograms.FirstOrDefault(x => x.Id == model.Id); + if (creditProgram == null) + { + return null; + } + creditProgram.Update(model); + creditProgram.UpdateCurrencies(context, model); + context.SaveChanges(); + return creditProgram.GetViewModel; + } + } +} diff --git a/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs b/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs new file mode 100644 index 0000000..029c5ad --- /dev/null +++ b/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs @@ -0,0 +1,89 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Implements +{ + public class CurrencyPurchaseStorage : ICurrencyPurchaseStorage + { + public CurrencyPurchaseViewModel? Delete(CurrencyPurchaseBindingModel model) + { + using var context = new BankDatabase(); + var currencyPurchase = context.CurrencyPurchases.FirstOrDefault(x => x.Id == model.Id); + if (currencyPurchase == null) + { + return null; + } + currencyPurchase.Update(model); + context.SaveChanges(); + return currencyPurchase.GetViewModel; + } + + public CurrencyPurchaseViewModel? GetElement(CurrencyPurchaseSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new BankDatabase(); + return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x=>x.Currency) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(CurrencyPurchaseSearchModel model) + { + if (!model.Id.HasValue) + { + return new(); + } + using var context = new BankDatabase(); + return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x=>x.Currency) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDatabase(); + return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x=> x.Currency) + .Select(x => x.GetViewModel) + .ToList(); + } + + public CurrencyPurchaseViewModel? Insert(CurrencyPurchaseBindingModel model) + { + using var context = new BankDatabase(); + var newCurrencyPurchase = CurrencyPurchase.Create(context, model); + if (newCurrencyPurchase == null) + { + return null; + } + context.CurrencyPurchases.Add(newCurrencyPurchase); + context.SaveChanges(); + return newCurrencyPurchase.GetViewModel; + } + + public CurrencyPurchaseViewModel? Update(CurrencyPurchaseBindingModel model) + { + using var context = new BankDatabase(); + var currencyPurchase = context.CurrencyPurchases.FirstOrDefault(x => x.Id == model.Id); + if (currencyPurchase == null) + { + return null; + } + currencyPurchase.Update(model); + context.SaveChanges(); + return currencyPurchase.GetViewModel; + } + } +} From 22090fb93d017dcae6b12cc8b1f1f96464c499da Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:06:08 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81:=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=B2=D1=8F=D0=B7=D0=BA=D0=B0=20BankOperator=20=D0=BA=20?= =?UTF-8?q?=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D1=8F=D0=BC=20Credit?= =?UTF-8?q?Program=20=D0=B8=20Currency.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20BankOperatorId=20=D0=B2=20Sear?= =?UTF-8?q?chModel=20CurrencyPurchase/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreditProgramBindingModel.cs | 1 + .../BindingModels/CurrencyBindingModel.cs | 1 + .../SearchModels/CreditProgramSearchModel.cs | 1 + .../CurrencyPurchaseSearchModel.cs | 1 + .../SearchModels/CurrencySearchModel.cs | 1 + .../ViewModels/CreditProgramViewModel.cs | 5 +++- .../ViewModels/CurrencyPurchaseViewModel.cs | 5 ++-- .../ViewModels/CurrencyViewModel.cs | 5 +++- .../Models/ICreditProgramModel.cs | 1 + Bank/BankDataModels/Models/ICurrencyModel.cs | 1 + .../Implements/CreditProgramStorage.cs | 28 +++++++++++++------ .../Implements/CurrencyStorage.cs | 28 +++++++++++++------ .../Models/CreditProgram.cs | 8 ++++-- Bank/BankDatabaseImplement/Models/Currency.cs | 7 +++++ 14 files changed, 71 insertions(+), 22 deletions(-) diff --git a/Bank/BankContracts/BindingModels/CreditProgramBindingModel.cs b/Bank/BankContracts/BindingModels/CreditProgramBindingModel.cs index b06cdd7..5cf62cf 100644 --- a/Bank/BankContracts/BindingModels/CreditProgramBindingModel.cs +++ b/Bank/BankContracts/BindingModels/CreditProgramBindingModel.cs @@ -16,5 +16,6 @@ namespace BankContracts.BindingModels public Dictionary CreditProgramCurrencies { get; set; } = new(); public int Id { get; set; } + public int BankOperatorId { get; set; } } } diff --git a/Bank/BankContracts/BindingModels/CurrencyBindingModel.cs b/Bank/BankContracts/BindingModels/CurrencyBindingModel.cs index 544c68a..9b82541 100644 --- a/Bank/BankContracts/BindingModels/CurrencyBindingModel.cs +++ b/Bank/BankContracts/BindingModels/CurrencyBindingModel.cs @@ -11,5 +11,6 @@ namespace BankContracts.BindingModels { public string Name { get; set; } = String.Empty; public int Id { get; set; } + public int BankOperatorId { get; set; } } } diff --git a/Bank/BankContracts/SearchModels/CreditProgramSearchModel.cs b/Bank/BankContracts/SearchModels/CreditProgramSearchModel.cs index 3791aeb..fa5b1f4 100644 --- a/Bank/BankContracts/SearchModels/CreditProgramSearchModel.cs +++ b/Bank/BankContracts/SearchModels/CreditProgramSearchModel.cs @@ -9,5 +9,6 @@ namespace BankContracts.SearchModels public class CreditProgramSearchModel { public int? Id { get; set; } + public int? BankOperatorId { get; set; } } } diff --git a/Bank/BankContracts/SearchModels/CurrencyPurchaseSearchModel.cs b/Bank/BankContracts/SearchModels/CurrencyPurchaseSearchModel.cs index 2b5274c..14b8fee 100644 --- a/Bank/BankContracts/SearchModels/CurrencyPurchaseSearchModel.cs +++ b/Bank/BankContracts/SearchModels/CurrencyPurchaseSearchModel.cs @@ -9,5 +9,6 @@ namespace BankContracts.SearchModels public class CurrencyPurchaseSearchModel { public int? Id { get; set; } + public int? BankOperatorId { get; set; } } } diff --git a/Bank/BankContracts/SearchModels/CurrencySearchModel.cs b/Bank/BankContracts/SearchModels/CurrencySearchModel.cs index bd12811..028344e 100644 --- a/Bank/BankContracts/SearchModels/CurrencySearchModel.cs +++ b/Bank/BankContracts/SearchModels/CurrencySearchModel.cs @@ -9,5 +9,6 @@ namespace BankContracts.SearchModels public class CurrencySearchModel { public int? Id { get; set; } + public int? BankOperatorId { get; set; } } } diff --git a/Bank/BankContracts/ViewModels/CreditProgramViewModel.cs b/Bank/BankContracts/ViewModels/CreditProgramViewModel.cs index d858db5..fb9cc67 100644 --- a/Bank/BankContracts/ViewModels/CreditProgramViewModel.cs +++ b/Bank/BankContracts/ViewModels/CreditProgramViewModel.cs @@ -11,11 +11,14 @@ namespace BankContracts.ViewModels public class CreditProgramViewModel : ICreditProgramModel { [DisplayName("Название кредитной программы")] - public string Name { get; set; } = String.Empty; + public string Name { get; set; } = string.Empty; [DisplayName("Процент кредитования")] public float Percent { get; set; } public Dictionary CreditProgramCurrencies { get; set; } = new(); [DisplayName("Номер программы")] public int Id { get; set; } + public int BankOperatorId { get; set; } + [DisplayName("ФИО оператора")] + public string BankOperatorFIO { get; set; } = string.Empty; } } diff --git a/Bank/BankContracts/ViewModels/CurrencyPurchaseViewModel.cs b/Bank/BankContracts/ViewModels/CurrencyPurchaseViewModel.cs index eac2c69..2692a51 100644 --- a/Bank/BankContracts/ViewModels/CurrencyPurchaseViewModel.cs +++ b/Bank/BankContracts/ViewModels/CurrencyPurchaseViewModel.cs @@ -16,11 +16,12 @@ namespace BankContracts.ViewModels public DateTime PurchaseDate { get; set; } = DateTime.Now.Date; public int BankOperatorId { get; set; } [DisplayName("ФИО оператора")] - public string BankOperatorName { get; set; } + public string BankOperatorName { get; set; } = string.Empty; public int CurrencyId { get; set; } [DisplayName("Название валюты")] - public string CurrencyName { get; set; } + public string CurrencyName { get; set; } = string.Empty; [DisplayName("Номер покупки")] public int Id { get; set; } + } } diff --git a/Bank/BankContracts/ViewModels/CurrencyViewModel.cs b/Bank/BankContracts/ViewModels/CurrencyViewModel.cs index dc94e9d..739f3c0 100644 --- a/Bank/BankContracts/ViewModels/CurrencyViewModel.cs +++ b/Bank/BankContracts/ViewModels/CurrencyViewModel.cs @@ -11,8 +11,11 @@ namespace BankContracts.ViewModels public class CurrencyViewModel : ICurrencyModel { [DisplayName("Название валюты")] - public string Name { get; set; } = String.Empty; + public string Name { get; set; } = string.Empty; [DisplayName("Номер валюты")] public int Id { get; set; } + public int BankOperatorId { get; set; } + [DisplayName("ФИО оператора")] + public string BankOperatorName { get; set; } = string.Empty; } } diff --git a/Bank/BankDataModels/Models/ICreditProgramModel.cs b/Bank/BankDataModels/Models/ICreditProgramModel.cs index feca505..9c49ef5 100644 --- a/Bank/BankDataModels/Models/ICreditProgramModel.cs +++ b/Bank/BankDataModels/Models/ICreditProgramModel.cs @@ -10,6 +10,7 @@ namespace BankDataModels.Models { string Name { get;} float Percent { get;} + int BankOperatorId { get;} Dictionary CreditProgramCurrencies { get; } } } diff --git a/Bank/BankDataModels/Models/ICurrencyModel.cs b/Bank/BankDataModels/Models/ICurrencyModel.cs index fe76b06..3bc14b8 100644 --- a/Bank/BankDataModels/Models/ICurrencyModel.cs +++ b/Bank/BankDataModels/Models/ICurrencyModel.cs @@ -9,5 +9,6 @@ namespace BankDataModels.Models public interface ICurrencyModel : IId { string Name { get; } + int BankOperatorId { get; } } } diff --git a/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs b/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs index 16d2f6b..5ea918d 100644 --- a/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs @@ -3,6 +3,7 @@ using BankContracts.SearchModels; using BankContracts.StoragesContracts; using BankContracts.ViewModels; using BankDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; @@ -33,28 +34,39 @@ namespace BankDatabaseImplement.Implements return null; } using var context = new BankDatabase(); - return context.CreditPrograms + return context.CreditPrograms.Include(x => x.BankOperator) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } public List GetFilteredList(CreditProgramSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.BankOperatorId.HasValue) { return new(); } - using var context = new BankDatabase(); - return context.CreditPrograms - .Where(x => x.Id == model.Id) - .Select(x => x.GetViewModel) - .ToList(); + if (model.BankOperatorId.HasValue) + { + using var context = new BankDatabase(); + return context.CreditPrograms.Include(x => x.BankOperator) + .Where(x => x.BankOperatorId == model.BankOperatorId) + .Select(x => x.GetViewModel) + .ToList(); + } + else + { + using var context = new BankDatabase(); + return context.CreditPrograms.Include(x => x.BankOperator) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } } public List GetFullList() { using var context = new BankDatabase(); - return context.CreditPrograms + return context.CreditPrograms.Include(x => x.BankOperator) .Select(x => x.GetViewModel) .ToList(); } diff --git a/Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs b/Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs index 6676d0d..ca97ac9 100644 --- a/Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs @@ -3,6 +3,7 @@ using BankContracts.SearchModels; using BankContracts.StoragesContracts; using BankContracts.ViewModels; using BankDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; @@ -33,28 +34,39 @@ namespace BankDatabaseImplement.Implements return null; } using var context = new BankDatabase(); - return context.Currencies + return context.Currencies.Include(x => x.BankOperator) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } public List GetFilteredList(CurrencySearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.BankOperatorId.HasValue) { return new(); } - using var context = new BankDatabase(); - return context.Currencies - .Where(x => x.Id == model.Id) - .Select(x => x.GetViewModel) - .ToList(); + if (model.BankOperatorId.HasValue) + { + using var context = new BankDatabase(); + return context.Currencies.Include(x => x.BankOperator) + .Where(x => x.BankOperatorId == model.BankOperatorId) + .Select(x => x.GetViewModel) + .ToList(); + } + else + { + using var context = new BankDatabase(); + return context.Currencies.Include(x => x.BankOperator) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } } public List GetFullList() { using var context = new BankDatabase(); - return context.Currencies + return context.Currencies.Include(x => x.BankOperator) .Select(x => x.GetViewModel) .ToList(); } diff --git a/Bank/BankDatabaseImplement/Models/CreditProgram.cs b/Bank/BankDatabaseImplement/Models/CreditProgram.cs index 90a1888..39ed948 100644 --- a/Bank/BankDatabaseImplement/Models/CreditProgram.cs +++ b/Bank/BankDatabaseImplement/Models/CreditProgram.cs @@ -18,6 +18,8 @@ namespace BankDatabaseImplement.Models public float Percent { get; set; } [Required] public string Name { get; set; } + public int BankOperatorId { get; set; } + public virtual BankOperator BankOperator { get; set; } = new(); private Dictionary? _creditProgramCurrencies = null; [NotMapped] @@ -49,7 +51,9 @@ namespace BankDatabaseImplement.Models Currencies = model.CreditProgramCurrencies.Select(x => new CreditProgramCurrency { Currency = context.Currencies.First(y => y.Id == x.Key) - }).ToList() + }).ToList(), + BankOperatorId = model.BankOperatorId, + BankOperator = context.BankOperators.First(x => x.Id == model.BankOperatorId), }; } public void Update(CreditProgramBindingModel? model) @@ -73,7 +77,7 @@ namespace BankDatabaseImplement.Models var creditProgramsCurrencies = context.CreditProgramCurrencies.Where(rec => rec.CreditProgramId == model.Id).ToList(); if (creditProgramsCurrencies != null && creditProgramsCurrencies.Count > 0) { - context.CreditProgramCurrencies.RemoveRange(creditProgramsCurrencies.Where(rec => !model.CreditProgramCurrencies.ContainsKey(rec.DealId))); + context.CreditProgramCurrencies.RemoveRange(creditProgramsCurrencies.Where(rec => !model.CreditProgramCurrencies.ContainsKey(rec.CreditProgramId))); context.SaveChanges(); var creditProgram = context.CreditPrograms.First(x => x.Id == Id); foreach (var updateCurrency in creditProgramsCurrencies) diff --git a/Bank/BankDatabaseImplement/Models/Currency.cs b/Bank/BankDatabaseImplement/Models/Currency.cs index 05abeae..9f8b501 100644 --- a/Bank/BankDatabaseImplement/Models/Currency.cs +++ b/Bank/BankDatabaseImplement/Models/Currency.cs @@ -16,6 +16,8 @@ namespace BankDatabaseImplement.Models public int Id { get; set; } [Required] public string Name { get; set; } + public int BankOperatorId { get; set; } + public virtual BankOperator BankOperator { get; set; } = new(); public static Currency? Create(BankDatabase context, CurrencyBindingModel model) { if (model == null) @@ -26,7 +28,10 @@ namespace BankDatabaseImplement.Models { Id = model.Id, Name = model.Name, + BankOperatorId = model.BankOperatorId, + BankOperator = context.BankOperators.First(x => x.Id == model.BankOperatorId), }; + } public static Currency? Create(BankDatabase context, CurrencyViewModel model) { @@ -34,6 +39,8 @@ namespace BankDatabaseImplement.Models { Id = model.Id, Name = model.Name, + BankOperatorId = model.BankOperatorId, + BankOperator = context.BankOperators.First(x => x.Id == model.BankOperatorId), }; }