я это не понимаю, мне это не интересно, вот мне лично не интересно, за других сказать не могу
This commit is contained in:
parent
c175b499f0
commit
27bed74b89
74
Bank/Bank.sln
Normal file
74
Bank/Bank.sln
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.9.34728.123
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankContracts", "BankContracts\BankContracts.csproj", "{610931F8-3291-4861-BD62-2DC7ED1FE95A}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F} = {01E07151-F43D-469A-9415-AF4497758A4F}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankDataModels", "BankDataModels\BankDataModels.csproj", "{01E07151-F43D-469A-9415-AF4497758A4F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankBusinessLogic", "BankBusinessLogic\BankBusinessLogic.csproj", "{CF140DCA-FC71-444F-9458-373ED9570BCD}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A} = {610931F8-3291-4861-BD62-2DC7ED1FE95A}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankDatabaseImplement", "BankDatabaseImplement\BankDatabaseImplement.csproj", "{43394408-5D9A-494F-8A2F-8B35CD5C1E89}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F} = {01E07151-F43D-469A-9415-AF4497758A4F}
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A} = {610931F8-3291-4861-BD62-2DC7ED1FE95A}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankRestApi", "BankRestApi\BankRestApi.csproj", "{4417C383-C505-4329-89A9-376D7F21B43F}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{43394408-5D9A-494F-8A2F-8B35CD5C1E89} = {43394408-5D9A-494F-8A2F-8B35CD5C1E89}
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A} = {610931F8-3291-4861-BD62-2DC7ED1FE95A}
|
||||||
|
{CF140DCA-FC71-444F-9458-373ED9570BCD} = {CF140DCA-FC71-444F-9458-373ED9570BCD}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankWorkerApp", "BankWorkerApp\BankWorkerApp.csproj", "{E86F66DE-77A7-46B6-AB90-C8E5B7B13875}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{4417C383-C505-4329-89A9-376D7F21B43F} = {4417C383-C505-4329-89A9-376D7F21B43F}
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A} = {610931F8-3291-4861-BD62-2DC7ED1FE95A}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{610931F8-3291-4861-BD62-2DC7ED1FE95A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{01E07151-F43D-469A-9415-AF4497758A4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CF140DCA-FC71-444F-9458-373ED9570BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CF140DCA-FC71-444F-9458-373ED9570BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CF140DCA-FC71-444F-9458-373ED9570BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CF140DCA-FC71-444F-9458-373ED9570BCD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{43394408-5D9A-494F-8A2F-8B35CD5C1E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{43394408-5D9A-494F-8A2F-8B35CD5C1E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{43394408-5D9A-494F-8A2F-8B35CD5C1E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{43394408-5D9A-494F-8A2F-8B35CD5C1E89}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4417C383-C505-4329-89A9-376D7F21B43F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4417C383-C505-4329-89A9-376D7F21B43F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4417C383-C505-4329-89A9-376D7F21B43F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4417C383-C505-4329-89A9-376D7F21B43F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E86F66DE-77A7-46B6-AB90-C8E5B7B13875}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E86F66DE-77A7-46B6-AB90-C8E5B7B13875}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E86F66DE-77A7-46B6-AB90-C8E5B7B13875}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E86F66DE-77A7-46B6-AB90-C8E5B7B13875}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {BAA06038-7884-4BD5-8A73-81AF38684112}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
17
Bank/BankBusinessLogic/BankBusinessLogic.csproj
Normal file
17
Bank/BankBusinessLogic/BankBusinessLogic.csproj
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
165
Bank/BankBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
165
Bank/BankBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ClientLogic : IClientLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
public ClientLogic(ILogger<ClientLogic> logger,
|
||||||
|
IClientStorage clientStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
|
public bool Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Snils: {Snils}", model.Snils);
|
||||||
|
if (_clientStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadList. ClientSurname: {ClientSurname} {ClientName} " +
|
||||||
|
"{ClientPatronomic}. Snils: {Snils}", model?.ClientSurname,
|
||||||
|
model?.ClientName, model?.ClientPatronymic, model?.Snils);
|
||||||
|
var list = model == null ? _clientStorage.GetFullList() :
|
||||||
|
_clientStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadElement. ClientFullname: {ClientSurname} {ClientName} " +
|
||||||
|
"{ClientPatronomic}. Snils: {Snils}", model.ClientSurname,
|
||||||
|
model.ClientName, model.ClientPatronymic, model.Snils);
|
||||||
|
var element = _clientStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Snils: {Snils}",
|
||||||
|
element.Snils);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(ClientBindingModel model,
|
||||||
|
bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Snils))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует СНИЛС клиента",
|
||||||
|
nameof(model.Snils));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientSurname))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует фамилия клиента",
|
||||||
|
nameof(model.ClientSurname));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует имя клиента",
|
||||||
|
nameof(model.ClientName));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientPatronymic))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует отчество клиента",
|
||||||
|
nameof(model.ClientPatronymic));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Phone))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует номер телефона клиента",
|
||||||
|
nameof(model.Phone));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.PasswordHash))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует пароль клиента",
|
||||||
|
nameof(model.PasswordHash));
|
||||||
|
}
|
||||||
|
if (model.WorkerId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Идентификатор работника должен быть больше 0",
|
||||||
|
nameof(model.WorkerId));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Client. Snils: {Snils}. ClientFullname: " +
|
||||||
|
"{ClientSurname} {ClientName} {ClientPatronymic}. Phone: " +
|
||||||
|
"{Phone}. Email: {Email}. PasswordHash: {PasswordHash}.",
|
||||||
|
model.Snils, model.ClientSurname, model.ClientName,
|
||||||
|
model.ClientPatronymic, model.Phone, model.Email,
|
||||||
|
model.PasswordHash);
|
||||||
|
var elementByEmail = _clientStorage.GetElement(
|
||||||
|
new ClientSearchModel
|
||||||
|
{
|
||||||
|
Email = model.Email,
|
||||||
|
});
|
||||||
|
var elementByPhone = _clientStorage.GetElement(
|
||||||
|
new ClientSearchModel
|
||||||
|
{
|
||||||
|
Phone = model.Phone,
|
||||||
|
});
|
||||||
|
if ((elementByEmail != null && elementByEmail.Snils != model.Snils)
|
||||||
|
|| (elementByPhone != null && elementByPhone.Snils
|
||||||
|
!= model.Snils))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Клиент с такой почтой " +
|
||||||
|
"или номером телефона уже существует");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
121
Bank/BankBusinessLogic/BusinessLogics/CurrencyLogic.cs
Normal file
121
Bank/BankBusinessLogic/BusinessLogics/CurrencyLogic.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class CurrencyLogic : ICurrencyLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ICurrencyStorage _currencyStorage;
|
||||||
|
public CurrencyLogic(ILogger<CurrencyLogic> logger,
|
||||||
|
ICurrencyStorage currencyStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_currencyStorage = currencyStorage;
|
||||||
|
}
|
||||||
|
public bool Create(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_currencyStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_currencyStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_currencyStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<CurrencyViewModel>? ReadList(CurrencySearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadList. CurrencyName: {CurrencyName}. Id: {Id}",
|
||||||
|
model?.CurrencyName, model?.Id);
|
||||||
|
var list = model == null ? _currencyStorage.GetFullList() :
|
||||||
|
_currencyStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public CurrencyViewModel? ReadElement(CurrencySearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadElement. CurrencyName: {CurrencyName}. Id: {Id}",
|
||||||
|
model.CurrencyName, model.Id);
|
||||||
|
var element = _currencyStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(CurrencyBindingModel model,
|
||||||
|
bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.CurrencyName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует название валюты",
|
||||||
|
nameof(model.CurrencyName));
|
||||||
|
}
|
||||||
|
if (model.Course <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Курс должен быть больше 0",
|
||||||
|
nameof(model.Course));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Currency. Id: {Id}. CurrencyName: " +
|
||||||
|
"{CurrencyName}. Course: {Course}.",
|
||||||
|
model.Id, model.CurrencyName, model.Course);
|
||||||
|
var element = _currencyStorage.GetElement(new CurrencySearchModel
|
||||||
|
{
|
||||||
|
CurrencyName = model.CurrencyName,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Курс с таким названием уже существует");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
108
Bank/BankBusinessLogic/BusinessLogics/DepositLogic.cs
Normal file
108
Bank/BankBusinessLogic/BusinessLogics/DepositLogic.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class DepositLogic : IDepositLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IDepositStorage _depositStorage;
|
||||||
|
public DepositLogic(ILogger<DepositLogic> logger,
|
||||||
|
IDepositStorage depositStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_depositStorage = depositStorage;
|
||||||
|
}
|
||||||
|
public bool Create(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_depositStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_depositStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_depositStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<DepositViewModel>? ReadList(DepositSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
|
var list = model == null ? _depositStorage.GetFullList() :
|
||||||
|
_depositStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public DepositViewModel? ReadElement(DepositSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
|
var element = _depositStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(DepositBindingModel model,
|
||||||
|
bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.WorkerId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Идентификатор работника должен быть больше 0",
|
||||||
|
nameof(model.WorkerId));
|
||||||
|
}
|
||||||
|
if (model.Sum <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Сумма должна быть больше 0",
|
||||||
|
nameof(model.Sum));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Deposit. Id: {Id}. WorkerId: {WorkerId}." +
|
||||||
|
"Sum: {Sum}. OpeningDate: {OpeningDate}.",
|
||||||
|
model.Id, model.WorkerId, model.Sum, model.OpeningDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
121
Bank/BankBusinessLogic/BusinessLogics/ProgramLogic.cs
Normal file
121
Bank/BankBusinessLogic/BusinessLogics/ProgramLogic.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ProgramLogic : IProgramLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProgramStorage _programStorage;
|
||||||
|
public ProgramLogic(ILogger<ProgramLogic> logger,
|
||||||
|
IProgramStorage programStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_programStorage = programStorage;
|
||||||
|
}
|
||||||
|
public bool Create(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_programStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_programStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_programStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<ProgramViewModel>? ReadList(ProgramSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadList. ProgramName: {ProgramName}. Id: {Id}",
|
||||||
|
model?.ProgramName, model?.Id);
|
||||||
|
var list = model == null ? _programStorage.GetFullList() :
|
||||||
|
_programStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public ProgramViewModel? ReadElement(ProgramSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadElement. ProgramName: {ProgramName}. Id: {Id}",
|
||||||
|
model.ProgramName, model.Id);
|
||||||
|
var element = _programStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(ProgramBindingModel model,
|
||||||
|
bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ProgramName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует название кредитной программы",
|
||||||
|
nameof(model.ProgramName));
|
||||||
|
}
|
||||||
|
if (model.InterestRate < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Процентная ставка должна быть не менее 0",
|
||||||
|
nameof(model.InterestRate));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Program. Id: {Id}. ProgramName: " +
|
||||||
|
"{ProgramName}. InterestRate: {InterestRate}.",
|
||||||
|
model.Id, model.ProgramName, model.InterestRate);
|
||||||
|
var element = _programStorage.GetElement(new ProgramSearchModel
|
||||||
|
{
|
||||||
|
ProgramName = model.ProgramName,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Кредитная программа с таким названием уже существует");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
Bank/BankBusinessLogic/BusinessLogics/RefillLogic.cs
Normal file
114
Bank/BankBusinessLogic/BusinessLogics/RefillLogic.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class RefillLogic : IRefillLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IRefillStorage _refillStorage;
|
||||||
|
public RefillLogic(ILogger<RefillLogic> logger,
|
||||||
|
IRefillStorage refillStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_refillStorage = refillStorage;
|
||||||
|
}
|
||||||
|
public bool Create(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_refillStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_refillStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_refillStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<RefillViewModel>? ReadList(RefillSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
|
var list = model == null ? _refillStorage.GetFullList() :
|
||||||
|
_refillStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public RefillViewModel? ReadElement(RefillSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
|
var element = _refillStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(RefillBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.DepositId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Идентификатор вклада должен быть больше 0",
|
||||||
|
nameof(model.DepositId));
|
||||||
|
}
|
||||||
|
if (model.WorkerId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Идентификатор работника должен быть больше 0",
|
||||||
|
nameof(model.WorkerId));
|
||||||
|
}
|
||||||
|
if (model.Sum <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Сумма должна быть больше 0",
|
||||||
|
nameof(model.Sum));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Refill. Id: {Id}. DepositId: " +
|
||||||
|
"{DepositId}. WorkerId: {WorkerId}. Sum: {Sum}. " +
|
||||||
|
"RefillDate: {RefillDate}.", model.Id, model.DepositId,
|
||||||
|
model.WorkerId, model.Sum, model.RefillDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
Bank/BankBusinessLogic/BusinessLogics/TermLogic.cs
Normal file
107
Bank/BankBusinessLogic/BusinessLogics/TermLogic.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class TermLogic : ITermLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ITermStorage _termStorage;
|
||||||
|
public TermLogic(ILogger<TermLogic> logger,
|
||||||
|
ITermStorage termStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_termStorage = termStorage;
|
||||||
|
}
|
||||||
|
public bool Create(TermBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_termStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(TermBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_termStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(TermBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_termStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<TermViewModel>? ReadList(TermSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
|
var list = model == null ? _termStorage.GetFullList() :
|
||||||
|
_termStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public TermViewModel? ReadElement(TermSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
|
var element = _termStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(TermBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.ProgramId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Идентификатор кредитной программы должен быть больше 0",
|
||||||
|
nameof(model.ProgramId));
|
||||||
|
}
|
||||||
|
if (model.Duration <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Длительность должна быть больше 0",
|
||||||
|
nameof(model.Duration));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Term. Id: {Id}. ProgramId: " +
|
||||||
|
"{ProgramId}. Duration: {Duration}.", model.Id,
|
||||||
|
model.ProgramId, model.Duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
157
Bank/BankBusinessLogic/BusinessLogics/WorkerLogic.cs
Normal file
157
Bank/BankBusinessLogic/BusinessLogics/WorkerLogic.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class WorkerLogic : IWorkerLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IWorkerStorage _workerStorage;
|
||||||
|
public WorkerLogic(ILogger<WorkerLogic> logger,
|
||||||
|
IWorkerStorage workerStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_workerStorage = workerStorage;
|
||||||
|
}
|
||||||
|
public bool Create(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_workerStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadList. WorkerSurname: {WorkerSurname} {WorkerName} " +
|
||||||
|
"{WorkerPatronomic}. Id: {Id}", model?.WorkerSurname,
|
||||||
|
model?.WorkerName, model?.WorkerPatronymic, model?.Id);
|
||||||
|
var list = model == null ? _workerStorage.GetFullList() :
|
||||||
|
_workerStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? ReadElement(WorkerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ReadElement. WorkerFullname: {WorkerSurname} {WorkerName} " +
|
||||||
|
"{WorkerPatronomic}. Id: {Id}", model.WorkerSurname,
|
||||||
|
model.WorkerName, model.WorkerPatronymic, model.Id);
|
||||||
|
var element = _workerStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void CheckModel(WorkerBindingModel model,
|
||||||
|
bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.WorkerSurname))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует фамилия работника",
|
||||||
|
nameof(model.WorkerSurname));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.WorkerName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует имя работника",
|
||||||
|
nameof(model.WorkerName));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.WorkerPatronymic))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует отчество работника",
|
||||||
|
nameof(model.WorkerPatronymic));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Phone))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует номера телефона работника",
|
||||||
|
nameof(model.Phone));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует почта работника",
|
||||||
|
nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.PasswordHash))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(
|
||||||
|
"Отсутствует пароль работника",
|
||||||
|
nameof(model.PasswordHash));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Worker. Id: {Id}. WorkerFullname: " +
|
||||||
|
"{WorkerSurname} {WorkerName} {WorkerPatronymic}. Phone: " +
|
||||||
|
"{Phone}. Email: {Email}. PasswordHash: {PasswordHash}.",
|
||||||
|
model.Id, model.WorkerSurname, model.WorkerName,
|
||||||
|
model.WorkerPatronymic, model.Phone, model.Email,
|
||||||
|
model.PasswordHash);
|
||||||
|
var elementByEmail = _workerStorage.GetElement(
|
||||||
|
new WorkerSearchModel
|
||||||
|
{
|
||||||
|
Email = model.Email,
|
||||||
|
});
|
||||||
|
var elementByPhone = _workerStorage.GetElement(
|
||||||
|
new WorkerSearchModel
|
||||||
|
{
|
||||||
|
Phone = model.Phone,
|
||||||
|
});
|
||||||
|
if ((elementByEmail != null && elementByEmail.Id != model.Id)
|
||||||
|
|| (elementByPhone != null && elementByPhone.Id != model.Id))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Работник с такой почтой" +
|
||||||
|
" или номером телефона уже существует");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
Bank/BankContracts/BankContracts.csproj
Normal file
13
Bank/BankContracts/BankContracts.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
20
Bank/BankContracts/BindingModels/ClientBindingModel.cs
Normal file
20
Bank/BankContracts/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ClientBindingModel : IClientModel
|
||||||
|
{
|
||||||
|
public string Snils { get; set; } = string.Empty;
|
||||||
|
public string ClientSurname { get; set; } = string.Empty;
|
||||||
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
public string ClientPatronymic { get; set; } = string.Empty;
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
public string? Email { get; set; } = string.Empty;
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public Dictionary<int, IProgramModel>
|
||||||
|
ClientPrograms { get; set; } = new();
|
||||||
|
public Dictionary<int, IDepositModel>
|
||||||
|
ClientDeposits { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
11
Bank/BankContracts/BindingModels/CurrencyBindingModel.cs
Normal file
11
Bank/BankContracts/BindingModels/CurrencyBindingModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class CurrencyBindingModel : ICurrencyModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string CurrencyName { get; set; } = string.Empty;
|
||||||
|
public double Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BindingModels/DepositBindingModel.cs
Normal file
15
Bank/BankContracts/BindingModels/DepositBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class DepositBindingModel : IDepositModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public double Sum { get; set; }
|
||||||
|
public DateOnly OpeningDate { get; set; } =
|
||||||
|
DateOnly.FromDateTime(DateTime.Now);
|
||||||
|
public Dictionary<int, ICurrencyModel>
|
||||||
|
DepositCurrencies { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
14
Bank/BankContracts/BindingModels/ProgramBindingModel.cs
Normal file
14
Bank/BankContracts/BindingModels/ProgramBindingModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ProgramBindingModel : IProgramModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int CurrencyId { get; set; }
|
||||||
|
public string ProgramName { get; set; } = string.Empty;
|
||||||
|
public double InterestRate { get; set; }
|
||||||
|
public Dictionary<int, ICurrencyModel>
|
||||||
|
ProgramCurrencies { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
14
Bank/BankContracts/BindingModels/RefillBindingModel.cs
Normal file
14
Bank/BankContracts/BindingModels/RefillBindingModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class RefillBindingModel : IRefillModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int DepositId { get; set; }
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public double Sum { get; set; }
|
||||||
|
public DateOnly RefillDate { get; set; } =
|
||||||
|
DateOnly.FromDateTime(DateTime.Now);
|
||||||
|
}
|
||||||
|
}
|
11
Bank/BankContracts/BindingModels/TermBindingModel.cs
Normal file
11
Bank/BankContracts/BindingModels/TermBindingModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class TermBindingModel : ITermModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ProgramId { get; set; }
|
||||||
|
public int Duration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BindingModels/WorkerBindingModel.cs
Normal file
15
Bank/BankContracts/BindingModels/WorkerBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class WorkerBindingModel : IWorkerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string WorkerSurname { get; set; } = string.Empty;
|
||||||
|
public string WorkerName { get; set; } = string.Empty;
|
||||||
|
public string WorkerPatronymic { get; set; } = string.Empty;
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IClientLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IClientLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IClientLogic
|
||||||
|
{
|
||||||
|
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||||
|
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||||
|
bool Create(ClientBindingModel model);
|
||||||
|
bool Update(ClientBindingModel model);
|
||||||
|
bool Delete(ClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/ICurrencyLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/ICurrencyLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ICurrencyLogic
|
||||||
|
{
|
||||||
|
List<CurrencyViewModel>? ReadList(CurrencySearchModel? model);
|
||||||
|
CurrencyViewModel? ReadElement(CurrencySearchModel model);
|
||||||
|
bool Create(CurrencyBindingModel model);
|
||||||
|
bool Update(CurrencyBindingModel model);
|
||||||
|
bool Delete(CurrencyBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IDepositLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IDepositLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IDepositLogic
|
||||||
|
{
|
||||||
|
List<DepositViewModel>? ReadList(DepositSearchModel? model);
|
||||||
|
DepositViewModel? ReadElement(DepositSearchModel model);
|
||||||
|
bool Create(DepositBindingModel model);
|
||||||
|
bool Update(DepositBindingModel model);
|
||||||
|
bool Delete(DepositBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IProgramLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IProgramLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IProgramLogic
|
||||||
|
{
|
||||||
|
List<ProgramViewModel>? ReadList(ProgramSearchModel? model);
|
||||||
|
ProgramViewModel? ReadElement(ProgramSearchModel model);
|
||||||
|
bool Create(ProgramBindingModel model);
|
||||||
|
bool Update(ProgramBindingModel model);
|
||||||
|
bool Delete(ProgramBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IRefillLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IRefillLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IRefillLogic
|
||||||
|
{
|
||||||
|
List<RefillViewModel>? ReadList(RefillSearchModel? model);
|
||||||
|
RefillViewModel? ReadElement(RefillSearchModel model);
|
||||||
|
bool Create(RefillBindingModel model);
|
||||||
|
bool Update(RefillBindingModel model);
|
||||||
|
bool Delete(RefillBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/ITermLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/ITermLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ITermLogic
|
||||||
|
{
|
||||||
|
List<TermViewModel>? ReadList(TermSearchModel? model);
|
||||||
|
TermViewModel? ReadElement(TermSearchModel model);
|
||||||
|
bool Create(TermBindingModel model);
|
||||||
|
bool Update(TermBindingModel model);
|
||||||
|
bool Delete(TermBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IWorkerLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IWorkerLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IWorkerLogic
|
||||||
|
{
|
||||||
|
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
|
||||||
|
WorkerViewModel? ReadElement(WorkerSearchModel model);
|
||||||
|
bool Create(WorkerBindingModel model);
|
||||||
|
bool Update(WorkerBindingModel model);
|
||||||
|
bool Delete(WorkerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
14
Bank/BankContracts/SearchModels/ClientSearchModel.cs
Normal file
14
Bank/BankContracts/SearchModels/ClientSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ClientSearchModel
|
||||||
|
{
|
||||||
|
public string? Snils { get; set; }
|
||||||
|
public string? ClientSurname { get; set; }
|
||||||
|
public string? ClientName { get; set; }
|
||||||
|
public string? ClientPatronymic { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? PasswordHash { get; set; }
|
||||||
|
public int? WorkerId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankContracts/SearchModels/CurrencySearchModel.cs
Normal file
9
Bank/BankContracts/SearchModels/CurrencySearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class CurrencySearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? CurrencyName { get; set; }
|
||||||
|
public double? Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
10
Bank/BankContracts/SearchModels/DepositSearchModel.cs
Normal file
10
Bank/BankContracts/SearchModels/DepositSearchModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class DepositSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? WorkerId { get; set; }
|
||||||
|
public double? Sum { get; set; }
|
||||||
|
public DateOnly? OpeningDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
10
Bank/BankContracts/SearchModels/ProgramSearchModel.cs
Normal file
10
Bank/BankContracts/SearchModels/ProgramSearchModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ProgramSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
public string? ProgramName { get; set; }
|
||||||
|
public double? InterestRate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
Bank/BankContracts/SearchModels/RefillSearchModel.cs
Normal file
11
Bank/BankContracts/SearchModels/RefillSearchModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class RefillSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? DepositId { get; set; }
|
||||||
|
public int? WorkerId { get; set; }
|
||||||
|
public double? Sum { get; set; }
|
||||||
|
public DateOnly? RefillDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankContracts/SearchModels/TermSearchModel.cs
Normal file
9
Bank/BankContracts/SearchModels/TermSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class TermSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? ProgramId { get; set; }
|
||||||
|
public int? Duration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
Bank/BankContracts/SearchModels/WorkerSearchModel.cs
Normal file
12
Bank/BankContracts/SearchModels/WorkerSearchModel.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace BankContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class WorkerSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? WorkerSurname { get; set; }
|
||||||
|
public string? WorkerName { get; set; }
|
||||||
|
public string? WorkerPatronymic { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/IClientStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/IClientStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IClientStorage
|
||||||
|
{
|
||||||
|
List<ClientViewModel> GetFullList();
|
||||||
|
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||||
|
ClientViewModel? GetElement(ClientSearchModel model);
|
||||||
|
ClientViewModel? Insert(ClientBindingModel model);
|
||||||
|
ClientViewModel? Update(ClientBindingModel model);
|
||||||
|
ClientViewModel? Delete(ClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/ICurrencyStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/ICurrencyStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ICurrencyStorage
|
||||||
|
{
|
||||||
|
List<CurrencyViewModel> GetFullList();
|
||||||
|
List<CurrencyViewModel> GetFilteredList(CurrencySearchModel model);
|
||||||
|
CurrencyViewModel? GetElement(CurrencySearchModel model);
|
||||||
|
CurrencyViewModel? Insert(CurrencyBindingModel model);
|
||||||
|
CurrencyViewModel? Update(CurrencyBindingModel model);
|
||||||
|
CurrencyViewModel? Delete(CurrencyBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/IDepositStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/IDepositStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IDepositStorage
|
||||||
|
{
|
||||||
|
List<DepositViewModel> GetFullList();
|
||||||
|
List<DepositViewModel> GetFilteredList(DepositSearchModel model);
|
||||||
|
DepositViewModel? GetElement(DepositSearchModel model);
|
||||||
|
DepositViewModel? Insert(DepositBindingModel model);
|
||||||
|
DepositViewModel? Update(DepositBindingModel model);
|
||||||
|
DepositViewModel? Delete(DepositBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/IProgramStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/IProgramStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IProgramStorage
|
||||||
|
{
|
||||||
|
List<ProgramViewModel> GetFullList();
|
||||||
|
List<ProgramViewModel> GetFilteredList(ProgramSearchModel model);
|
||||||
|
ProgramViewModel? GetElement(ProgramSearchModel model);
|
||||||
|
ProgramViewModel? Insert(ProgramBindingModel model);
|
||||||
|
ProgramViewModel? Update(ProgramBindingModel model);
|
||||||
|
ProgramViewModel? Delete(ProgramBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/IRefillStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/IRefillStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IRefillStorage
|
||||||
|
{
|
||||||
|
List<RefillViewModel> GetFullList();
|
||||||
|
List<RefillViewModel> GetFilteredList(RefillSearchModel model);
|
||||||
|
RefillViewModel? GetElement(RefillSearchModel model);
|
||||||
|
RefillViewModel? Insert(RefillBindingModel model);
|
||||||
|
RefillViewModel? Update(RefillBindingModel model);
|
||||||
|
RefillViewModel? Delete(RefillBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/ITermStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/ITermStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ITermStorage
|
||||||
|
{
|
||||||
|
List<TermViewModel> GetFullList();
|
||||||
|
List<TermViewModel> GetFilteredList(TermSearchModel model);
|
||||||
|
TermViewModel? GetElement(TermSearchModel model);
|
||||||
|
TermViewModel? Insert(TermBindingModel model);
|
||||||
|
TermViewModel? Update(TermBindingModel model);
|
||||||
|
TermViewModel? Delete(TermBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankContracts/StoragesContracts/IWorkerStorage.cs
Normal file
16
Bank/BankContracts/StoragesContracts/IWorkerStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IWorkerStorage
|
||||||
|
{
|
||||||
|
List<WorkerViewModel> GetFullList();
|
||||||
|
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
|
||||||
|
WorkerViewModel? GetElement(WorkerSearchModel model);
|
||||||
|
WorkerViewModel? Insert(WorkerBindingModel model);
|
||||||
|
WorkerViewModel? Update(WorkerBindingModel model);
|
||||||
|
WorkerViewModel? Delete(WorkerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
29
Bank/BankContracts/ViewModels/ClientViewModel.cs
Normal file
29
Bank/BankContracts/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ClientViewModel : IClientModel
|
||||||
|
{
|
||||||
|
[DisplayName("СНИЛС")]
|
||||||
|
public string Snils { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
|
public string ClientSurname { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Имя")]
|
||||||
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Отчество")]
|
||||||
|
public string ClientPatronymic { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Телефон")]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Почта")]
|
||||||
|
public string? Email { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Идентификатор работника")]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
[DisplayName("Хэш пароля")]
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
public Dictionary<int, IProgramModel>
|
||||||
|
ClientPrograms { get; set; } = new();
|
||||||
|
public Dictionary<int, IDepositModel>
|
||||||
|
ClientDeposits { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
15
Bank/BankContracts/ViewModels/CurrencyViewModel.cs
Normal file
15
Bank/BankContracts/ViewModels/CurrencyViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class CurrencyViewModel : ICurrencyModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название")]
|
||||||
|
public string CurrencyName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Курс")]
|
||||||
|
public double Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
20
Bank/BankContracts/ViewModels/DepositViewModel.cs
Normal file
20
Bank/BankContracts/ViewModels/DepositViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class DepositViewModel : IDepositModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Идентификатор сотрудника")]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
[DisplayName("Сумма")]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateOnly OpeningDate { get; set; } =
|
||||||
|
DateOnly.FromDateTime(DateTime.Now);
|
||||||
|
public Dictionary<int, ICurrencyModel>
|
||||||
|
DepositCurrencies { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
17
Bank/BankContracts/ViewModels/ProgramViewModel.cs
Normal file
17
Bank/BankContracts/ViewModels/ProgramViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ProgramViewModel : IProgramModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Идентификатор валюты")]
|
||||||
|
public string ProgramName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Процентная ставка")]
|
||||||
|
public double InterestRate { get; set; }
|
||||||
|
public Dictionary<int, ICurrencyModel>
|
||||||
|
ProgramCurrencies { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
20
Bank/BankContracts/ViewModels/RefillViewModel.cs
Normal file
20
Bank/BankContracts/ViewModels/RefillViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class RefillViewModel : IRefillModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Идентификатор вклада")]
|
||||||
|
public int DepositId { get; set; }
|
||||||
|
[DisplayName("Идентификатор сотрудника")]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
[DisplayName("Сумма")]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[DisplayName("Дата пополнения")]
|
||||||
|
public DateOnly RefillDate { get; set; } =
|
||||||
|
DateOnly.FromDateTime(DateTime.Now);
|
||||||
|
}
|
||||||
|
}
|
17
Bank/BankContracts/ViewModels/TermViewModel.cs
Normal file
17
Bank/BankContracts/ViewModels/TermViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class TermViewModel : ITermModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название кредитной программы")]
|
||||||
|
public int ProgramName { get; set; }
|
||||||
|
[DisplayName("Идентификатор кредитной программы")]
|
||||||
|
public int ProgramId { get; set; }
|
||||||
|
[DisplayName("Длительность")]
|
||||||
|
public int Duration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
23
Bank/BankContracts/ViewModels/WorkerViewModel.cs
Normal file
23
Bank/BankContracts/ViewModels/WorkerViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class WorkerViewModel : IWorkerModel
|
||||||
|
{
|
||||||
|
[DisplayName("Идентификатор")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
|
public string WorkerSurname { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Имя")]
|
||||||
|
public string WorkerName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Отчество")]
|
||||||
|
public string WorkerPatronymic { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Телефон")]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Почта")]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Хэш пароля")]
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankDataModels/BankDataModels.csproj
Normal file
9
Bank/BankDataModels/BankDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
7
Bank/BankDataModels/IId.cs
Normal file
7
Bank/BankDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace BankDataModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
16
Bank/BankDataModels/Models/IClientModel.cs
Normal file
16
Bank/BankDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IClientModel
|
||||||
|
{
|
||||||
|
string Snils { get; }
|
||||||
|
string ClientSurname { get; }
|
||||||
|
string ClientName { get; }
|
||||||
|
string ClientPatronymic { get; }
|
||||||
|
string Phone { get; }
|
||||||
|
string? Email { get; }
|
||||||
|
string PasswordHash { get; }
|
||||||
|
int WorkerId { get; }
|
||||||
|
Dictionary<int, IProgramModel> ClientPrograms { get; }
|
||||||
|
Dictionary<int, IDepositModel> ClientDeposits { get; }
|
||||||
|
}
|
||||||
|
}
|
8
Bank/BankDataModels/Models/ICurrencyModel.cs
Normal file
8
Bank/BankDataModels/Models/ICurrencyModel.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ICurrencyModel : IId
|
||||||
|
{
|
||||||
|
string CurrencyName { get; }
|
||||||
|
double Course { get; }
|
||||||
|
}
|
||||||
|
}
|
10
Bank/BankDataModels/Models/IDepositModel.cs
Normal file
10
Bank/BankDataModels/Models/IDepositModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IDepositModel : IId
|
||||||
|
{
|
||||||
|
int WorkerId { get; }
|
||||||
|
double Sum { get; }
|
||||||
|
DateOnly OpeningDate { get; }
|
||||||
|
Dictionary<int, ICurrencyModel> DepositCurrencies { get; }
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankDataModels/Models/IProgramModel.cs
Normal file
9
Bank/BankDataModels/Models/IProgramModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IProgramModel : IId
|
||||||
|
{
|
||||||
|
string ProgramName { get; }
|
||||||
|
double InterestRate { get; }
|
||||||
|
Dictionary<int, ICurrencyModel> ProgramCurrencies { get; }
|
||||||
|
}
|
||||||
|
}
|
10
Bank/BankDataModels/Models/IRefillModel.cs
Normal file
10
Bank/BankDataModels/Models/IRefillModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IRefillModel : IId
|
||||||
|
{
|
||||||
|
int DepositId { get; }
|
||||||
|
int WorkerId { get; }
|
||||||
|
double Sum { get; }
|
||||||
|
DateOnly RefillDate { get; }
|
||||||
|
}
|
||||||
|
}
|
8
Bank/BankDataModels/Models/ITermModel.cs
Normal file
8
Bank/BankDataModels/Models/ITermModel.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ITermModel : IId
|
||||||
|
{
|
||||||
|
int ProgramId { get; }
|
||||||
|
int Duration { get; }
|
||||||
|
}
|
||||||
|
}
|
12
Bank/BankDataModels/Models/IWorkerModel.cs
Normal file
12
Bank/BankDataModels/Models/IWorkerModel.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace BankDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IWorkerModel : IId
|
||||||
|
{
|
||||||
|
string WorkerSurname { get; }
|
||||||
|
string WorkerName { get; }
|
||||||
|
string WorkerPatronymic { get; }
|
||||||
|
string Phone { get; }
|
||||||
|
string Email { get; }
|
||||||
|
string PasswordHash { get; }
|
||||||
|
}
|
||||||
|
}
|
29
Bank/BankDatabaseImplement/BankDatabase.cs
Normal file
29
Bank/BankDatabaseImplement/BankDatabase.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement
|
||||||
|
{
|
||||||
|
public class BankDatabase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(
|
||||||
|
DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=BankDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
public virtual DbSet<ClientProgram> ClientPrograms { set; get; }
|
||||||
|
public virtual DbSet<ClientDeposit> ClientDeposits { set; get; }
|
||||||
|
public virtual DbSet<Currency> Currencies { set; get; }
|
||||||
|
public virtual DbSet<Deposit> Deposits { set; get; }
|
||||||
|
public virtual DbSet<DepositCurrency> DepositCurrencies { set; get; }
|
||||||
|
public virtual DbSet<Program> Programs { set; get; }
|
||||||
|
public virtual DbSet<ProgramCurrency> ProgramCurrencies { set; get; }
|
||||||
|
public virtual DbSet<Refill> Refills { set; get; }
|
||||||
|
public virtual DbSet<Term> Terms { set; get; }
|
||||||
|
public virtual DbSet<Worker> Workers { set; get; }
|
||||||
|
}
|
||||||
|
}
|
23
Bank/BankDatabaseImplement/BankDatabaseImplement.csproj
Normal file
23
Bank/BankDatabaseImplement/BankDatabaseImplement.csproj
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
104
Bank/BankDatabaseImplement/Implements/ClientStorage.cs
Normal file
104
Bank/BankDatabaseImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Clients.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Snils) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientSurname) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientName) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientPatronymic) &&
|
||||||
|
string.IsNullOrEmpty(model.Phone) &&
|
||||||
|
string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Clients
|
||||||
|
.Where(x => (string.IsNullOrEmpty(model.Snils) ||
|
||||||
|
x.Snils == model.Snils) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientSurname) ||
|
||||||
|
x.ClientSurname.Contains(model.ClientSurname)) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientName) ||
|
||||||
|
x.ClientName.Contains(model.ClientName)) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientPatronymic) ||
|
||||||
|
x.ClientPatronymic.Contains(model.ClientPatronymic)) &&
|
||||||
|
(string.IsNullOrEmpty(model.Phone) ||
|
||||||
|
x.Phone.Contains(model.Phone)) &&
|
||||||
|
(string.IsNullOrEmpty(model.Email) ||
|
||||||
|
x.Email.Contains(model.Email)))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Snils) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientSurname) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientName) &&
|
||||||
|
string.IsNullOrEmpty(model.ClientPatronymic))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Clients
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.Snils) ||
|
||||||
|
x.Snils == model.Snils) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientSurname) ||
|
||||||
|
x.ClientSurname == model.ClientSurname) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientName) ||
|
||||||
|
x.ClientName == model.ClientName) &&
|
||||||
|
(string.IsNullOrEmpty(model.ClientPatronymic) ||
|
||||||
|
x.ClientPatronymic == model.ClientPatronymic))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Clients.Add(newClient);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newClient.GetViewModel;
|
||||||
|
}
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var client = context.Clients
|
||||||
|
.FirstOrDefault(x => x.Snils == model.Snils);
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
client.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var element = context.Clients
|
||||||
|
.FirstOrDefault(rec => rec.Snils == model.Snils);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Clients.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
88
Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs
Normal file
88
Bank/BankDatabaseImplement/Implements/CurrencyStorage.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class CurrencyStorage : ICurrencyStorage
|
||||||
|
{
|
||||||
|
public List<CurrencyViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Currencies.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CurrencyViewModel> GetFilteredList(
|
||||||
|
CurrencySearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.CurrencyName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Currencies
|
||||||
|
.Where(x => (string.IsNullOrEmpty(model.CurrencyName)
|
||||||
|
|| x.CurrencyName.Contains(model.CurrencyName))
|
||||||
|
&& (!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrencyViewModel? GetElement(CurrencySearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.CurrencyName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Currencies
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.CurrencyName)
|
||||||
|
|| x.CurrencyName == model.CurrencyName) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrencyViewModel? Insert(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
var newCurrency = Currency.Create(model);
|
||||||
|
if (newCurrency == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Currencies.Add(newCurrency);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newCurrency.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrencyViewModel? Update(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var currency = context.Currencies
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (currency == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
currency.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return currency.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrencyViewModel? Delete(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var element = context.Currencies
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Currencies.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
Bank/BankDatabaseImplement/Implements/DepositStorage.cs
Normal file
85
Bank/BankDatabaseImplement/Implements/DepositStorage.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class DepositStorage : IDepositStorage
|
||||||
|
{
|
||||||
|
public List<DepositViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Deposits.Include(x => x.Worker)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<DepositViewModel> GetFilteredList(DepositSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.WorkerId == 0 && model.Sum == 0)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Deposits.Include(x => x.Worker)
|
||||||
|
.Where(x => (model.WorkerId == 0 ||
|
||||||
|
x.WorkerId == model.WorkerId) &&
|
||||||
|
(model.Sum == 0 || x.Sum == model.Sum))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public DepositViewModel? GetElement(DepositSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.WorkerId == 0 && model.Sum == 0 && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Deposits.Include(x => x.Worker)
|
||||||
|
.FirstOrDefault(x => (model.WorkerId == 0 ||
|
||||||
|
x.WorkerId == model.WorkerId) &&
|
||||||
|
(model.Sum == 0 || x.Sum == model.Sum) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public DepositViewModel? Insert(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
var newDeposit = Deposit.Create(model);
|
||||||
|
if (newDeposit == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Deposits.Add(newDeposit);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newDeposit.GetViewModel;
|
||||||
|
}
|
||||||
|
public DepositViewModel? Update(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var deposit = context.Deposits
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (deposit == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
deposit.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return deposit.GetViewModel;
|
||||||
|
}
|
||||||
|
public DepositViewModel? Delete(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var deposit = context.Deposits
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (deposit != null)
|
||||||
|
{
|
||||||
|
context.Deposits.Remove(deposit);
|
||||||
|
context.SaveChanges();
|
||||||
|
return deposit.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
88
Bank/BankDatabaseImplement/Implements/ProgramStorage.cs
Normal file
88
Bank/BankDatabaseImplement/Implements/ProgramStorage.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ProgramStorage : IProgramStorage
|
||||||
|
{
|
||||||
|
public List<ProgramViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Programs.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<ProgramViewModel> GetFilteredList(ProgramSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProgramName)
|
||||||
|
&& model.InterestRate == 0)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Programs
|
||||||
|
.Where(x => (string.IsNullOrEmpty(model.ProgramName)
|
||||||
|
|| x.ProgramName.Contains(model.ProgramName)) &&
|
||||||
|
(model.InterestRate == 0 ||
|
||||||
|
x.InterestRate == model.InterestRate))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public ProgramViewModel? GetElement(ProgramSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProgramName) &&
|
||||||
|
model.InterestRate == 0 && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Programs
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ProgramName)
|
||||||
|
|| x.ProgramName == model.ProgramName) &&
|
||||||
|
(model.InterestRate == 0 ||
|
||||||
|
x.InterestRate == model.InterestRate) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public ProgramViewModel? Insert(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
var newProgram = Program.Create(model);
|
||||||
|
if (newProgram == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Programs.Add(newProgram);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newProgram.GetViewModel;
|
||||||
|
}
|
||||||
|
public ProgramViewModel? Update(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var program = context.Programs
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (program == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
program.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return program.GetViewModel;
|
||||||
|
}
|
||||||
|
public ProgramViewModel? Delete(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var program = context.Programs
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (program != null)
|
||||||
|
{
|
||||||
|
context.Programs.Remove(program);
|
||||||
|
context.SaveChanges();
|
||||||
|
return program.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
Bank/BankDatabaseImplement/Implements/RefillStorage.cs
Normal file
93
Bank/BankDatabaseImplement/Implements/RefillStorage.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class RefillStorage : IRefillStorage
|
||||||
|
{
|
||||||
|
public List<RefillViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Refills.Include(x => x.Deposit)
|
||||||
|
.Include(x => x.Worker).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<RefillViewModel> GetFilteredList(RefillSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.DepositId == 0 && model.WorkerId == 0 &&
|
||||||
|
model.Sum == 0 && model.RefillDate == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Refills.Include(x => x.Deposit)
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.Where(x => (model.DepositId == 0 ||
|
||||||
|
x.DepositId == model.DepositId) &&
|
||||||
|
(model.WorkerId == 0 || x.WorkerId == model.WorkerId) &&
|
||||||
|
(model.Sum == 0 || x.Sum == model.Sum) &&
|
||||||
|
(model.RefillDate == null ||
|
||||||
|
x.RefillDate == model.RefillDate))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public RefillViewModel? GetElement(RefillSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.DepositId == 0 && model.WorkerId == 0 && model.Sum == 0
|
||||||
|
&& model.RefillDate == null && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Refills.Include(x => x.Deposit)
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.FirstOrDefault(x => (model.DepositId == 0 ||
|
||||||
|
x.DepositId == model.DepositId) &&
|
||||||
|
(model.WorkerId == 0 || x.WorkerId == model.WorkerId) &&
|
||||||
|
(model.Sum == 0 || x.Sum == model.Sum) &&
|
||||||
|
(model.RefillDate == null ||
|
||||||
|
x.RefillDate == model.RefillDate) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public RefillViewModel? Insert(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
var newRefill = Refill.Create(model);
|
||||||
|
if (newRefill == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Refills.Add(newRefill);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newRefill.GetViewModel;
|
||||||
|
}
|
||||||
|
public RefillViewModel? Update(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var refill = context.Refills.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (refill == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
refill.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return refill.GetViewModel;
|
||||||
|
}
|
||||||
|
public RefillViewModel? Delete(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var refill = context.Refills.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (refill != null)
|
||||||
|
{
|
||||||
|
context.Refills.Remove(refill);
|
||||||
|
context.SaveChanges();
|
||||||
|
return refill.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
86
Bank/BankDatabaseImplement/Implements/TermStorage.cs
Normal file
86
Bank/BankDatabaseImplement/Implements/TermStorage.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class TermStorage : ITermStorage
|
||||||
|
{
|
||||||
|
public List<TermViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Terms.Include(x => x.Program)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<TermViewModel> GetFilteredList(TermSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Duration == 0 && model.ProgramId == 0)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Terms.Include(x => x.Program)
|
||||||
|
.Where(x => (model.Duration == 0 ||
|
||||||
|
x.Duration == model.Duration) &&
|
||||||
|
(model.ProgramId == 0 || x.ProgramId == model.ProgramId))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public TermViewModel? GetElement(TermSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Duration == 0 && model.ProgramId == 0
|
||||||
|
&& !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Terms.Include(x => x.Program)
|
||||||
|
.FirstOrDefault(x => (model.Duration == 0 ||
|
||||||
|
x.Duration == model.Duration) &&
|
||||||
|
(model.ProgramId == 0 || x.ProgramId == model.ProgramId) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public TermViewModel? Insert(TermBindingModel model)
|
||||||
|
{
|
||||||
|
var newTerm = Term.Create(model);
|
||||||
|
if (newTerm == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Terms.Add(newTerm);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newTerm.GetViewModel;
|
||||||
|
}
|
||||||
|
public TermViewModel? Update(TermBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var term = context.Terms
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (term == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
term.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return term.GetViewModel;
|
||||||
|
}
|
||||||
|
public TermViewModel? Delete(TermBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var term = context.Terms
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (term != null)
|
||||||
|
{
|
||||||
|
context.Terms.Remove(term);
|
||||||
|
context.SaveChanges();
|
||||||
|
return term.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
Bank/BankDatabaseImplement/Implements/WorkerStorage.cs
Normal file
99
Bank/BankDatabaseImplement/Implements/WorkerStorage.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class WorkerStorage : IWorkerStorage
|
||||||
|
{
|
||||||
|
public List<WorkerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Workers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.WorkerSurname) &&
|
||||||
|
string.IsNullOrEmpty(model.WorkerName) &&
|
||||||
|
string.IsNullOrEmpty(model.WorkerPatronymic) &&
|
||||||
|
string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Workers
|
||||||
|
.Where(x => (string.IsNullOrEmpty(model.WorkerSurname) ||
|
||||||
|
x.WorkerSurname.Contains(model.WorkerSurname)) &&
|
||||||
|
(string.IsNullOrEmpty(model.WorkerName) ||
|
||||||
|
x.WorkerName.Contains(model.WorkerName)) &&
|
||||||
|
(string.IsNullOrEmpty(model.WorkerPatronymic)
|
||||||
|
|| x.WorkerPatronymic.Contains(model.WorkerPatronymic)) &&
|
||||||
|
(string.IsNullOrEmpty(model.Email) ||
|
||||||
|
x.Email.Contains(model.Email)))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public WorkerViewModel? GetElement(WorkerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.WorkerSurname) &&
|
||||||
|
string.IsNullOrEmpty(model.WorkerName) &&
|
||||||
|
string.IsNullOrEmpty(model.WorkerPatronymic) &&
|
||||||
|
string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.Workers
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.WorkerSurname)
|
||||||
|
|| x.WorkerSurname == model.WorkerSurname) &&
|
||||||
|
(string.IsNullOrEmpty(model.WorkerName) ||
|
||||||
|
x.WorkerName == model.WorkerName) &&
|
||||||
|
(string.IsNullOrEmpty(model.WorkerPatronymic) ||
|
||||||
|
x.WorkerPatronymic == model.WorkerPatronymic) &&
|
||||||
|
(string.IsNullOrEmpty(model.Email) ||
|
||||||
|
x.Email == model.Email) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Insert(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
var newWorker = Worker.Create(model);
|
||||||
|
if (newWorker == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
context.Workers.Add(newWorker);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newWorker.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var worker = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (worker == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
worker.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return worker.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Delete(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
var worker = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (worker != null)
|
||||||
|
{
|
||||||
|
context.Workers.Remove(worker);
|
||||||
|
context.SaveChanges();
|
||||||
|
return worker.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
Bank/BankDatabaseImplement/Models/Client.cs
Normal file
105
Bank/BankDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public string Snils { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string ClientSurname { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string ClientPatronymic { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public virtual Worker? Worker { get; set; }
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<ClientProgram> Programs { get; set; } = new();
|
||||||
|
private Dictionary<int, IProgramModel>?
|
||||||
|
_clientPrograms { get; set; } = null;
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<ClientDeposit> Deposits { get; set; } = new();
|
||||||
|
private Dictionary<int, IDepositModel>?
|
||||||
|
_clientDeposits { get; set; } = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, IProgramModel> ClientPrograms
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_clientPrograms == null)
|
||||||
|
{
|
||||||
|
_clientPrograms = Programs.ToDictionary(
|
||||||
|
x => x.ProgramId,
|
||||||
|
x => (x.Program as IProgramModel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _clientPrograms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, IDepositModel> ClientDeposits
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_clientDeposits == null)
|
||||||
|
{
|
||||||
|
_clientDeposits = Deposits.ToDictionary(
|
||||||
|
x => x.DepositId,
|
||||||
|
x => (x.Deposit as IDepositModel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _clientDeposits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Client
|
||||||
|
{
|
||||||
|
Snils = model.Snils,
|
||||||
|
ClientSurname = model.ClientSurname,
|
||||||
|
ClientName = model.ClientName,
|
||||||
|
ClientPatronymic = model.ClientPatronymic,
|
||||||
|
Phone = model.Phone,
|
||||||
|
Email = model.Email ?? string.Empty,
|
||||||
|
PasswordHash = model.PasswordHash,
|
||||||
|
WorkerId = model.WorkerId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Snils = model.Snils;
|
||||||
|
ClientSurname = model.ClientSurname;
|
||||||
|
ClientName = model.ClientName;
|
||||||
|
ClientPatronymic = model.ClientPatronymic;
|
||||||
|
Phone = model.Phone;
|
||||||
|
Email = model.Email ?? string.Empty;
|
||||||
|
PasswordHash = model.PasswordHash;
|
||||||
|
WorkerId = model.WorkerId;
|
||||||
|
}
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Snils = Snils,
|
||||||
|
ClientSurname = ClientSurname,
|
||||||
|
ClientName = ClientName,
|
||||||
|
ClientPatronymic = ClientPatronymic,
|
||||||
|
Phone = Phone,
|
||||||
|
Email = Email ?? string.Empty,
|
||||||
|
PasswordHash = PasswordHash,
|
||||||
|
WorkerId = WorkerId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
19
Bank/BankDatabaseImplement/Models/ClientDeposit.cs
Normal file
19
Bank/BankDatabaseImplement/Models/ClientDeposit.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ClientDeposit
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DepositId { get; set; }
|
||||||
|
public virtual Client Client { get; set; } = new();
|
||||||
|
public virtual Deposit Deposit { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
19
Bank/BankDatabaseImplement/Models/ClientProgram.cs
Normal file
19
Bank/BankDatabaseImplement/Models/ClientProgram.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ClientProgram
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ProgramId { get; set; }
|
||||||
|
public virtual Client Client { get; set; } = new();
|
||||||
|
public virtual Program Program { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
49
Bank/BankDatabaseImplement/Models/Currency.cs
Normal file
49
Bank/BankDatabaseImplement/Models/Currency.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Currency : ICurrencyModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string CurrencyName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Course { get; set; }
|
||||||
|
[ForeignKey("CurrencyId")]
|
||||||
|
public virtual List<DepositCurrency> Deposits { get; set; } = new();
|
||||||
|
[ForeignKey("CurrencyId")]
|
||||||
|
public virtual List<ProgramCurrency> Programs { get; set; } = new();
|
||||||
|
public static Currency? Create(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Currency
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
CurrencyName = model.CurrencyName,
|
||||||
|
Course = model.Course,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
CurrencyName = model.CurrencyName;
|
||||||
|
Course = model.Course;
|
||||||
|
}
|
||||||
|
public CurrencyViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
CurrencyName = CurrencyName,
|
||||||
|
Course = Course,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
69
Bank/BankDatabaseImplement/Models/Deposit.cs
Normal file
69
Bank/BankDatabaseImplement/Models/Deposit.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Deposit : IDepositModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public virtual Worker? Worker { get; set; }
|
||||||
|
[Required]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateOnly OpeningDate { get; set; }
|
||||||
|
[ForeignKey("DepositId")]
|
||||||
|
public virtual List<DepositCurrency> Currencies { get; set; } = new();
|
||||||
|
[ForeignKey("DepositId")]
|
||||||
|
public virtual List<ClientDeposit> Clients { get; set; } = new();
|
||||||
|
[ForeignKey("DepositId")]
|
||||||
|
public virtual List<Refill> Refills { get; set; } = new();
|
||||||
|
private Dictionary<int, ICurrencyModel>?
|
||||||
|
_depositCurrencies
|
||||||
|
{ get; set; } = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, ICurrencyModel> DepositCurrencies
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_depositCurrencies == null)
|
||||||
|
{
|
||||||
|
_depositCurrencies = Currencies.ToDictionary(
|
||||||
|
x => x.CurrencyId,
|
||||||
|
x => (x.Currency as ICurrencyModel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _depositCurrencies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Deposit? Create(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Deposit
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
WorkerId = model.WorkerId,
|
||||||
|
Sum = model.Sum,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
WorkerId = model.WorkerId;
|
||||||
|
Sum = model.Sum;
|
||||||
|
}
|
||||||
|
public DepositViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
WorkerId = WorkerId,
|
||||||
|
Sum = Sum,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
19
Bank/BankDatabaseImplement/Models/DepositCurrency.cs
Normal file
19
Bank/BankDatabaseImplement/Models/DepositCurrency.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class DepositCurrency
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DepositId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int CurrencyId { get; set; }
|
||||||
|
public virtual Deposit Deposit { get; set; } = new();
|
||||||
|
public virtual Currency Currency { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
66
Bank/BankDatabaseImplement/Models/Program.cs
Normal file
66
Bank/BankDatabaseImplement/Models/Program.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Program : IProgramModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string ProgramName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double InterestRate { get; set; }
|
||||||
|
[ForeignKey("ProgramId")]
|
||||||
|
public virtual List<ProgramCurrency> Currencies { get; set; } = new();
|
||||||
|
[ForeignKey("ProgramId")]
|
||||||
|
public virtual List<ClientProgram> Clients { get; set; } = new();
|
||||||
|
[ForeignKey("ProgramId")]
|
||||||
|
public virtual List<Term> Terms { get; set; } = new();
|
||||||
|
private Dictionary<int, ICurrencyModel>?
|
||||||
|
_programCurrencies
|
||||||
|
{ get; set; } = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, ICurrencyModel> ProgramCurrencies
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_programCurrencies == null)
|
||||||
|
{
|
||||||
|
_programCurrencies = Currencies.ToDictionary(
|
||||||
|
x => x.CurrencyId,
|
||||||
|
x => (x.Currency as ICurrencyModel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _programCurrencies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Program? Create(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Program
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ProgramName = model.ProgramName,
|
||||||
|
InterestRate = model.InterestRate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
ProgramName = model.ProgramName;
|
||||||
|
InterestRate = model.InterestRate;
|
||||||
|
}
|
||||||
|
public ProgramViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ProgramName = ProgramName,
|
||||||
|
InterestRate = InterestRate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
19
Bank/BankDatabaseImplement/Models/ProgramCurrency.cs
Normal file
19
Bank/BankDatabaseImplement/Models/ProgramCurrency.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ProgramCurrency
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ProgramId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int CurrencyId { get; set; }
|
||||||
|
public virtual Program Program { get; set; } = new();
|
||||||
|
public virtual Currency Currency { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
54
Bank/BankDatabaseImplement/Models/Refill.cs
Normal file
54
Bank/BankDatabaseImplement/Models/Refill.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Refill : IRefillModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DepositId { get; set; }
|
||||||
|
public virtual Deposit? Deposit { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int WorkerId { get; set; }
|
||||||
|
public virtual Worker? Worker { get; set; }
|
||||||
|
[Required]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateOnly RefillDate { get; set; }
|
||||||
|
public static Refill? Create(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Refill
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
DepositId = model.DepositId,
|
||||||
|
WorkerId = model.WorkerId,
|
||||||
|
Sum = model.Sum,
|
||||||
|
RefillDate = model.RefillDate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
DepositId = model.DepositId;
|
||||||
|
WorkerId = model.WorkerId;
|
||||||
|
Sum = model.Sum;
|
||||||
|
RefillDate = model.RefillDate;
|
||||||
|
}
|
||||||
|
public RefillViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
DepositId = DepositId,
|
||||||
|
WorkerId = WorkerId,
|
||||||
|
Sum = Sum,
|
||||||
|
RefillDate = RefillDate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
43
Bank/BankDatabaseImplement/Models/Term.cs
Normal file
43
Bank/BankDatabaseImplement/Models/Term.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Term : ITermModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Duration { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ProgramId { get; set; }
|
||||||
|
public virtual Program? Program { get; set; }
|
||||||
|
public static Term? Create(TermBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Term
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Duration = model.Duration,
|
||||||
|
ProgramId = model.ProgramId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(TermBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
Duration = model.Duration;
|
||||||
|
ProgramId = model.ProgramId;
|
||||||
|
}
|
||||||
|
public TermViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Duration = Duration,
|
||||||
|
ProgramId = ProgramId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
65
Bank/BankDatabaseImplement/Models/Worker.cs
Normal file
65
Bank/BankDatabaseImplement/Models/Worker.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using BankDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BankDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Worker : IWorkerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string WorkerSurname { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string WorkerName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string WorkerPatronymic { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string PasswordHash { get; set; } = string.Empty;
|
||||||
|
[ForeignKey("WorkerId")]
|
||||||
|
public virtual List<Worker> Workers { get; set; } = new();
|
||||||
|
public static Worker? Create(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
return new Worker
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
WorkerSurname = model.WorkerSurname,
|
||||||
|
WorkerName = model.WorkerName,
|
||||||
|
WorkerPatronymic = model.WorkerPatronymic,
|
||||||
|
Phone = model.Phone,
|
||||||
|
Email = model.Email ?? string.Empty,
|
||||||
|
PasswordHash = model.PasswordHash,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Id = model.Id;
|
||||||
|
WorkerSurname = model.WorkerSurname;
|
||||||
|
WorkerName = model.WorkerName;
|
||||||
|
WorkerPatronymic = model.WorkerPatronymic;
|
||||||
|
Phone = model.Phone;
|
||||||
|
Email = model.Email ?? string.Empty;
|
||||||
|
PasswordHash = model.PasswordHash;
|
||||||
|
}
|
||||||
|
public WorkerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
WorkerSurname = WorkerSurname,
|
||||||
|
WorkerName = WorkerName,
|
||||||
|
WorkerPatronymic = WorkerPatronymic,
|
||||||
|
Phone = Phone,
|
||||||
|
Email = Email ?? string.Empty,
|
||||||
|
PasswordHash = PasswordHash,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
21
Bank/BankRestApi/BankRestApi.csproj
Normal file
21
Bank/BankRestApi/BankRestApi.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.10" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankBusinessLogic\BankBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\BankDatabaseImplement\BankDatabaseImplement.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
93
Bank/BankRestApi/Controllers/ClientController.cs
Normal file
93
Bank/BankRestApi/Controllers/ClientController.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ClientController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientLogic _logic;
|
||||||
|
public ClientController(ILogger<ClientController> logger,
|
||||||
|
IClientLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<ClientViewModel>? GetClientList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка клиентов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public ClientViewModel? GetClient(string ClientSnils)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Snils = ClientSnils
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения клиента по Snils={Snils}",
|
||||||
|
ClientSnils);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateClient(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateClient(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteClient(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Bank/BankRestApi/Controllers/CurrencyController.cs
Normal file
94
Bank/BankRestApi/Controllers/CurrencyController.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class CurrencyController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ICurrencyLogic _logic;
|
||||||
|
public CurrencyController(ILogger<CurrencyController> logger,
|
||||||
|
ICurrencyLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<CurrencyViewModel>? GetCurrencyList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка валют");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public CurrencyViewModel? GetCurrency(int CurrencyId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new CurrencySearchModel
|
||||||
|
{
|
||||||
|
Id = CurrencyId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения валюты по Id={Id}",
|
||||||
|
CurrencyId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateCurrency(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания валюты");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateCurrency(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления валюты");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteCurrency(CurrencyBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления валюты");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Bank/BankRestApi/Controllers/DepositController.cs
Normal file
94
Bank/BankRestApi/Controllers/DepositController.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class DepositController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IDepositLogic _logic;
|
||||||
|
public DepositController(ILogger<DepositController> logger,
|
||||||
|
IDepositLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<DepositViewModel>? GetDepositList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка вкладов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public DepositViewModel? GetDeposit(int DepositId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new DepositSearchModel
|
||||||
|
{
|
||||||
|
Id = DepositId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения вклада по Id={Id}",
|
||||||
|
DepositId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateDeposit(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания вклада");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateDeposit(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления вклада");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteDeposit(DepositBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления вклада");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
95
Bank/BankRestApi/Controllers/ProgramController.cs
Normal file
95
Bank/BankRestApi/Controllers/ProgramController.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ProgramController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProgramLogic _logic;
|
||||||
|
public ProgramController(ILogger<ProgramController> logger,
|
||||||
|
IProgramLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ProgramViewModel>? GetProgramList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения списка кредитных программ");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public ProgramViewModel? GetProgram(int ProgramId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new ProgramSearchModel
|
||||||
|
{
|
||||||
|
Id = ProgramId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения кредитной программы по Id={Id}",
|
||||||
|
ProgramId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateProgram(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания кредитной программы");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateProgram(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления кредитной программы");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteProgram(ProgramBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления кредитной программы");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Bank/BankRestApi/Controllers/RefillController.cs
Normal file
94
Bank/BankRestApi/Controllers/RefillController.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class RefillController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IRefillLogic _logic;
|
||||||
|
public RefillController(ILogger<RefillController> logger,
|
||||||
|
IRefillLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<RefillViewModel>? GetRefillList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка пополнений");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public RefillViewModel? GetRefill(int RefillId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new RefillSearchModel
|
||||||
|
{
|
||||||
|
Id = RefillId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения пополнения по Id={Id}",
|
||||||
|
RefillId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateRefill(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания пополнения");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateRefill(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления пополнения");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteRefill(RefillBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления пополнения");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Bank/BankRestApi/Controllers/TermController.cs
Normal file
94
Bank/BankRestApi/Controllers/TermController.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TermController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ITermLogic _logic;
|
||||||
|
public TermController(ILogger<TermController> logger,
|
||||||
|
ITermLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<TermViewModel>? GetTermList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка сроков");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public TermViewModel? GetTerm(int TermId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new TermSearchModel
|
||||||
|
{
|
||||||
|
Id = TermId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения срока по Id={Id}",
|
||||||
|
TermId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateTerm(TermBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания срока");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateTerm(TermBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления срока");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteTerm(TermBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления срока");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Bank/BankRestApi/Controllers/WorkerController.cs
Normal file
94
Bank/BankRestApi/Controllers/WorkerController.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.SearchModels;
|
||||||
|
using BankContracts.ViewModels;
|
||||||
|
using BankDatabaseImplement.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace BankRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class WorkerController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IWorkerLogic _logic;
|
||||||
|
public WorkerController(ILogger<WorkerController> logger,
|
||||||
|
IWorkerLogic logic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<WorkerViewModel>? GetWorkerList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка работников");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public WorkerViewModel? GetWorker(int WorkerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new WorkerSearchModel
|
||||||
|
{
|
||||||
|
Id = WorkerId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
ex, "Ошибка получения работника по Id={Id}",
|
||||||
|
WorkerId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateWorker(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания работника");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPut]
|
||||||
|
public void UpdateWorker(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления работника");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteWorker(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления работника");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
Bank/BankRestApi/Program.cs
Normal file
61
Bank/BankRestApi/Program.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using BankBusinessLogic.BusinessLogics;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using BankContracts.StoragesContracts;
|
||||||
|
using BankDatabaseImplement.Implements;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
|
builder.Logging.AddLog4Net("log4net.config");
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
builder.Services.AddTransient<ICurrencyStorage, CurrencyStorage>();
|
||||||
|
builder.Services.AddTransient<IDepositStorage, DepositStorage>();
|
||||||
|
builder.Services.AddTransient<IProgramStorage, ProgramStorage>();
|
||||||
|
builder.Services.AddTransient<IRefillStorage, RefillStorage>();
|
||||||
|
builder.Services.AddTransient<ITermStorage, TermStorage>();
|
||||||
|
builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
|
||||||
|
builder.Services.AddTransient<IDepositLogic, DepositLogic>();
|
||||||
|
builder.Services.AddTransient<IProgramLogic, ProgramLogic>();
|
||||||
|
builder.Services.AddTransient<IRefillLogic, RefillLogic>();
|
||||||
|
builder.Services.AddTransient<ITermLogic, TermLogic>();
|
||||||
|
builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
|
||||||
|
builder.Services.AddLogging(option =>
|
||||||
|
{
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddNLog("nlog.config");
|
||||||
|
});
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
|
// Learn more about configuring Swagger/OpenAPI
|
||||||
|
// at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
c.SwaggerDoc("v1", new OpenApiInfo {
|
||||||
|
Title = "VetClinicRestApi",
|
||||||
|
Version = "v1" });
|
||||||
|
});
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
|
||||||
|
"BankRestApi v1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
41
Bank/BankRestApi/Properties/launchSettings.json
Normal file
41
Bank/BankRestApi/Properties/launchSettings.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:64404",
|
||||||
|
"sslPort": 44307
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5142",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7061;http://localhost:5142",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
Bank/BankRestApi/appsettings.Development.json
Normal file
8
Bank/BankRestApi/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankRestApi/appsettings.json
Normal file
9
Bank/BankRestApi/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
16
Bank/BankRestApi/log4net.config
Normal file
16
Bank/BankRestApi/log4net.config
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<log4net>
|
||||||
|
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<file value="c:/temp/BankRestApi.log" />
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<maximumFileSize value="100KB" />
|
||||||
|
<maxSizeRollBackups value="2" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<root>
|
||||||
|
<level value="TRACE" />
|
||||||
|
<appender-ref ref="RollingFile" />
|
||||||
|
</root>
|
||||||
|
</log4net>
|
18
Bank/BankWorkerApp/APIClient.cs
Normal file
18
Bank/BankWorkerApp/APIClient.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using BankContracts.ViewModels;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
|
namespace BankWorkerApp
|
||||||
|
{
|
||||||
|
public static class APIClient
|
||||||
|
{
|
||||||
|
private static readonly HttpClient _worker = new();
|
||||||
|
public static WorkerViewModel? Worker { get; set; } = null;
|
||||||
|
public static void Connect(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_worker.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
_worker.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
_worker.DefaultRequestHeaders.Accept.Add(new
|
||||||
|
MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
Bank/BankWorkerApp/BankWorkerApp.csproj
Normal file
21
Bank/BankWorkerApp/BankWorkerApp.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\BankRestApi\BankRestApi.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
43
Bank/BankWorkerApp/Controllers/HomeController.cs
Normal file
43
Bank/BankWorkerApp/Controllers/HomeController.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using BankWorkerApp.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace BankWorkerApp.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
public HomeController(ILogger<HomeController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
if (APIClient.Worker == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
public IActionResult Privacy()
|
||||||
|
{
|
||||||
|
if (APIClient.Worker == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Enter()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||||
|
NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id
|
||||||
|
?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
Bank/BankWorkerApp/Models/ErrorViewModel.cs
Normal file
9
Bank/BankWorkerApp/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace BankWorkerApp.Models
|
||||||
|
{
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
|
}
|
38
Bank/BankWorkerApp/Program.cs
Normal file
38
Bank/BankWorkerApp/Program.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
namespace BankWorkerApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
// The default HSTS value is 30 days. You may want
|
||||||
|
// to change this for production scenarios, see
|
||||||
|
// https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Bank/BankWorkerApp/Properties/launchSettings.json
Normal file
28
Bank/BankWorkerApp/Properties/launchSettings.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:10885",
|
||||||
|
"sslPort": 44379
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"BankWorkerApp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7048;http://localhost:5096",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
Bank/BankWorkerApp/Views/Home/Index.cshtml
Normal file
8
Bank/BankWorkerApp/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Home Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Welcome</h1>
|
||||||
|
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||||
|
</div>
|
25
Bank/BankWorkerApp/Views/Shared/Error.cshtml
Normal file
25
Bank/BankWorkerApp/Views/Shared/Error.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@model ErrorViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
49
Bank/BankWorkerApp/Views/Shared/_Layout.cshtml
Normal file
49
Bank/BankWorkerApp/Views/Shared/_Layout.cshtml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - BankWorkerApp</title>
|
||||||
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/BankWorkerApp.styles.css" asp-append-version="true" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">BankWorkerApp</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
|
<ul class="navbar-nav flex-grow-1">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<div class="container">
|
||||||
|
<main role="main" class="pb-3">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="border-top footer text-muted">
|
||||||
|
<div class="container">
|
||||||
|
© 2024 - BankWorkerApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
48
Bank/BankWorkerApp/Views/Shared/_Layout.cshtml.css
Normal file
48
Bank/BankWorkerApp/Views/Shared/_Layout.cshtml.css
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
for details on configuring this project to bundle and minify static web assets. */
|
||||||
|
|
||||||
|
a.navbar-brand {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0077cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-top {
|
||||||
|
border-top: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-shadow {
|
||||||
|
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.accept-policy {
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 60px;
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||||
|
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
3
Bank/BankWorkerApp/Views/_ViewImports.cshtml
Normal file
3
Bank/BankWorkerApp/Views/_ViewImports.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@using BankWorkerApp
|
||||||
|
@using BankWorkerApp.Models
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
3
Bank/BankWorkerApp/Views/_ViewStart.cshtml
Normal file
3
Bank/BankWorkerApp/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user