Merge branch 'main' of http://student.git.athene.tech/Andrey_Abazov/CourseWork_Bank
This commit is contained in:
commit
af59eea06b
@ -16,5 +16,6 @@ namespace BankContracts.BindingModels
|
|||||||
public Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; set; } = new();
|
public Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; set; } = new();
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public int BankOperatorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ namespace BankContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public string Name { get; set; } = String.Empty;
|
public string Name { get; set; } = String.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public int BankOperatorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@ namespace BankContracts.SearchModels
|
|||||||
public class CreditProgramSearchModel
|
public class CreditProgramSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? BankOperatorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@ namespace BankContracts.SearchModels
|
|||||||
public class CurrencyPurchaseSearchModel
|
public class CurrencyPurchaseSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? BankOperatorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@ namespace BankContracts.SearchModels
|
|||||||
public class CurrencySearchModel
|
public class CurrencySearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? BankOperatorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,14 @@ namespace BankContracts.ViewModels
|
|||||||
public class CreditProgramViewModel : ICreditProgramModel
|
public class CreditProgramViewModel : ICreditProgramModel
|
||||||
{
|
{
|
||||||
[DisplayName("Название кредитной программы")]
|
[DisplayName("Название кредитной программы")]
|
||||||
public string Name { get; set; } = String.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[DisplayName("Процент кредитования")]
|
[DisplayName("Процент кредитования")]
|
||||||
public float Percent { get; set; }
|
public float Percent { get; set; }
|
||||||
public Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; set; } = new();
|
public Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; set; } = new();
|
||||||
[DisplayName("Номер программы")]
|
[DisplayName("Номер программы")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public int BankOperatorId { get; set; }
|
||||||
|
[DisplayName("ФИО оператора")]
|
||||||
|
public string BankOperatorFIO { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,12 @@ namespace BankContracts.ViewModels
|
|||||||
public DateTime PurchaseDate { get; set; } = DateTime.Now.Date;
|
public DateTime PurchaseDate { get; set; } = DateTime.Now.Date;
|
||||||
public int BankOperatorId { get; set; }
|
public int BankOperatorId { get; set; }
|
||||||
[DisplayName("ФИО оператора")]
|
[DisplayName("ФИО оператора")]
|
||||||
public string BankOperatorName { get; set; }
|
public string BankOperatorName { get; set; } = string.Empty;
|
||||||
public int CurrencyId { get; set; }
|
public int CurrencyId { get; set; }
|
||||||
[DisplayName("Название валюты")]
|
[DisplayName("Название валюты")]
|
||||||
public string CurrencyName { get; set; }
|
public string CurrencyName { get; set; } = string.Empty;
|
||||||
[DisplayName("Номер покупки")]
|
[DisplayName("Номер покупки")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,11 @@ namespace BankContracts.ViewModels
|
|||||||
public class CurrencyViewModel : ICurrencyModel
|
public class CurrencyViewModel : ICurrencyModel
|
||||||
{
|
{
|
||||||
[DisplayName("Название валюты")]
|
[DisplayName("Название валюты")]
|
||||||
public string Name { get; set; } = String.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[DisplayName("Номер валюты")]
|
[DisplayName("Номер валюты")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public int BankOperatorId { get; set; }
|
||||||
|
[DisplayName("ФИО оператора")]
|
||||||
|
public string BankOperatorName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace BankDataModels.Models
|
|||||||
{
|
{
|
||||||
string Name { get;}
|
string Name { get;}
|
||||||
float Percent { get;}
|
float Percent { get;}
|
||||||
|
int BankOperatorId { get;}
|
||||||
Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; }
|
Dictionary<int, ICurrencyModel> CreditProgramCurrencies { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@ namespace BankDataModels.Models
|
|||||||
public interface ICurrencyModel : IId
|
public interface ICurrencyModel : IId
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
int BankOperatorId { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
88
Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs
Normal file
88
Bank/BankDatabaseImplement/Implements/BankOperatorStorage.cs
Normal file
@ -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<BankOperatorViewModel> 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<BankOperatorViewModel> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
101
Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs
Normal file
101
Bank/BankDatabaseImplement/Implements/CreditProgramStorage.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
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 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.Include(x => x.BankOperator)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CreditProgramViewModel> GetFilteredList(CreditProgramSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue && !model.BankOperatorId.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
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<CreditProgramViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.CreditPrograms.Include(x => x.BankOperator)
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<CurrencyPurchaseViewModel> 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<CurrencyPurchaseViewModel> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ using BankContracts.SearchModels;
|
|||||||
using BankContracts.StoragesContracts;
|
using BankContracts.StoragesContracts;
|
||||||
using BankContracts.ViewModels;
|
using BankContracts.ViewModels;
|
||||||
using BankDatabaseImplement.Models;
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -33,28 +34,39 @@ namespace BankDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new BankDatabase();
|
using var context = new BankDatabase();
|
||||||
return context.Currencies
|
return context.Currencies.Include(x => x.BankOperator)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CurrencyViewModel> GetFilteredList(CurrencySearchModel model)
|
public List<CurrencyViewModel> GetFilteredList(CurrencySearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && !model.BankOperatorId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new BankDatabase();
|
if (model.BankOperatorId.HasValue)
|
||||||
return context.Currencies
|
{
|
||||||
.Where(x => x.Id == model.Id)
|
using var context = new BankDatabase();
|
||||||
.Select(x => x.GetViewModel)
|
return context.Currencies.Include(x => x.BankOperator)
|
||||||
.ToList();
|
.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<CurrencyViewModel> GetFullList()
|
public List<CurrencyViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new BankDatabase();
|
using var context = new BankDatabase();
|
||||||
return context.Currencies
|
return context.Currencies.Include(x => x.BankOperator)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ namespace BankDatabaseImplement.Models
|
|||||||
public float Percent { get; set; }
|
public float Percent { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public int BankOperatorId { get; set; }
|
||||||
|
public virtual BankOperator BankOperator { get; set; } = new();
|
||||||
|
|
||||||
private Dictionary<int, ICurrencyModel>? _creditProgramCurrencies = null;
|
private Dictionary<int, ICurrencyModel>? _creditProgramCurrencies = null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
@ -49,7 +51,9 @@ namespace BankDatabaseImplement.Models
|
|||||||
Currencies = model.CreditProgramCurrencies.Select(x => new CreditProgramCurrency
|
Currencies = model.CreditProgramCurrencies.Select(x => new CreditProgramCurrency
|
||||||
{
|
{
|
||||||
Currency = context.Currencies.First(y => y.Id == x.Key)
|
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)
|
public void Update(CreditProgramBindingModel? model)
|
||||||
@ -73,7 +77,7 @@ namespace BankDatabaseImplement.Models
|
|||||||
var creditProgramsCurrencies = context.CreditProgramCurrencies.Where(rec => rec.CreditProgramId == model.Id).ToList();
|
var creditProgramsCurrencies = context.CreditProgramCurrencies.Where(rec => rec.CreditProgramId == model.Id).ToList();
|
||||||
if (creditProgramsCurrencies != null && creditProgramsCurrencies.Count > 0)
|
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();
|
context.SaveChanges();
|
||||||
var creditProgram = context.CreditPrograms.First(x => x.Id == Id);
|
var creditProgram = context.CreditPrograms.First(x => x.Id == Id);
|
||||||
foreach (var updateCurrency in creditProgramsCurrencies)
|
foreach (var updateCurrency in creditProgramsCurrencies)
|
||||||
|
@ -16,6 +16,8 @@ namespace BankDatabaseImplement.Models
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }
|
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)
|
public static Currency? Create(BankDatabase context, CurrencyBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -26,7 +28,10 @@ namespace BankDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
|
BankOperatorId = model.BankOperatorId,
|
||||||
|
BankOperator = context.BankOperators.First(x => x.Id == model.BankOperatorId),
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
public static Currency? Create(BankDatabase context, CurrencyViewModel model)
|
public static Currency? Create(BankDatabase context, CurrencyViewModel model)
|
||||||
{
|
{
|
||||||
@ -34,6 +39,8 @@ namespace BankDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
|
BankOperatorId = model.BankOperatorId,
|
||||||
|
BankOperator = context.BankOperators.First(x => x.Id == model.BankOperatorId),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user