Compare commits

..

2 Commits

Author SHA1 Message Date
a508054c3a Merge pull request 'этап' (#1) from Stage7 into main
Reviewed-on: #1
2024-05-02 01:17:18 +04:00
41691e5af1 этап 2024-05-02 01:15:19 +04:00
179 changed files with 78690 additions and 0 deletions

55
Bank/Bank.sln Normal file
View File

@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bank", "Bank\Bank.csproj", "{AFB79BC5-47CC-4DC9-B090-2190ECC6165E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataModels", "BankDataModels\BankDataModels.csproj", "{84B572A0-F8F5-40D2-9D9E-ACAEC7A91859}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankContracts", "BankContracts\BankContracts.csproj", "{0A3FDB59-29E9-459A-8D17-62CA88D1C56E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankBusinessLogic", "BankBusinessLogic\BankBusinessLogic.csproj", "{861E0654-2ECE-4A7D-8A82-2E6DB5AEBDCE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDatabaseImplement", "BankDatabaseImplement\BankDatabaseImplement.csproj", "{2C40C8A1-137C-4B36-BA44-888CD7230E50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankWorkerApp", "BankWorkerApp\BankWorkerApp.csproj", "{E42AD3E0-7FFF-4F13-8F06-DEE8C095B1FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFB79BC5-47CC-4DC9-B090-2190ECC6165E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB79BC5-47CC-4DC9-B090-2190ECC6165E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFB79BC5-47CC-4DC9-B090-2190ECC6165E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFB79BC5-47CC-4DC9-B090-2190ECC6165E}.Release|Any CPU.Build.0 = Release|Any CPU
{84B572A0-F8F5-40D2-9D9E-ACAEC7A91859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84B572A0-F8F5-40D2-9D9E-ACAEC7A91859}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84B572A0-F8F5-40D2-9D9E-ACAEC7A91859}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84B572A0-F8F5-40D2-9D9E-ACAEC7A91859}.Release|Any CPU.Build.0 = Release|Any CPU
{0A3FDB59-29E9-459A-8D17-62CA88D1C56E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A3FDB59-29E9-459A-8D17-62CA88D1C56E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A3FDB59-29E9-459A-8D17-62CA88D1C56E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A3FDB59-29E9-459A-8D17-62CA88D1C56E}.Release|Any CPU.Build.0 = Release|Any CPU
{861E0654-2ECE-4A7D-8A82-2E6DB5AEBDCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{861E0654-2ECE-4A7D-8A82-2E6DB5AEBDCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{861E0654-2ECE-4A7D-8A82-2E6DB5AEBDCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{861E0654-2ECE-4A7D-8A82-2E6DB5AEBDCE}.Release|Any CPU.Build.0 = Release|Any CPU
{2C40C8A1-137C-4B36-BA44-888CD7230E50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C40C8A1-137C-4B36-BA44-888CD7230E50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C40C8A1-137C-4B36-BA44-888CD7230E50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C40C8A1-137C-4B36-BA44-888CD7230E50}.Release|Any CPU.Build.0 = Release|Any CPU
{E42AD3E0-7FFF-4F13-8F06-DEE8C095B1FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E42AD3E0-7FFF-4F13-8F06-DEE8C095B1FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E42AD3E0-7FFF-4F13-8F06-DEE8C095B1FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E42AD3E0-7FFF-4F13-8F06-DEE8C095B1FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10D52A8F-A93F-4B95-8944-3690FFD8508E}
EndGlobalSection
EndGlobal

25
Bank/Bank/Bank.csproj Normal file
View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BankDatabaseImplement\BankDatabaseImplement.csproj" />
</ItemGroup>
</Project>

25
Bank/Bank/Program.cs Normal file
View File

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18296",
"sslPort": 44326
}
},
"profiles": {
"Bank": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7080;http://localhost:5080",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,124 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.BusinessLogics
{
public class ClerkLogic : IClerkLogic
{
private readonly ILogger _logger;
private readonly IClerkStorage _clerkStorage;
public ClerkLogic(ILogger<ClerkLogic> logger, IClerkStorage clerkStorage)
{
_logger = logger;
_clerkStorage = clerkStorage;
}
public bool Create(ClerkBindingModel model)
{
CheckModel(model);
if (_clerkStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ClerkBindingModel model)
{
CheckModel(model);
if (_clerkStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ClerkBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_clerkStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public ClerkViewModel? ReadElement(ClerkSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}. PhoneNumber:{PhoneNumber}. Id:{ Id}", model.Login, model.PhoneNumber, model.Id);
var element = _clerkStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ClerkViewModel>? ReadList(ClerkSearchModel? model)
{
_logger.LogInformation("ReadList. ClerkId:{Id}", model?.Id);
var list = model == null ? _clerkStorage.GetFullList() : _clerkStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(ClerkBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина клерка", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номера телефона клерка", nameof(model.PhoneNumber));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля клерка", nameof(model.Password));
}
_logger.LogInformation("Clerk. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. Id:{ Id}", model.Login, model.PhoneNumber, model.Password, model.Id);
var element = _clerkStorage.GetElement(new ClerkSearchModel
{
Login = model.Login,
PhoneNumber = model.PhoneNumber,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клерк с таким именем уже есть");
}
}
}
}

View File

@ -0,0 +1,129 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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. Id:{Id}", model.Id);
if (_clientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Surname:{Surname}. Name:{Name}. Patronymic:{Patronymic}. Id:{ Id}", model.Surname, model.Name, model.Patronymic, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. ClientId:{Id}", model?.Id);
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;
}
private void CheckModel(ClientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Surname))
{
throw new ArgumentNullException("Нет фамилии пациента", nameof(model.Surname));
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет имени пациента", nameof(model.Name));
}
if (string.IsNullOrEmpty(model.Patronymic))
{
throw new ArgumentNullException("Нет отчества пациента", nameof(model.Patronymic));
}
if (model.Age < 0)
{
throw new ArgumentNullException("Возраст пациента должен быть больше 0", nameof(model.Patronymic));
}
_logger.LogInformation("Client. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. Age:{Age}. ClerkId:{ClerkId}. Id:{ Id}", model.Surname, model.Name, model.Patronymic, model.Age, model.ClerkId, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{
Surname = model.Surname,
Name = model.Name,
Patronymic = model.Patronymic,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Пациент с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.BusinessLogics
{
public class ContributionLogic : IContributionLogic
{
private readonly ILogger _logger;
private readonly IContributionStorage _contributionStorage;
public ContributionLogic(ILogger<ContributionLogic> logger, IContributionStorage contributionStorage)
{
_logger = logger;
_contributionStorage = contributionStorage;
}
public bool Create(ContributionBindingModel model)
{
CheckModel(model);
if (_contributionStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ContributionBindingModel model)
{
CheckModel(model);
if (_contributionStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ContributionBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_contributionStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public ContributionViewModel? ReadElement(ContributionSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _contributionStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ContributionViewModel>? ReadList(ContributionSearchModel? model)
{
_logger.LogInformation("ReadList. ContributionId:{Id}", model?.Id);
var list = model == null ? _contributionStorage.GetFullList() : _contributionStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(ContributionBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.ContributionCurrencies == null || model.ContributionCurrencies.Count == 0)
{
throw new ArgumentNullException("Нет валюты во вкладе", nameof(model.ContributionCurrencies));
}
_logger.LogInformation("Contribution. Id:{ Id}. DepositsId:{DepositsId}. ClerkId:{ClerkId}", model.Id, model.DepositsId, model.ClerkId);
var element = _contributionStorage.GetElement(new ContributionSearchModel
{
Id = model.Id,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 CurrencyViewModel? ReadElement(CurrencySearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Name:{Name}. Id:{ Id}", model.Name, 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;
}
public List<CurrencyViewModel>? ReadList(CurrencySearchModel? model)
{
_logger.LogInformation("ReadList. CurrencyId:{Id}", 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;
}
private void CheckModel(CurrencyBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет навзания валюты", nameof(model.Name));
}
_logger.LogInformation("Currency. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _currencyStorage.GetElement(new CurrencySearchModel
{
Name = model.Name,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Валюта с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,116 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.BusinessLogics
{
public class DepositsLogic : IDepositsLogic
{
private readonly ILogger _logger;
private readonly IDepositsStorage _diseaseStorage;
public DepositsLogic(ILogger<DepositsLogic> logger, IDepositsStorage DepositsStorage)
{
_logger = logger;
_diseaseStorage = DepositsStorage;
}
public bool Create(DepositsBindingModel model)
{
CheckModel(model);
if (_diseaseStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DepositsBindingModel model)
{
CheckModel(model);
if (_diseaseStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DepositsBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_diseaseStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public DepositsViewModel? ReadElement(DepositsSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _diseaseStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<DepositsViewModel>? ReadList(DepositsSearchModel? model)
{
_logger.LogInformation("ReadList. DepositsId:{Id}", model?.Id);
var list = model == null ? _diseaseStorage.GetFullList() : _diseaseStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(DepositsBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет пополнения", nameof(model.Name));
}
_logger.LogInformation("Deposits. Name:{Name}. Reasons:{Reasons}. ClerkId:{ClerkId}. Id:{ Id}", model.Name, model.Reasons, model.ClerkId, model.Id);
var element = _diseaseStorage.GetElement(new DepositsSearchModel
{
Name = model.Name,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Вклад с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 ProgramViewModel? ReadElement(ProgramSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Name:{Name}. Id:{ Id}", model.Name, 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;
}
public List<ProgramViewModel>? ReadList(ProgramSearchModel? model)
{
_logger.LogInformation("ReadList. ProgramId:{Id}", 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;
}
private void CheckModel(ProgramBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия кредитной программы", nameof(model.Name));
}
_logger.LogInformation("Program. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _programStorage.GetElement(new ProgramSearchModel
{
Name = model.Name,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Кредитная программа с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,128 @@
using BankBusinessLogic.OfficePackage;
using BankBusinessLogic.OfficePackage.HelperModels;
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.BusinessLogics
{
public class ReportLogic : IReportLogic
{
private readonly IClientStorage _clientStorage;
private readonly IContributionStorage _contributionStorage;
private readonly ICurrencyStorage _currencyStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IClientStorage clientStorage, IContributionStorage contributionStorage, ICurrencyStorage currencyStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_clientStorage = clientStorage;
_contributionStorage = contributionStorage;
_currencyStorage = currencyStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
public List<ReportClientCurrencyViewModel> GetClientCurrencyViewModel()
{
throw new NotImplementedException();
}
public List<ReportClientCurrencyViewModel> GetClientCurrencyModule()
{
var Currencies = _currencyStorage.GetFullList();
var Contributions = _contributionStorage.GetFullList();
var Clients = _clientStorage.GetFullList();
var list = new List<ReportClientCurrencyViewModel>();
foreach (var Client in Clients)
{
var record = new ReportClientCurrencyViewModel
{
ClientSurname = Client.Surname,
ClientName = Client.Name,
ClientPatronymic = Client.Patronymic,
Currencies = new Dictionary<int, string>(),
};
foreach (var Contribution in Contributions)
{
if (Client.ClientContributions.ContainsValue(Contribution))
{
foreach (var Currency in Currencies)
{
if (Contribution.ContributionCurrencies.ContainsKey(Currency.Id))
{
record.Currencies.Add(Currency.Id, Currency.Name);
}
}
}
}
list.Add(record);
}
return list;
}
public List<ReportClientsViewModel> GetClients(ReportBindingModel model)
{
var Clients = _clientStorage.GetFilteredList(new ClientSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo });
var Currencies = _currencyStorage.GetFullList();
var Contributions = _contributionStorage.GetFullList();
var list = new List<ReportClientsViewModel>();
foreach (var Client in Clients)
{
var record = new ReportClientsViewModel
{
Id = Client.Id,
ClientSurname = Client.Surname,
ClientName = Client.Name,
ClientPatronymic = Client.Patronymic,
Currencies = new Dictionary<int, string>()
};
foreach (var Contribution in Contributions)
{
if (Client.ClientContributions.ContainsValue(Contribution))
{
foreach (var Currency in Currencies)
{
if (Contribution.ContributionCurrencies.ContainsKey(Currency.Id))
{
record.Currencies.Add(Currency.Id, Currency.Name);
}
}
}
}
list.Add(record);
}
return list;
}
public void SaveClientCurrencyToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveClientCurrencyToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveClientsToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,68 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using BankBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcel
{
public void CreateReport(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var pm in info.ClientCurrenies)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pm.CurrencyName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
//Text = pm.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters
excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfo info);
}
}

View File

@ -0,0 +1,58 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using BankBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdf
{
public void CreateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style =
"NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата", "Клиент","Валюта" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var Client in info.Clients)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { Client.Id.ToString(), Client.ClientSurname, Client.ClientName, Client.ClientPatronymic, Client.CurrencyName},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfo info);
}
}

View File

@ -0,0 +1,46 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using BankBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWord
{
public void CreateDoc(WordInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var Currency in info.Currencies)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {(Currency.Name, new WordTextProperties { Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}
protected abstract void CreateWord(WordInfo info);
protected abstract void CreateParagraph(WordParagraph paragraph);
protected abstract void SaveWord(WordInfo info);
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperEnums
{
public enum ExcelStyleInfoType
{
Title,
Text,
TextWithBroder
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{
Center,
Left,
Rigth
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperEnums
{
public enum WordJustificationType
{
Center,
Both
}
}

View File

@ -0,0 +1,19 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class ExcelCellParameters
{
public string ColumnName { get; set; } = string.Empty;
public uint RowIndex { get; set; }
public string Text { get; set; } = string.Empty;
public string CellReference => $"{ColumnName}{RowIndex}";
public ExcelStyleInfoType StyleInfo { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportClientCurrencyViewModel> ClientCurrenies
{
get;
set;
} = new();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class ExcelMergeParameters
{
public string CellFromName { get; set; } = string.Empty;
public string CellToName { get; set; } = string.Empty;
public string Merge => $"{CellFromName}:{CellToName}";
}
}

View File

@ -0,0 +1,19 @@
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportClientsViewModel> Clients { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class PdfParagraph
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class PdfRowParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class WordInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<CurrencyViewModel> Currencies { get; set; } = new();
public IEnumerable<object> Components { get; internal set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class WordParagraph
{
public List<(string, WordTextProperties)> Texts { get; set; } = new();
public WordTextProperties? TextProperties { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using BankBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class WordTextProperties
{
public string Size { get; set; } = string.Empty;
public bool Bold { get; set; }
public WordJustificationType JustificationType { get; set; }
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class ClerkBindingModel : IClerkModel
{
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,28 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class ClientBindingModel : IClientModel
{
public int Id { get; set; }
public string Surname { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public int Age { get; set; }
public int ClerkId { get; set; }
public Dictionary<int, IProgramModel> ClientPrograms { get; set; } = new();
public Dictionary<int, IContributionModel> ClientContributions { get; set; } = new();
}
}

View File

@ -0,0 +1,22 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class ContributionBindingModel : IContributionModel
{
public int Id { get; set; }
public DateTime IssueDate { get; set; } = DateTime.Now;
public int DepositsId { get; set; }
public int ClerkId { get; set; }
public Dictionary<int, ICurrencyModel> ContributionCurrencies { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class CurrencyBindingModel : ICurrencyModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,20 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class DepositsBindingModel : IDepositsModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Reasons { get; set; } = string.Empty;
public int ClerkId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class ProgramBindingModel : IProgramModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public Dictionary<int, ICurrencyModel> ProgramCurrencies { get; set; } = new();
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BusinessLogicsContracts
{
public interface IClerkLogic
{
List<ClerkViewModel>? ReadList(ClerkSearchModel? model);
ClerkViewModel? ReadElement(ClerkSearchModel model);
bool Create(ClerkBindingModel model);
bool Update(ClerkBindingModel model);
bool Delete(ClerkBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BusinessLogicsContracts
{
public interface IContributionLogic
{
List<ContributionViewModel>? ReadList(ContributionSearchModel? model);
ContributionViewModel? ReadElement(ContributionSearchModel model);
bool Create(ContributionBindingModel model);
bool Update(ContributionBindingModel model);
bool Delete(ContributionBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BusinessLogicsContracts
{
public interface IDepositsLogic
{
List<DepositsViewModel>? ReadList(DepositsSearchModel? model);
DepositsViewModel? ReadElement(DepositsSearchModel model);
bool Create(DepositsBindingModel model);
bool Update(DepositsBindingModel model);
bool Delete(DepositsBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,24 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.BusinessLogicsContracts
{
public interface IReportLogic
{
List<ReportClientCurrencyViewModel> GetClientCurrencyViewModel();
List<ReportClientsViewModel> GetClients(ReportBindingModel model);
void SaveClientCurrencyToWordFile(ReportBindingModel model);
void SaveClientCurrencyToExcelFile(ReportBindingModel model);
void SaveClientsToPdfFile(ReportBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class ClerkSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? PhoneNumber { get; set; }
public string? Password { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
public string? Surname { get; set; }
public string? Name { get; set; }
public string? Patronymic { get; set; }
public int? ClerkId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class ContributionSearchModel
{
public int? Id { get; set; }
public int? ClerkId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class CurrencySearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class DepositsSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public int? ClerkId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.SearchModels
{
public class ProgramSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesContracts
{
public interface IClerkStorage
{
List<ClerkViewModel> GetFullList();
List<ClerkViewModel> GetFilteredList(ClerkSearchModel model);
ClerkViewModel? GetElement(ClerkSearchModel model);
ClerkViewModel? Insert(ClerkBindingModel model);
ClerkViewModel? Update(ClerkBindingModel model);
ClerkViewModel? Delete(ClerkBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesContracts
{
public interface IContributionStorage
{
List<ContributionViewModel> GetFullList();
List<ContributionViewModel> GetFilteredList(ContributionSearchModel model);
ContributionViewModel? GetElement(ContributionSearchModel model);
ContributionViewModel? Insert(ContributionBindingModel model);
ContributionViewModel? Update(ContributionBindingModel model);
ContributionViewModel? Delete(ContributionBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.StoragesContracts
{
public interface IDepositsStorage
{
List<DepositsViewModel> GetFullList();
List<DepositsViewModel> GetFilteredList(DepositsSearchModel model);
DepositsViewModel? GetElement(DepositsSearchModel model);
DepositsViewModel? Insert(DepositsBindingModel model);
DepositsViewModel? Update(DepositsBindingModel model);
DepositsViewModel? Delete(DepositsBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}

View File

@ -0,0 +1,24 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ClerkViewModel : IClerkModel
{
public int Id { get; set; }
[DisplayName("Логин клерка")]
public string Login { get; set; } = string.Empty;
[DisplayName("Номер телефона клерка")]
public string PhoneNumber { get; set; } = string.Empty;
[DisplayName("Пароль клерка")]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,33 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
public int Id { get; set; }
[DisplayName("Фамилия клиента")]
public string Surname { get; set; } = string.Empty;
[DisplayName("Имя клиента")]
public string Name { get; set; } = string.Empty;
[DisplayName("Отчество клиента")]
public string Patronymic { get; set; } = string.Empty;
[DisplayName("Возраст клиента")]
public int Age { get; set; }
public int ClerkId { get; set; }
public Dictionary<int, IProgramModel> ClientPrograms { get; set; } = new();
public Dictionary<int, IContributionModel> ClientContributions { get; set; } = new();
}
}

View File

@ -0,0 +1,25 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ContributionViewModel : IContributionModel
{
[DisplayName("Номер вклада")]
public int Id { get; set; }
[DisplayName("Дата открытия")]
public DateTime IssueDate { get; set; } = DateTime.Now;
public int DepositsId { get; set; }
public int ClerkId { get; set; }
public Dictionary<int, ICurrencyModel> ContributionCurrencies { get; set; } = new();
}
}

View File

@ -0,0 +1,18 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class CurrencyViewModel : ICurrencyModel
{
public int Id { get; set; }
[DisplayName("Название валюты")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,23 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class DepositsViewModel : IDepositsModel
{
public int Id { get; set; }
[DisplayName("Название пополнения")]
public string Name { get; set; } = string.Empty;
[DisplayName("Причина пополнения")]
public string Reasons { get; set; } = string.Empty;
public int ClerkId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ProgramViewModel : IProgramModel
{
public int Id { get; set; }
[DisplayName("Название кредитной программы")]
public string Name { get; set; } = string.Empty;
public Dictionary<int, ICurrencyModel> ProgramCurrencies { get; set; } = new();
}
}

View File

@ -0,0 +1,29 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ReportClientCurrencyViewModel
{
public int Id { get; set; }
public string ClientSurname { get; set; } = string.Empty;
public string ClientName { get; set; } = string.Empty;
public string ClientPatronymic { get; set; } = string.Empty;
public int ContributionId { get; set; }
public int ClerkId { get; set; }
public Dictionary<int, string> Currencies { get; set; } = new();
public string CurrencyName { get; set; }
}
}

View File

@ -0,0 +1,29 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankContracts.ViewModels
{
public class ReportClientsViewModel
{
public int Id { get; set; }
public string ClientSurname { get; set; } = string.Empty;
public string ClientName { get; set; } = string.Empty;
public string ClientPatronymic { get; set; } = string.Empty;
public int ContributionId { get; set; }
public string CurrencyName { get; set; } = string.Empty;
public List<int> Contributions { get; set; } = new();
public Dictionary<int, string> Currencies { get; set; } = new();
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface IClerkModel : IId
{
string Login { get; }
string PhoneNumber { get; }
string Password { get; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface IClientModel : IId
{
string Surname { get; }
string Name { get; }
string Patronymic { get; }
int Age { get; }
int ClerkId { get; }
Dictionary<int, IProgramModel> ClientPrograms { get; }
Dictionary<int, IContributionModel> ClientContributions { get; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface IContributionModel : IId
{
DateTime IssueDate { get; }
int DepositsId { get; }
int ClerkId { get; }
Dictionary<int, ICurrencyModel> ContributionCurrencies { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface ICurrencyModel : IId
{
string Name { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface IDepositsModel : IId
{
string Name { get; }
string Reasons { get; }
int ClerkId { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDataModels.Models
{
public interface IProgramModel : IId
{
string Name { get; }
Dictionary<int, ICurrencyModel> ProgramCurrencies { get; }
}
}

View File

@ -0,0 +1,12 @@
{
"profiles": {
"BankDataModels": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:65343;http://localhost:65344"
}
}
}

View File

@ -0,0 +1,43 @@
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement
{
public class BankDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BankDatabaseFull1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Clerk> Clerks { set; get; }
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Contribution> Contributions { set; get; }
public virtual DbSet<Deposits> Deposits { set; get; }
public virtual DbSet<Currency> Currencies { set; get; }
public virtual DbSet<Program> Programs { set; get; }
public virtual DbSet<ClientContribution> ClientContributions { set; get; }
public virtual DbSet<ClientProgram> ClientPrograms { set; get; }
public virtual DbSet<ContributionCurrency> ContributionCurrencies { set; get; }
public virtual DbSet<ProgramCurrency> ProgramCurrencies { set; get; }
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.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>

View File

@ -0,0 +1,114 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class ClerkStorage : IClerkStorage
{
public ClerkViewModel? GetElement(ClerkSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public List<ClerkViewModel> GetFilteredList(ClerkSearchModel model)
{
using var context = new BankDatabase();
if (!string.IsNullOrEmpty(model.Login))
{
return context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.Where(x => x.Login.Contains(model.Login))
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public List<ClerkViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.Select(x => x.GetViewModel)
.ToList();
}
public ClerkViewModel? Insert(ClerkBindingModel model)
{
var newClerk = Clerk.Create(model);
if (newClerk == null)
{
return null;
}
using var context = new BankDatabase();
context.Clerks.Add(newClerk);
context.SaveChanges();
return context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.FirstOrDefault(x => x.Id == newClerk.Id)
?.GetViewModel;
}
public ClerkViewModel? Update(ClerkBindingModel model)
{
using var context = new BankDatabase();
var clerk = context.Clerks.FirstOrDefault(x => x.Id == model.Id);
if (clerk == null)
{
return null;
}
clerk.Update(model);
context.SaveChanges();
return context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public ClerkViewModel? Delete(ClerkBindingModel model)
{
using var context = new BankDatabase();
var element = context.Clerks.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Clerks
.Include(x => x.Contributions)
.Include(x => x.Deposits)
.Include(x => x.Clients)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Clerks.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,124 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class clientStorage : IClientStorage
{
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Surname) && string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.Patronymic) && !model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Clients
.Include(x => x.Clerk)
.Include(x => x.Contributions)
.ThenInclude(x => x.Contribution)
.FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Surname) && x.Surname == model.Surname) &&
(!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) &&
(!string.IsNullOrEmpty(model.Patronymic) && x.Patronymic == model.Patronymic)) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
using var context = new BankDatabase();
if (!string.IsNullOrEmpty(model.Surname) && !string.IsNullOrEmpty(model.Name) && !string.IsNullOrEmpty(model.Patronymic))
{
return context.Clients
.Include(x => x.Clerk)
.Include(x => x.Contributions)
.ThenInclude(x => x.Contribution)
.Where(x => (x.Id == model.Id)).ToList()
.Select(x => x.GetViewModel).ToList();
}
else if (model.ClerkId.HasValue)
{
return context.Clients
.Include(x => x.Clerk)
.Include(x => x.Contributions)
.ThenInclude(x => x.Contribution)
.Where(x => x.ClerkId == model.ClerkId)
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public List<ClientViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Clients
.Include(x => x.Clerk)
.Include(x => x.Contributions)
.ThenInclude(x => x.Contribution).ToList()
.Select(x => x.GetViewModel).ToList();
}
public ClientViewModel? Insert(ClientBindingModel model)
{
using var context = new BankDatabase();
var newClient = Client.Create(context, model);
if (newClient == null)
{
return null;
}
context.Clients.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new BankDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var Client = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
if (Client == null)
{
return null;
}
Client.Update(model);
context.SaveChanges();
Client.UpdateContributions(context, model);
transaction.Commit();
return Client.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new BankDatabase();
var element = context.Clients
.Include(x => x.Clerk)
.Include(x => x.Contributions)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,123 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class contributionStorage : IContributionStorage
{
public List<ContributionViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Contributions
.Include(x => x.Clerk)
.Include(x => x.DepositsId)
.Select(x => x.GetViewModel).ToList();
}
public List<ContributionViewModel> GetFilteredList(ContributionSearchModel model)
{
using var context = new BankDatabase();
if (!model.Id.HasValue)
{
return context.Contributions
.Include(x => x.Clerk)
.Include(x => x.Currencies)
.ThenInclude(x => x.Currency)
.Where(x => x.Id == model.Id).ToList()
.Select(x => x.GetViewModel).ToList();
}
else if (model.ClerkId.HasValue)
{
return context.Contributions
.Include(x => x.Clerk)
.Include(x => x.Currencies)
.ThenInclude(x => x.Currency)
.Where(x => x.ClerkId == model.ClerkId)
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public ContributionViewModel? GetElement(ContributionSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Contributions
.Include(x => x.Clerk)
.Include(x => x.Currencies)
.ThenInclude(x => x.Currency)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public ContributionViewModel? Insert(ContributionBindingModel model)
{
using var context = new BankDatabase();
var newContribution = Contribution.Create(context, model);
if (newContribution == null)
{
return null;
}
context.Contributions.Add(newContribution);
context.SaveChanges();
return newContribution.GetViewModel;
}
public ContributionViewModel? Update(ContributionBindingModel model)
{
using var context = new BankDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var Contribution = context.Contributions
.Include(x => x.Clerk)
.FirstOrDefault(rec => rec.Id == model.Id);
if (Contribution == null)
{
return null;
}
Contribution.Update(model);
context.SaveChanges();
Contribution.UpdateCurrency(context, model);
transaction.Commit();
return Contribution.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ContributionViewModel? Delete(ContributionBindingModel model)
{
using var context = new BankDatabase();
var element = context.Contributions
.Include(x => x.Clerk)
.Include(x => x.Currencies)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Contributions.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,101 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class 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)
{
using var context = new BankDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Currencies
.Where(x => x.Name.Contains(model.Name)).ToList()
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public CurrencyViewModel? GetElement(CurrencySearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Currencies
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public CurrencyViewModel? Insert(CurrencyBindingModel model)
{
using var context = new BankDatabase();
var newCurrency = Currency.Create(model);
if (newCurrency == null)
{
return null;
}
context.Currencies.Add(newCurrency);
context.SaveChanges();
return newCurrency.GetViewModel;
}
public CurrencyViewModel? Update(CurrencyBindingModel model)
{
using var context = new BankDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var Currency = context.Currencies
.FirstOrDefault(rec => rec.Id == model.Id);
if (Currency == null)
{
return null;
}
Currency.Update(model);
context.SaveChanges();
transaction.Commit();
return Currency.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
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;
}
}
}

View File

@ -0,0 +1,120 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class DepositsStorage : IDepositsStorage
{
public DepositsViewModel? GetElement(DepositsSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<DepositsViewModel> GetFilteredList(DepositsSearchModel model)
{
using var context = new BankDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.ClerkId.HasValue)
{
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.Where(x => x.ClerkId == model.ClerkId)
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return new();
}
}
public List<DepositsViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.Select(x => x.GetViewModel)
.ToList();
}
public DepositsViewModel? Insert(DepositsBindingModel model)
{
var newDeposits = Deposits.Create(model);
if (newDeposits == null)
{
return null;
}
using var context = new BankDatabase();
context.Deposits.Add(newDeposits);
context.SaveChanges();
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.FirstOrDefault(x => x.Id == newDeposits.Id)
?.GetViewModel;
}
public DepositsViewModel? Update(DepositsBindingModel model)
{
using var context = new BankDatabase();
var Deposits = context.Deposits.FirstOrDefault(x => x.Id == model.Id);
if (Deposits == null)
{
return null;
}
Deposits.Update(model);
context.SaveChanges();
return context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public DepositsViewModel? Delete(DepositsBindingModel model)
{
using var context = new BankDatabase();
var element = context.Deposits.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Deposits
.Include(x => x.Contributions)
.Include(x => x.Clerk)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Deposits.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,108 @@
using BankContracts.BindingModels;
using BankContracts.SearchModels;
using BankContracts.StoragesContracts;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Implements
{
public class ProgramStorage : IProgramStorage
{
public List<ProgramViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Programs
.Include(x => x.Currencies)
.Select(x => x.GetViewModel)
.ToList();
}
public List<ProgramViewModel> GetFilteredList(ProgramSearchModel model)
{
using var context = new BankDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Programs
.Include(x => x.Currencies)
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public ProgramViewModel? GetElement(ProgramSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new BankDatabase();
return context.Programs
.Include(x => x.Currencies)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ProgramViewModel? Insert(ProgramBindingModel model)
{
using var context = new BankDatabase();
var newProgram = Program.Create(context, model);
if (newProgram == null)
{
return null;
}
context.Programs.Add(newProgram);
context.SaveChanges();
return newProgram.GetViewModel;
}
public ProgramViewModel? Update(ProgramBindingModel model)
{
using var context = new BankDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var program = context.Programs
.FirstOrDefault(rec => rec.Id == model.Id);
if (program == null)
{
return null;
}
program.Update(model);
context.SaveChanges();
program.UpdateCurrency(context, model);
transaction.Commit();
return program.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ProgramViewModel? Delete(ProgramBindingModel model)
{
using var context = new BankDatabase();
var element = context.Programs
.Include(x => x.Currencies)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Programs.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,83 @@
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BankContracts.BindingModels;
using BankContracts.ViewModels;
namespace BankDatabaseImplement.Models
{
public class Clerk : IClerkModel
{
public int Id { get; set; }
[Required]
[MaxLength(25)]
public string Login { get; set; } = string.Empty;
[Required]
[MaxLength(11)]
public string PhoneNumber { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string Password { get; set; } = string.Empty;
[ForeignKey("ClerkId")]
public virtual List<Client> Clients { get; set; } = new();
[ForeignKey("ClerkId")]
public virtual List<Contribution> Contributions { get; set; } = new();
[ForeignKey("ClerkId")]
public virtual List<Deposits> Deposits { get; set; } = new();
public static Clerk? Create(ClerkBindingModel model)
{
if (model == null)
{
return null;
}
return new Clerk()
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}
public static Clerk Create(ClerkViewModel model)
{
return new Clerk
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}
public void Update(ClerkBindingModel model)
{
if (model == null)
{
return;
}
Login = model.Login;
PhoneNumber = model.PhoneNumber;
Password = model.Password;
}
public ClerkViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
PhoneNumber = PhoneNumber,
Password = Password
};
}
}

View File

@ -0,0 +1,136 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace BankDatabaseImplement.Models
{
public class Client : IClientModel
{
public int Id { get; set; }
public int ClerkId { get; private set; }
public virtual Clerk Clerk { get; set; }
[Required]
[MaxLength(50)]
public string Surname { get; set; } = string.Empty;
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[Required]
[MaxLength(50)]
public string Patronymic { get; set; } = string.Empty;
[Required]
public int Age { get; set; }
private Dictionary<int, IContributionModel>? _clientContributions = null;
[NotMapped]
public Dictionary<int, IContributionModel> ClientContributions
{
get
{
if (_clientContributions == null)
{
_clientContributions = Contributions.ToDictionary(recPR => recPR.ContributionId, recPR => (recPR.Contribution as IContributionModel));
}
return _clientContributions;
}
}
[ForeignKey("ClientId")]
public virtual List<ClientContribution> Contributions { get; set; } = new();
private Dictionary<int, IProgramModel>? _clientPrograms = null;
[NotMapped]
public Dictionary<int, IProgramModel> ClientPrograms
{
get
{
if (_clientPrograms == null)
{
_clientPrograms = Programs.ToDictionary(recPP => recPP.ProgramId, recPP => (recPP.Program as IProgramModel));
}
return _clientPrograms;
}
}
[ForeignKey("ClientId")]
public virtual List<ClientProgram> Programs { get; set; } = new();
public static Client Create(BankDatabase context, ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Surname = model.Surname,
Name = model.Name,
Patronymic = model.Patronymic,
Age = model.Age,
ClerkId = model.ClerkId,
Clerk = context.Clerks.First(x => x.Id == model.ClerkId),
Contributions = model.ClientContributions.Select(x => new ClientContribution
{
Contribution = context.Contributions.First(y => y.Id == x.Key),
}).ToList(),
Programs = model.ClientPrograms.Select(x => new ClientProgram
{
Program = context.Programs.First(y => y.Id == x.Key),
}).ToList()
};
}
public void Update(ClientBindingModel model)
{
Surname = model.Surname;
Name = model.Name;
Patronymic = model.Patronymic;
Age = model.Age;
}
public ClientViewModel GetViewModel => new()
{
Surname = Surname,
Name = Name,
Patronymic = Patronymic,
Age = Age,
ClientContributions = ClientContributions,
ClientPrograms = ClientPrograms
};
public void UpdateContributions(BankDatabase context, ClientBindingModel model)
{
var ClientContributions = context.ClientContributions.Where(rec => rec.ClientId == model.Id).ToList();
if (ClientContributions != null)
{
context.ClientContributions.RemoveRange(ClientContributions.Where(rec => !model.ClientContributions.ContainsKey(rec.ContributionId)));
context.SaveChanges();
}
var Client = context.Clients.First(x => x.Id == Id);
foreach (var pr in model.ClientContributions)
{
context.ClientContributions.Add(new ClientContribution
{
Client = Client,
Contribution = context.Contributions.First(x => x.Id == pr.Key),
});
context.SaveChanges();
}
_clientContributions = null;
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class ClientContribution
{
public int Id { get; set; }
[Required]
public int ClientId { get; set; }
[Required]
public int ContributionId { get; set; }
public virtual Client Client { get; set; } = new();
public virtual Contribution Contribution { get; set; } = new();
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class 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();
}
}

View File

@ -0,0 +1,97 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace BankDatabaseImplement.Models
{
public class Contribution : IContributionModel
{
public int Id { get; set; }
public int ClerkId { get; private set; }
public virtual Clerk Clerk { get; set; }
public int DepositsId { get; private set; }
public virtual Deposits Deposits { get; set; }
[Required]
public DateTime IssueDate { get; private set; } = DateTime.Now;
private Dictionary<int, ICurrencyModel>? _contributionCurrency = null;
[NotMapped]
public Dictionary<int, ICurrencyModel> ContributionCurrencies
{
get
{
if (_contributionCurrency == null)
{
_contributionCurrency = Currencies.ToDictionary(recRM => recRM.CurrencyId, recRM => (recRM.Currency as ICurrencyModel));
}
return _contributionCurrency;
}
}
[ForeignKey("ContributionId")]
public virtual List<ContributionCurrency> Currencies { get; set; } = new();
public static Contribution Create(BankDatabase context, ContributionBindingModel model)
{
return new Contribution()
{
Id = model.Id,
IssueDate = model.IssueDate,
DepositsId = model.DepositsId,
ClerkId = model.ClerkId,
Clerk = context.Clerks.First(x => x.Id == model.ClerkId),
Currencies = model.ContributionCurrencies.Select(x => new ContributionCurrency
{
Currency = context.Currencies.First(y => y.Id == x.Key),
}).ToList()
};
}
public void Update(ContributionBindingModel model)
{
IssueDate = model.IssueDate;
}
public ContributionViewModel GetViewModel => new()
{
Id = Id,
IssueDate = IssueDate,
ContributionCurrencies = ContributionCurrencies
};
public void UpdateCurrency(BankDatabase context, ContributionBindingModel model)
{
var ContributionCurrencies = context.ContributionCurrencies.Where(rec => rec.ContributionId == model.Id).ToList();
if (ContributionCurrencies != null)
{
context.ContributionCurrencies.RemoveRange(ContributionCurrencies.Where(rec => !model.ContributionCurrencies.ContainsKey(rec.CurrencyId)));
context.SaveChanges();
}
var Contribution = context.Contributions.First(x => x.Id == Id);
foreach (var pr in model.ContributionCurrencies)
{
context.ContributionCurrencies.Add(new ContributionCurrency
{
Contribution = Contribution,
Currency = context.Currencies.First(x => x.Id == pr.Key),
});
context.SaveChanges();
}
_contributionCurrency = null;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class ContributionCurrency
{
public int Id { get; set; }
[Required]
public int ContributionId { get; set; }
[Required]
public int CurrencyId { get; set; }
public virtual Contribution Contribution { get; set; } = new();
public virtual Currency Currency { get; set; } = new();
}
}

View File

@ -0,0 +1,60 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace BankDatabaseImplement.Models
{
public class Currency : ICurrencyModel
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[ForeignKey("CurrencyId")]
public virtual List<ContributionCurrency> ContributionCurrencies { get; set; } = new();
public static Currency? Create(CurrencyBindingModel model)
{
if (model == null)
{
return null;
}
return new Currency()
{
Id = model.Id,
Name = model.Name
};
}
public static Currency Create(CurrencyViewModel model)
{
return new Currency
{
Id = model.Id,
Name = model.Name
};
}
public void Update(CurrencyBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public CurrencyViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}

View File

@ -0,0 +1,75 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class Deposits : IDepositsModel
{
public int Id { get; set; }
public int ClerkId { get; private set; }
public virtual Clerk Clerk { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[Required]
[MaxLength(150)]
public string Reasons { get; set; } = string.Empty;
[ForeignKey("DepositsId")]
public virtual List<Contribution> Contributions { get; set; } = new();
public static Deposits? Create(DepositsBindingModel model)
{
if (model == null)
{
return null;
}
return new Deposits()
{
Id = model.Id,
Name = model.Name,
Reasons = model.Reasons,
ClerkId = model.ClerkId
};
}
public static Deposits Create(DepositsViewModel model)
{
return new Deposits
{
Id = model.Id,
Name = model.Name,
Reasons = model.Reasons
};
}
public void Update(DepositsBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Reasons = model.Reasons;
}
public DepositsViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Reasons = Reasons
};
}
}

View File

@ -0,0 +1,91 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace BankDatabaseImplement.Models
{
public class Program : IProgramModel
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[ForeignKey("ProgramId")]
public virtual List<ClientProgram> ClientPrograms { get; set; } = new();
private Dictionary<int, ICurrencyModel>? _programCurrencies = null;
[NotMapped]
public Dictionary<int, ICurrencyModel> ProgramCurrencies
{
get
{
if (_programCurrencies == null)
{
_programCurrencies = Currencies.ToDictionary(recPM => recPM.CurrencyId, recPM =>(recPM.Currency as ICurrencyModel));
}
return _programCurrencies;
}
}
[ForeignKey("ProgramId")]
public virtual List<ProgramCurrency> Currencies { get; set; } = new();
public static Program Create(BankDatabase context, ProgramBindingModel model)
{
return new Program()
{
Id = model.Id,
Name = model.Name,
Currencies = model.ProgramCurrencies.Select(x => new ProgramCurrency
{
Currency = context.Currencies.First(y => y.Id == x.Key)
}).ToList()
};
}
public void Update(ProgramBindingModel model)
{
Name = model.Name;
}
public ProgramViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
ProgramCurrencies = ProgramCurrencies
};
public void UpdateCurrency(BankDatabase context, ProgramBindingModel model)
{
var ProgramCurrencies = context.ProgramCurrencies.Where(rec => rec.ProgramId == model.Id).ToList();
if (ProgramCurrencies != null)
{
context.ProgramCurrencies.RemoveRange(ProgramCurrencies.Where(rec => !model.ProgramCurrencies.ContainsKey(rec.CurrencyId)));
context.SaveChanges();
}
var Program = context.Programs.First(x => x.Id == Id);
foreach (var pm in model.ProgramCurrencies)
{
context.ProgramCurrencies.Add(new ProgramCurrency
{
Program = Program,
Currency = context.Currencies.First(x => x.Id == pm.Key)
});
context.SaveChanges();
}
_programCurrencies = null;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class 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();
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BankDatabaseImplement\BankDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,191 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
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()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpGet]
public IActionResult Clients()
{
List<ClientViewModel> clients = new List<ClientViewModel>
{
new ClientViewModel
{
Id = 1,
},
new ClientViewModel
{
Id = 2,
}
};
return View(clients);
}
[HttpGet]
public IActionResult Client()
{
var programs = new List<ProgramViewModel>();
programs.Add(new ProgramViewModel
{
Id = 1,
}) ;
programs.Add(new ProgramViewModel
{
Id = 1,
});
return View(programs);
}
[HttpGet]
public IActionResult Contributions()
{
List<ContributionViewModel> contributions = new List<ContributionViewModel>
{
new ContributionViewModel
{
Id = 1,
},
new ContributionViewModel
{
Id = 2,
}
};
return View(contributions);
}
[HttpGet]
public IActionResult Contribution()
{
return View();
}
[HttpGet]
public IActionResult ConnectionContributionClient()
{
List<ClientViewModel> clients = new List<ClientViewModel>
{
new ClientViewModel
{
Id = 1,
ClientPrograms= new()
},
new ClientViewModel
{
Id = 2,
ClientPrograms= new()
}
};
return View(clients);
}
[HttpGet]
public IActionResult Reports()
{
return View();
}
[HttpGet]
public IActionResult ProgramProgramReport()
{
List<ReportClientCurrencyViewModel> programContributions = new List<ReportClientCurrencyViewModel>
{
new ReportClientCurrencyViewModel
{
},
new ReportClientCurrencyViewModel
{
}
};
return View(programContributions);
}
[HttpGet]
public IActionResult ClientDateReport()
{
List<ReportClientsViewModel> clientTimeReports = new List<ReportClientsViewModel>
{
new ReportClientsViewModel
{
},
new ReportClientsViewModel
{
}
};
return View(clientTimeReports);
}
[HttpGet]
public IActionResult Depositss()
{
List<DepositsViewModel> depositss = new List<DepositsViewModel>
{
new DepositsViewModel
{
Id = 1,
},
new DepositsViewModel
{
Id = 1,
}
};
return View(depositss);
}
[HttpGet]
public IActionResult Deposits()
{
var contributions = new List<ContributionViewModel>();
contributions.Add(new ContributionViewModel
{
Id = 1,
});
contributions.Add(new ContributionViewModel
{
Id = 2,
});
return View(contributions);
}
}
}

View File

@ -0,0 +1,9 @@
namespace BankWorkerApp.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,29 @@
using BankWorkerApp;
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 program 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();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:30752",
"sslPort": 44368
}
},
"profiles": {
"BankWorkerApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7012;http://localhost:5094",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,48 @@

@{
ViewData["Title"] = "Connect plan and clients";
}
<div class="text-center">
<h3 class="display-4">Привязка заготовок к плану производства:</h3>
</div>
<form method="post">
<div class="row">
<div class="col-4">План производства:</div>
<div class="col-8">
<select id="planprogram" name="planprogram" class="form-control"></select>
</div>
</div>
<h3>Список заготовок</h3>
<div class="container">
<div>Клиент</div>
<div class="table-responsive-lg">
<table id="detailsTable" class="display">
<thead>
<tr>
<th>Выбор </th>
<th>Название </th>
<th>Количество</th>
</tr>
</thead>
<tbody>
@foreach (var client in Model)
{
<tr>
<td>
<input type="checkbox" name="clients" value="@client.Id" />
</td>
<td>@client.ClientName</td>
<td>
<input type="number" name="count" value="0" min="0" class="form-control" />
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,29 @@

@{
ViewData["Title"] = "Client";
}
<div class="text-center">
<h2 class="display-4">Заготовка</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">План производства:</div>
<div class="col-8">
<select id="planprogram" name="planprogram" class="form-control"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" /></div>
</div>
<div class="row">
<div class="col-4">Статус:</div>
<div class="col-8">
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,52 @@
@using BankContracts.ViewModels
@model List<DepositsViewModel>
@{
ViewData["Title"] = "Execution Phases";
}
<div class="text-center">
<h1 class="display-4">Пополнения</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="Deposits">Создать этап</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Название
</th>
<th>
ФИО исполнителя
</th>
<th>
Статус
</th>
<th>
План производства
</th>
<th>
Изменить этап
</th>
<th>
Удалить этап
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
}
</div>

Some files were not shown because too many files have changed in this diff Show More