Начальный набросок кода
This commit is contained in:
parent
a924450d0c
commit
8ad8b44a23
49
Bank/Bank.sln
Normal file
49
Bank/Bank.sln
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32901.215
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankView", "BankView\BankView.csproj", "{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankBuisinessLogics", "BankBuisinessLogics\BankBuisinessLogics.csproj", "{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataBaseImplement", "BankDataBaseImplement\BankDataBaseImplement.csproj", "{6F86B4CB-FBAD-4E00-B285-D082393A3157}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataModels", "BankDataModels\BankDataModels.csproj", "{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankContracts", "BankContracts\BankContracts.csproj", "{4B7AB326-2F82-45E3-8478-3EB0B398161A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6F86B4CB-FBAD-4E00-B285-D082393A3157}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6F86B4CB-FBAD-4E00-B285-D082393A3157}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6F86B4CB-FBAD-4E00-B285-D082393A3157}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6F86B4CB-FBAD-4E00-B285-D082393A3157}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B7AB326-2F82-45E3-8478-3EB0B398161A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B7AB326-2F82-45E3-8478-3EB0B398161A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B7AB326-2F82-45E3-8478-3EB0B398161A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B7AB326-2F82-45E3-8478-3EB0B398161A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D4FA3705-E6CF-4A2E-B038-370AB28E4470}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
27
Bank/BankBuisinessLogics/BankBuisinessLogics.csproj
Normal file
27
Bank/BankBuisinessLogics/BankBuisinessLogics.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="OfficePackage\HelperEnums\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BancContracts\BankContracts.csproj" />
|
||||
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||
<ProjectReference Include="..\BankDataBaseImplement\BankDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||
<ProjectReference Include="..\BankView\BankView.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
171
Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs
Normal file
171
Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs
Normal file
@ -0,0 +1,171 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClercLogic : IClercLogic
|
||||
{
|
||||
private readonly int _loginMaxLength = 50;
|
||||
private readonly int _passwordMaxLength = 50;
|
||||
private readonly int _passwordMinLength = 10;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClercStorage _ClercStorage;
|
||||
|
||||
public ClercLogic(ILogger<ClercLogic> logger, IClercStorage clercStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clercStorage = clercStorage;
|
||||
}
|
||||
|
||||
public bool Create(ClercBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_clercStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClercBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
|
||||
if (_clercStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ClercViewModel? ReadElement(ClercSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}.", model.ClercFIO, model.ClercLogin, model.Id);
|
||||
|
||||
var element = _clercStorage.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<ClercViewModel>? ReadList(ClercSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}.", model?.ClercFIO, model?.ClercLogin, model?.Id);
|
||||
|
||||
var list = model == null ? _clercStorage.GetFullList() : _clercStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ClercBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_clercStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ClercBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ClercFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО организатора", nameof(model.ClercFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ClercLogin))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина организатора", nameof(model.ClercLogin));
|
||||
}
|
||||
|
||||
if (model.ClercLogin.Length>_loginMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Логин слишком длинный", nameof(model.ClercLogin));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ClercNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона организатора", nameof(model.ClercNumber));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ClercEmail))
|
||||
{
|
||||
throw new ArgumentNullException("Нет почты организатора", nameof(model.ClercEmail));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ClercPassword))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля организатора", nameof(model.ClercPassword));
|
||||
}
|
||||
|
||||
if (model.ClercPassword.Length < _passwordMinLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком короткий", nameof(model.ClercPassword));
|
||||
}
|
||||
|
||||
if (model.ClercPassword.Length > _passwordMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком длинный", nameof(model.ClercPassword));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Clerc. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}", model.ClercFIO, model.ClercLogin, model.Id);
|
||||
|
||||
var element = _clercStorage.GetElement(new ClercSearchModel
|
||||
{
|
||||
ClercLogin = model.ClercLogin
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Организатор с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
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 ConferenceBookingLogic : IConferenceBookingLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
||||
|
||||
public ConferenceBookingLogic(ILogger<ConferenceBookingLogic> logger, IConferenceBookingStorage conferenceBookingStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_conferenceBookingStorage = conferenceBookingStorage;
|
||||
}
|
||||
public bool Create(ConferenceBookingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceBookingStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConferenceBookingBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_conferenceBookingStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Id:{Id}", model.Id);
|
||||
|
||||
var element = _conferenceBookingStorage.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<ConferenceBookingViewModel>? ReadList(ConferenceBookingSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
|
||||
var list = model == null ? _conferenceBookingStorage.GetFullList() : _conferenceBookingStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ConferenceBookingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceBookingStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ConferenceBookingBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ConferenceBooking. Id: { Id}", model.Id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs
Normal file
120
Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ConferenceLogic : IConferenceLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
|
||||
public ConferenceLogic(ILogger<ConferenceLogic> logger, IConferenceStorage conferenceStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
}
|
||||
public bool Create(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_conferenceStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConferenceViewModel? ReadElement(ConferenceSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ConferenceName:{ConferenceName}.Id:{Id}", model.ConferenceName, model.Id);
|
||||
|
||||
var element = _conferenceStorage.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<ConferenceViewModel>? ReadList(ConferenceSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ConferenceName:{ConferenceName}.Id:{ Id}", model?.ConferenceName, model?.Id);
|
||||
|
||||
var list = model == null ? _conferenceStorage.GetFullList() : _conferenceStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ConferenceBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ConferenceName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия конференции", nameof(model.ConferenceName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Conference. ConferenceName:{ConferenceName}.StartDate:{ StartDate}. Id: { Id}", model.ConferenceName, model.StartDate, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
130
Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs
Normal file
130
Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs
Normal file
@ -0,0 +1,130 @@
|
||||
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 DinnerLogic : IDinnerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDinnerStorage _dinnerStorage;
|
||||
|
||||
public DinnerLogic(ILogger<DinnerLogic> logger, IDinnerStorage dinnerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dinnerStorage = dinnerStorage;
|
||||
}
|
||||
|
||||
public bool Create(DinnerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_dinnerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(DinnerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_dinnerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DinnerViewModel? ReadElement(DinnerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. DinnerName:{DinnerName}.Id:{Id}", model.DinnerName, model.Id);
|
||||
|
||||
var element = _dinnerStorage.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<DinnerViewModel>? ReadList(DinnerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. DinnerName:{DinnerName}.Id:{ Id}", model?.DinnerName, model?.Id);
|
||||
|
||||
var list = model == null ? _dinnerStorage.GetFullList() : _dinnerStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(DinnerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_dinnerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(DinnerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.DinnerName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени обеда", nameof(model.DinnerName));
|
||||
}
|
||||
|
||||
if (model.DinnerPrice < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость обеда не может быть меньше 0", nameof(model.DinnerPrice));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Dinner. DinnerName:{DinnerName}.DinnerPrice:{ DinnerPrice}. Id: { Id}", model.DinnerName, model.DinnerPrice, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
176
Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs
Normal file
176
Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs
Normal file
@ -0,0 +1,176 @@
|
||||
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 HeadwaiterLogic : IHeadwaiterLogic
|
||||
{
|
||||
private readonly int _loginMaxLength = 50;
|
||||
private readonly int _passwordMaxLength = 50;
|
||||
private readonly int _passwordMinLength = 10;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHeadwaiterStorage _headwaiterStorage;
|
||||
|
||||
public HeadwaiterLogic(ILogger<HeadwaiterLogic> logger, IHeadwaiterStorage headwaiterStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_headwaiterStorage = headwaiterStorage;
|
||||
}
|
||||
|
||||
public bool Create(HeadwaiterBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_headwaiterStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(HeadwaiterBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
|
||||
if (_headwaiterStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public HeadwaiterViewModel? ReadElement(HeadwaiterSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id);
|
||||
|
||||
var element = _headwaiterStorage.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<HeadwaiterViewModel>? ReadList(HeadwaiterSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model?.HeadwaiterFIO, model?.HeadwaiterLogin, model?.Id);
|
||||
|
||||
var list = model == null ? _headwaiterStorage.GetFullList() : _headwaiterStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(HeadwaiterBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_headwaiterStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(HeadwaiterBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО метродотеля", nameof(model.HeadwaiterFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterLogin))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина метродотеля", nameof(model.HeadwaiterLogin));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterLogin.Length > _loginMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Логин слишком длинный", nameof(model.HeadwaiterLogin));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона метродотеля", nameof(model.HeadwaiterNumber));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterEmail))
|
||||
{
|
||||
throw new ArgumentNullException("Нет почты метродотеля", nameof(model.HeadwaiterEmail));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterPassword))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля метродотеля", nameof(model.HeadwaiterPassword));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterPassword.Length < _passwordMinLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком короткий", nameof(model.HeadwaiterPassword));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterPassword.Length > _passwordMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком длинный", nameof(model.HeadwaiterPassword));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Headwaiter. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id);
|
||||
|
||||
var element = _headwaiterStorage.GetElement(new HeadwaiterSearchModel
|
||||
{
|
||||
HeadwaiterLogin = model.HeadwaiterLogin
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("метродотель с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
135
Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs
Normal file
135
Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MealPlanLogic : IMealPlanLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
|
||||
public MealPlanLogic(ILogger<MealPlanLogic> logger, IMealPlanStorage mealPlanStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
}
|
||||
public bool Create(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_mealPlanStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MealPlanViewModel? ReadElement(MealPlanSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.MealPlanName, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.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<MealPlanViewModel>? ReadList(MealPlanSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.MealPlanName, model?.Id);
|
||||
|
||||
var list = model == null ? _mealPlanStorage.GetFullList() : _mealPlanStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MealPlanBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MealPlanName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия плана питания", nameof(model.MealPlanName));
|
||||
}
|
||||
|
||||
if (model.MealPlanPrice<0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость плана питания не может быть меньше 0", nameof(model.MealPlanPrice));
|
||||
}
|
||||
|
||||
_logger.LogInformation("MealPlan. MealPlanName:{MealPlanName}.MealPlanPrice:{ MealPlanPrice}. Id: { Id}", model.MealPlanName, model.MealPlanPrice, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(new MealPlanSearchModel
|
||||
{
|
||||
MealPlanName = model.MealPlanName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("План питания с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
125
Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs
Normal file
125
Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MemberLogic : IMemberLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMemberStorage _memberStorage;
|
||||
|
||||
public MemberLogic(ILogger<MemberLogic> logger, IMemberStorage memberStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_memberStorage = memberStorage;
|
||||
}
|
||||
|
||||
public bool Create(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_memberStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_memberStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MemberViewModel? ReadElement(MemberSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. MemberFIO:{MemberFIO}.Id:{Id}", model.MemberFIO, model.Id);
|
||||
|
||||
var element = _memberStorage.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<MemberViewModel>? ReadList(MemberSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MemberFIO:{MemberFIO}.Id:{ Id}", model?.MemberFIO, model?.Id);
|
||||
|
||||
var list = model == null ? _memberStorage.GetFullList() : _memberStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_memberStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(MemberBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MemberFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО участника", nameof(model.MemberFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.Citizenship))
|
||||
{
|
||||
throw new ArgumentNullException("Не указано гражданство участника", nameof(model.Citizenship));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Member. MemberFIO:{MemberFIO}.Citizenship:{ Citizenship}. Id: { Id}", model.MemberFIO, model.Citizenship, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using BankBusinessLogic.OfficePackage;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogicHeadwaiter : IReportHeadwaiterLogic
|
||||
{
|
||||
private readonly IRoomStorage _roomStorage;
|
||||
private readonly IDinnerStorage _dinnerStorage;
|
||||
private readonly IMealPlanStorage _mealPlansStorage;
|
||||
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
||||
private readonly AbstractSaveToExcelHeadwaiter _saveToExcel;
|
||||
private readonly AbstractSaveToWordHeadwaitre _saveToWord;
|
||||
private readonly AbstractSaveToPdfHeadwaiter _saveToPdf;
|
||||
public ReportLogicHeadwaiter(IRoomStorage roomStorage, IDinnerStorage dinnerStorage, IMealPlanStorage mealPlansStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf)
|
||||
{
|
||||
_roomStorage = roomStorage;
|
||||
_dinnerStorage = dinnerStorage;
|
||||
_mealPlansStorage = mealPlansStorage;
|
||||
_conferenceBookingStorage = conferenceBookingStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
public List<ReportMealPlanDinnerViewModel> GetMealPlanDinner()
|
||||
{
|
||||
var mealPlans = _mealPlansStorage.GetFullList();
|
||||
var dinners = _dinnerStorage.GetFullList();
|
||||
var list = new List<ReportMealPlanDinnerViewModel>();
|
||||
foreach (var dinner in dinners)
|
||||
{
|
||||
var record = new ReportMealPlanDinnerViewModel
|
||||
{
|
||||
DinnerName = dinner.DinnerName,
|
||||
MealPlans = new List<Tuple<string, DateTime>>()
|
||||
};
|
||||
foreach (var mealPlan in mealPlans)
|
||||
{
|
||||
if (mealPlan.MealPlanDinners.ContainsKey(dinner.Id))
|
||||
{
|
||||
record.MealPlans.Add(new Tuple<string, DateTime>(mealPlans.MealPlanName, mealPlans.StartDate));
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportConferenceBindingRoomsViewModel> GetConferenceBindingRooms(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
var listAll = new List<ReportConferenceBindingRoomsViewModel>();
|
||||
|
||||
var listConferenceBinding = _conferenceBookingStorage.GetFilteredList(new ConferenceBookingSearchModel
|
||||
{
|
||||
HeadwaiterId = model.HeadwaiterId,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
var listRooms = _roomStorage.GetFilteredList(new RoomSearchModel());
|
||||
|
||||
foreach (var room in listRooms)
|
||||
{
|
||||
listAll.Add(new ReportConferenceBindingRoomsViewModel
|
||||
{
|
||||
RoomName = room.RoomName,
|
||||
RoomPrice = room.RoomPrice,
|
||||
RoomFrame = room.RoomFrame
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return listAll;
|
||||
}
|
||||
|
||||
public void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoHeadwaiter
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
MealPlanDinner = GetMealPlanDinner()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfoHeadwaiter
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
MealPlanDinner = GetMealPlanDinner()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoHeadwaiter
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
DateFrom = model.DateFrom!.Value,
|
||||
DateTo = model.DateTo!.Value,
|
||||
ConferenceBindingRooms = GetConferenceBindingRooms(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
124
Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs
Normal file
124
Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using BankBusinessLogic.OfficePackage;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogicOrganiser : IReportOrganiserLogic
|
||||
{
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
private readonly IMemberStorage _memberStorage;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
private readonly AbstractSaveToExcelOrganiser _saveToExcel;
|
||||
private readonly AbstractSaveToWordClerc _saveToWord;
|
||||
private readonly AbstractSaveToPdfClerc _saveToPdf;
|
||||
public ReportLogicOrganiser(IMealPlanStorage mealPlanStorage, IMemberStorage memberStorage, IConferenceStorage conferenceStorage, AbstractSaveToExcelOrganiser saveToExcel, AbstractSaveToWordClerc saveToWord, AbstractSaveToPdfClerc saveToPdf)
|
||||
{
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
_memberStorage = memberStorage;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
public List<ReportMemberConferenceViewModel> GetMemberConference()
|
||||
{
|
||||
var conferences = _conferenceStorage.GetFullList();
|
||||
var members = _memberStorage.GetFullList();
|
||||
var list = new List<ReportMemberConferenceViewModel>();
|
||||
foreach (var member in members)
|
||||
{
|
||||
var record = new ReportMemberConferenceViewModel
|
||||
{
|
||||
MemberFIO = member.MemberFIO,
|
||||
Conferences = new List<Tuple<string, DateTime>>()
|
||||
};
|
||||
foreach (var conference in conferences)
|
||||
{
|
||||
if (conference.ConferenceMembers.ContainsKey(member.Id))
|
||||
{
|
||||
record.Conferences.Add(new Tuple<string, DateTime>(conference.ConferenceName, conference.StartDate));
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportMembersViewModel> GetMembers(ReportBindingModel model)
|
||||
{
|
||||
var listAll = new List<ReportMembersViewModel>();
|
||||
|
||||
var listСonferences = _conferenceStorage.GetFilteredList(new ConferenceSearchModel
|
||||
{
|
||||
OrganiserId = model.OrganiserId,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
foreach (var conference in listСonferences)
|
||||
{
|
||||
foreach (var c in conference.ConferenceMembers)
|
||||
{
|
||||
listAll.Add(new ReportMembersViewModel
|
||||
{
|
||||
StartDate = conference.StartDate,
|
||||
ConferenceName = conference.ConferenceName,
|
||||
MemberFIO=c.Value.MemberFIO
|
||||
});
|
||||
}
|
||||
}
|
||||
var listMealPlans = _mealPlanStorage.GetFilteredList(new MealPlanSearchModel());
|
||||
|
||||
foreach (var mealPlan in listMealPlans)
|
||||
{
|
||||
listAll.Add(new ReportMembersViewModel
|
||||
{
|
||||
MealPlanName = mealPlan.MealPlanName,
|
||||
MealPlanPrice = mealPlan.MealPlanPrice
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return listAll;
|
||||
}
|
||||
|
||||
public void SaveMemberConferenceToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoOrganiser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
MemberConferences = GetMemberConference()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveMemberConferenceToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfoClerc
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
MemberConferences = GetMemberConference()
|
||||
}) ;
|
||||
}
|
||||
|
||||
public void SaveMembersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoClerc
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
DateFrom = model.DateFrom!.Value,
|
||||
DateTo = model.DateTo!.Value,
|
||||
Members = GetMembers(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
136
Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs
Normal file
136
Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs
Normal file
@ -0,0 +1,136 @@
|
||||
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 RoomLogic : IRoomLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRoomStorage _roomStorage;
|
||||
|
||||
public RoomLogic(ILogger<RoomLogic> logger, IRoomStorage roomStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_roomStorage = roomStorage;
|
||||
}
|
||||
public bool Create(RoomBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_roomStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(RoomBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_roomStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public RoomViewModel? ReadElement(RoomSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. RoomName:{RoomName}.Id:{Id}", model.RoomName, model.Id);
|
||||
|
||||
var element = _roomStorage.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<RoomViewModel>? ReadList(RoomSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. RoomName:{RoomName}.Id:{ Id}", model?.RoomName, model?.Id);
|
||||
|
||||
var list = model == null ? _roomStorage.GetFullList() : _roomStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(RoomBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_roomStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(RoomBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.RoomName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия комнате", nameof(model.RoomName));
|
||||
}
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(model.RoomFrame))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия корпусу", nameof(model.RoomFrame));
|
||||
}
|
||||
|
||||
if (model.RoomPrice < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость комнаты не может быть меньше 0", nameof(model.RoomPrice));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Room. RoomName:{RoomName}.RoomFrame:{ RoomFrame}.RoomPrice:{ RoomPrice}. Id: { Id}", model.RoomName, model.RoomFrame, model.RoomPrice, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcelClerc
|
||||
{
|
||||
public void CreateReport(ExcelInfoClerc 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 mc in info.MemberConferences)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = mc.MemberFIO,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
|
||||
foreach (var conference in mc.Conferences)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = conference.Item1,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = conference.Item2.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(ExcelInfoClerc info);
|
||||
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
||||
protected abstract void SaveExcel(ExcelInfoClerc info);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
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 AbstractSaveToExcelHeadwaiter
|
||||
{
|
||||
public void CreateReport(ExcelInfoHeadwaiter 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 mc in info.MealPlanDinner)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = mc.DinnerName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
|
||||
foreach (var mealPlan in mc.MealPlans)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = mealPlan.Item1,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = mealPlan.Item2.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(ExcelInfoHeadwaiter info);
|
||||
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
||||
protected abstract void SaveExcel(ExcelInfoHeadwaiter info);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfClerc
|
||||
{
|
||||
public void CreateDoc(PdfInfoClerc 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", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "ФИО участника", "Название конференции", "Дата начала конференции", "Название плана питания", "Стоимость плана питания" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var member in info.Members)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { member.Id.ToString(), member.ConferenceName, member.StartDate.ToShortDateString(), member.MealPlanName, member.MealPlanPrice.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Members.Sum(x => x.MealPlanPrice)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfoClerc info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfoClerc info);
|
||||
}
|
||||
}
|
@ -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 AbstractSaveToPdfHeadwaiter
|
||||
{
|
||||
public void CreateDoc(PdfInfoHeadwaiter 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", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Название команты", "Корпус комнтаы", "Цена комнаты" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var conferenceBindingRooms in info.ConferenceBindingRooms)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { conferenceBindingRooms.Id.ToString(), conferenceBindingRooms.RoomName, conferenceBindingRooms.RoomFrame, conferenceBindingRooms.RoomPrice.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.ConferenceBindingRooms.Sum(x => x.RoomPrice)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfoHeadwaiter info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfoHeadwaiter info);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWordClerc
|
||||
{
|
||||
public void CreateDoc(WordInfoClerc 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 mc in info.MemberConferences)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (mc.MemberFIO+" - ", new WordTextProperties { Size = "24", Bold=true})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var conference in mc.Conferences)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (conference.Item1 + " - ", new WordTextProperties { Size = "20", Bold=false}),
|
||||
(conference.Item2.ToShortDateString(), new WordTextProperties { Size = "20", Bold=false})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateWord(WordInfoClerc info);
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
protected abstract void SaveWord(WordInfoClerc info);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
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 AbstractSaveToWordHeadwaitre
|
||||
{
|
||||
public void CreateDoc(WordInfoHeadwaiter 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 mc in info.MealPlanDinner)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (mc.DinnerName+" - ", new WordTextProperties { Size = "24", Bold=true})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var mealPlan in mc.MealPlans)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (mealPlan.Item1 + " - ", new WordTextProperties { Size = "20", Bold=false}),
|
||||
(mealPlan.Item2.ToShortDateString(), new WordTextProperties { Size = "20", Bold=false})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateWord(WordInfoHeadwaiter info);
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
protected abstract void SaveWord(WordInfoHeadwaiter info);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Rigth
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoClerc
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportMemberConferenceViewModel> MemberConferences
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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 ExcelInfoHeadwaiter
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportMealPlanDinnerViewModel> MealPlanDinner
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
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}";
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfoClerc
|
||||
{
|
||||
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<ReportMembersViewModel> Members { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
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 PdfInfoHeadwaiter
|
||||
{
|
||||
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<ReportConferenceBindingRoomsViewModel> ConferenceBindingRooms { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfoClerc
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportMemberConferenceViewModel> MemberConferences { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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 WordInfoHeadwaiter
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportMealPlanDinnerViewModel> MealPlanDinner { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
public bool Bold { get; set; }
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,329 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcelClerc : AbstractSaveToExcelClerc
|
||||
{
|
||||
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
|
||||
var borderThin = new Border();
|
||||
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats()
|
||||
{
|
||||
Count = 1U
|
||||
};
|
||||
var cellFormatStyle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U
|
||||
};
|
||||
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
|
||||
var cellFormats = new CellFormats()
|
||||
{
|
||||
Count = 3U
|
||||
};
|
||||
var cellFormatFont = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true
|
||||
};
|
||||
var cellFormatFontAndBorder = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 1U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true,
|
||||
ApplyBorder = true
|
||||
};
|
||||
var cellFormatTitle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 1U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true,
|
||||
Horizontal = HorizontalAlignmentValues.Center
|
||||
},
|
||||
ApplyFont = true
|
||||
};
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
var cellStyles = new CellStyles() { Count = 1U };
|
||||
cellStyles.Append(new CellStyle()
|
||||
{
|
||||
Name = "Normal",
|
||||
FormatId = 0U,
|
||||
BuiltinId = 0U
|
||||
});
|
||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||
{
|
||||
Count = 0U
|
||||
};
|
||||
|
||||
var tableStyles = new TableStyles()
|
||||
{
|
||||
Count = 0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
var stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||
});
|
||||
var stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||
};
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||
});
|
||||
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfoClerc info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
CreateStyles(workbookpart);
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First() : _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
|
||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
_worksheet = worksheetPart.Worksheet;
|
||||
}
|
||||
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Row row;
|
||||
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
|
||||
Cell cell;
|
||||
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var newCell = new Cell()
|
||||
{
|
||||
CellReference = excelParams.CellReference
|
||||
};
|
||||
row.InsertBefore(newCell, refCell);
|
||||
cell = newCell;
|
||||
}
|
||||
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
var mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(excelParams.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfoClerc info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
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.Implements
|
||||
{
|
||||
public class SaveToExcelHeadwaiter : AbstractSaveToExcelHeadwaiter
|
||||
{
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
|
||||
var borderThin = new Border();
|
||||
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats()
|
||||
{
|
||||
Count = 1U
|
||||
};
|
||||
var cellFormatStyle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U
|
||||
};
|
||||
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
|
||||
var cellFormats = new CellFormats()
|
||||
{
|
||||
Count = 3U
|
||||
};
|
||||
var cellFormatFont = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true
|
||||
};
|
||||
var cellFormatFontAndBorder = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 1U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true,
|
||||
ApplyBorder = true
|
||||
};
|
||||
var cellFormatTitle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 1U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true,
|
||||
Horizontal = HorizontalAlignmentValues.Center
|
||||
},
|
||||
ApplyFont = true
|
||||
};
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
var cellStyles = new CellStyles() { Count = 1U };
|
||||
cellStyles.Append(new CellStyle()
|
||||
{
|
||||
Name = "Normal",
|
||||
FormatId = 0U,
|
||||
BuiltinId = 0U
|
||||
});
|
||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||
{
|
||||
Count = 0U
|
||||
};
|
||||
|
||||
var tableStyles = new TableStyles()
|
||||
{
|
||||
Count = 0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
var stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||
});
|
||||
var stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||
};
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||
});
|
||||
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfoHeadwaiter info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
CreateStyles(workbookpart);
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First() : _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
|
||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
_worksheet = worksheetPart.Worksheet;
|
||||
}
|
||||
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Row row;
|
||||
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
|
||||
Cell cell;
|
||||
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var newCell = new Cell()
|
||||
{
|
||||
CellReference = excelParams.CellReference
|
||||
};
|
||||
row.InsertBefore(newCell, refCell);
|
||||
cell = newCell;
|
||||
}
|
||||
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
var mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(excelParams.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfoHeadwaiter info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfClerc : AbstractSaveToPdfClerc
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfoClerc info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(PdfInfoClerc info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
internal class SaveToPdfHeadwaiter : AbstractSaveToPdfHeadwaiter
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfoHeadwaiter info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(PdfInfoHeadwaiter info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace BankBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWordClerc : AbstractSaveToWordClerc
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
properties.AppendChild(pageSize);
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var properties = new ParagraphProperties();
|
||||
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
properties.AppendChild(new Indentation());
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||
{
|
||||
Val = paragraphProperties.Size
|
||||
});
|
||||
}
|
||||
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text
|
||||
{
|
||||
Text = run.Item1,
|
||||
Space = SpaceProcessingModeValues.Preserve
|
||||
});
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
|
||||
protected override void CreateWord(WordInfoClerc info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
protected override void SaveWord(WordInfoClerc info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
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.Implements
|
||||
{
|
||||
public class SaveToWordHeadwaiter : AbstractSaveToWordHeadwaitre
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
properties.AppendChild(pageSize);
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var properties = new ParagraphProperties();
|
||||
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
properties.AppendChild(new Indentation());
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||
{
|
||||
Val = paragraphProperties.Size
|
||||
});
|
||||
}
|
||||
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text
|
||||
{
|
||||
Text = run.Item1,
|
||||
Space = SpaceProcessingModeValues.Preserve
|
||||
});
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
|
||||
protected override void CreateWord(WordInfoHeadwaiter info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
protected override void SaveWord(WordInfoHeadwaiter info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
17
Bank/BankContracts/BankContracts.csproj
Normal file
17
Bank/BankContracts/BankContracts.csproj
Normal 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" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
19
Bank/BankContracts/BindingModels/ClercBindingModel.cs
Normal file
19
Bank/BankContracts/BindingModels/ClercBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ClercBindingModel : IClercModel
|
||||
{
|
||||
public string OrganiserFIO { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserPassword { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserLogin { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserEmail { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
16
Bank/BankContracts/BindingModels/ConferenceBindingModel.cs
Normal file
16
Bank/BankContracts/BindingModels/ConferenceBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ConferenceBindingModel : IConferenceModel
|
||||
{
|
||||
public string ConferenceName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StartDate { get; set; } = DateTime.Now;
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
public Dictionary<int, IMemberModel> ConferenceMembers { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ConferenceBookingBindingModel : IConferenceBookingModel
|
||||
{
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
public int ConferenceId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; }
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BindingModels/DinnerBindingModel.cs
Normal file
15
Bank/BankContracts/BindingModels/DinnerBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class DinnerBindingModel : IDinnerModel
|
||||
{
|
||||
public string DinnerName { get; set; } = string.Empty;
|
||||
|
||||
public double DinnerPrice { get; set; }
|
||||
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
19
Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs
Normal file
19
Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class HeadwaiterBindingModel : IHeadwaiterModel
|
||||
{
|
||||
public string HeadwaiterFIO { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterPassword { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterLogin { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterEmail { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
16
Bank/BankContracts/BindingModels/MealPlanBindingModel.cs
Normal file
16
Bank/BankContracts/BindingModels/MealPlanBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class MealPlanBindingModel : IMealPlanModel
|
||||
{
|
||||
public string MealPlanName { get; set; } = string.Empty;
|
||||
|
||||
public double MealPlanPrice { get; set; }
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IMemberModel> MealPlanMembers { get; set; }
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BindingModels/MemberBindingModel.cs
Normal file
15
Bank/BankContracts/BindingModels/MemberBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class MemberBindingModel : IMemberModel
|
||||
{
|
||||
public string MemberFIO { get; set; } = string.Empty;
|
||||
|
||||
public string Citizenship { get; set; } = string.Empty;
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
10
Bank/BankContracts/BindingModels/ReportBindingModel.cs
Normal file
10
Bank/BankContracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int OrganiserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ReportHeadwaiterBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int HeadwaiterId { get; set; }
|
||||
}
|
||||
}
|
20
Bank/BankContracts/BindingModels/RoomBindingModel.cs
Normal file
20
Bank/BankContracts/BindingModels/RoomBindingModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using BankDataModels.Models;
|
||||
|
||||
namespace BankContracts.BindingModels
|
||||
{
|
||||
public class RoomBindingModel : IRoomModel
|
||||
{
|
||||
public string RoomName { get; set; } = string.Empty;
|
||||
|
||||
public string RoomFrame { get; set; } = string.Empty;
|
||||
|
||||
public double RoomPrice { get; set; }
|
||||
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
public int MealPlanId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IDinnerModel> RoomDinners { get; set; }
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IClercLogic
|
||||
{
|
||||
List<ClercViewModel>? ReadList(ClercSearchModel? model);
|
||||
ClercViewModel? ReadElement(ClercSearchModel model);
|
||||
bool Create(ClercBindingModel model);
|
||||
bool Update(ClercBindingModel model);
|
||||
bool Delete(ClercBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IConferenceBookingLogic
|
||||
{
|
||||
List<ConferenceBookingViewModel>? ReadList(ConferenceBookingSearchModel? model);
|
||||
ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model);
|
||||
bool Create(ConferenceBookingBindingModel model);
|
||||
bool Update(ConferenceBookingBindingModel model);
|
||||
bool Delete(ConferenceBookingBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IConferenceLogic
|
||||
{
|
||||
List<ConferenceViewModel>? ReadList(ConferenceSearchModel? model);
|
||||
ConferenceViewModel? ReadElement(ConferenceSearchModel model);
|
||||
bool Create(ConferenceBindingModel model);
|
||||
bool Update(ConferenceBindingModel model);
|
||||
bool Delete(ConferenceBindingModel model);
|
||||
}
|
||||
}
|
16
Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs
Normal file
16
Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IDinnerLogic
|
||||
{
|
||||
List<DinnerViewModel>? ReadList(DinnerSearchModel? model);
|
||||
DinnerViewModel? ReadElement(DinnerSearchModel model);
|
||||
bool Create(DinnerBindingModel model);
|
||||
bool Update(DinnerBindingModel model);
|
||||
bool Delete(DinnerBindingModel model);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IHeadwaiterLogic
|
||||
{
|
||||
List<HeadwaiterViewModel>? ReadList(HeadwaiterSearchModel? model);
|
||||
HeadwaiterViewModel? ReadElement(HeadwaiterSearchModel model);
|
||||
bool Create(HeadwaiterBindingModel model);
|
||||
bool Update(HeadwaiterBindingModel model);
|
||||
bool Delete(HeadwaiterBindingModel model);
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMealPlanLogic
|
||||
{
|
||||
List<MealPlanViewModel>? ReadList(MealPlanSearchModel? model);
|
||||
MealPlanViewModel? ReadElement(MealPlanSearchModel model);
|
||||
bool Create(MealPlanBindingModel model);
|
||||
bool Update(MealPlanBindingModel model);
|
||||
bool Delete(MealPlanBindingModel model);
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMemberLogic
|
||||
{
|
||||
List<MemberViewModel>? ReadList(MemberSearchModel? model);
|
||||
MemberViewModel? ReadElement(MemberSearchModel model);
|
||||
bool Create(MemberBindingModel model);
|
||||
bool Update(MemberBindingModel model);
|
||||
bool Delete(MemberBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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 IReportHeadwaiterLogic
|
||||
{
|
||||
List<ReportMealPlanDinnerViewModel> GetMealPlanDinner();
|
||||
List<ReportConferenceBindingRoomsViewModel> GetConferenceBindingRooms(ReportHeadwaiterBindingModel model);
|
||||
void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model);
|
||||
void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model);
|
||||
void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportOrganiserLogic
|
||||
{
|
||||
List<ReportMemberConferenceViewModel> GetMemberConference();
|
||||
List<ReportMembersViewModel> GetMembers(ReportBindingModel model);
|
||||
void SaveMemberConferenceToWordFile(ReportBindingModel model);
|
||||
void SaveMemberConferenceToExcelFile(ReportBindingModel model);
|
||||
void SaveMembersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
15
Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs
Normal file
15
Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IRoomLogic
|
||||
{
|
||||
List<RoomViewModel>? ReadList(RoomSearchModel? model);
|
||||
RoomViewModel? ReadElement(RoomSearchModel model);
|
||||
bool Create(RoomBindingModel model);
|
||||
bool Update(RoomBindingModel model);
|
||||
bool Delete(RoomBindingModel model);
|
||||
}
|
||||
}
|
10
Bank/BankContracts/SearchModels/ClercSearchModel.cs
Normal file
10
Bank/BankContracts/SearchModels/ClercSearchModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class ClercSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? OrganiserFIO { get; set; }
|
||||
public string? OrganiserLogin { get; set; }
|
||||
public string? OrganiserPassword { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class ConferenceBookingSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? HeadwaiterId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
11
Bank/BankContracts/SearchModels/ConferenceSearchModel.cs
Normal file
11
Bank/BankContracts/SearchModels/ConferenceSearchModel.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class ConferenceSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ConferenceName { get; set; }
|
||||
public int? OrganiserId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
9
Bank/BankContracts/SearchModels/DinnerSearchModel.cs
Normal file
9
Bank/BankContracts/SearchModels/DinnerSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class DinnerSearchModel
|
||||
{
|
||||
public string? DinnerName { get; set; }
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
13
Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs
Normal file
13
Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class HeadwaiterSearchModel
|
||||
{
|
||||
public string? HeadwaiterFIO { get; set; }
|
||||
|
||||
public string? HeadwaiterPassword { get; set; }
|
||||
|
||||
public string? HeadwaiterLogin { get; set; }
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
8
Bank/BankContracts/SearchModels/MealPlanSearchModel.cs
Normal file
8
Bank/BankContracts/SearchModels/MealPlanSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class MealPlanSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? MealPlanName { get; set; }
|
||||
}
|
||||
}
|
8
Bank/BankContracts/SearchModels/MemberSearchModel.cs
Normal file
8
Bank/BankContracts/SearchModels/MemberSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class MemberSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? MemberFIO { get; set; }
|
||||
}
|
||||
}
|
9
Bank/BankContracts/SearchModels/RoomSearchModel.cs
Normal file
9
Bank/BankContracts/SearchModels/RoomSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
namespace BankContracts.SearchModels
|
||||
{
|
||||
public class RoomSearchModel
|
||||
{
|
||||
public string? RoomName { get; set; }
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IClercStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IClercStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IClercStorage
|
||||
{
|
||||
List<ClercViewModel> GetFullList();
|
||||
|
||||
List<ClercViewModel> GetFilteredList(ClercSearchModel model);
|
||||
|
||||
ClercViewModel? GetElement(ClercSearchModel model);
|
||||
|
||||
ClercViewModel? Insert(ClercBindingModel model);
|
||||
|
||||
ClercViewModel? Update(ClercBindingModel model);
|
||||
|
||||
ClercViewModel? Delete(ClercBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IConferenceBookingStorage
|
||||
{
|
||||
List<ConferenceBookingViewModel> GetFullList();
|
||||
|
||||
List<ConferenceBookingViewModel> GetFilteredList(ConferenceBookingSearchModel model);
|
||||
|
||||
ConferenceBookingViewModel? GetElement(ConferenceBookingSearchModel model);
|
||||
|
||||
ConferenceBookingViewModel? Insert(ConferenceBookingBindingModel model);
|
||||
|
||||
ConferenceBookingViewModel? Update(ConferenceBookingBindingModel model);
|
||||
|
||||
ConferenceBookingViewModel? Delete(ConferenceBookingBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IConferenceStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IConferenceStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IConferenceStorage
|
||||
{
|
||||
List<ConferenceViewModel> GetFullList();
|
||||
|
||||
List<ConferenceViewModel> GetFilteredList(ConferenceSearchModel model);
|
||||
|
||||
ConferenceViewModel? GetElement(ConferenceSearchModel model);
|
||||
|
||||
ConferenceViewModel? Insert(ConferenceBindingModel model);
|
||||
|
||||
ConferenceViewModel? Update(ConferenceBindingModel model);
|
||||
|
||||
ConferenceViewModel? Delete(ConferenceBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IDinnerStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IDinnerStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IDinnerStorage
|
||||
{
|
||||
List<DinnerViewModel> GetFullList();
|
||||
|
||||
List<DinnerViewModel> GetFilteredList(DinnerSearchModel model);
|
||||
|
||||
DinnerViewModel? GetElement(DinnerSearchModel model);
|
||||
|
||||
DinnerViewModel? Insert(DinnerBindingModel model);
|
||||
|
||||
DinnerViewModel? Update(DinnerBindingModel model);
|
||||
|
||||
DinnerViewModel? Delete(DinnerBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IHeadwaiterStorage
|
||||
{
|
||||
List<HeadwaiterViewModel> GetFullList();
|
||||
|
||||
List<HeadwaiterViewModel> GetFilteredList(HeadwaiterSearchModel model);
|
||||
|
||||
HeadwaiterViewModel? GetElement(HeadwaiterSearchModel model);
|
||||
|
||||
HeadwaiterViewModel? Insert(HeadwaiterBindingModel model);
|
||||
|
||||
HeadwaiterViewModel? Update(HeadwaiterBindingModel model);
|
||||
|
||||
HeadwaiterViewModel? Delete(HeadwaiterBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IMealPlanStorage
|
||||
{
|
||||
List<MealPlanViewModel> GetFullList();
|
||||
|
||||
List<MealPlanViewModel> GetFilteredList(MealPlanSearchModel model);
|
||||
|
||||
MealPlanViewModel? GetElement(MealPlanSearchModel model);
|
||||
|
||||
MealPlanViewModel? Insert(MealPlanBindingModel model);
|
||||
|
||||
MealPlanViewModel? Update(MealPlanBindingModel model);
|
||||
|
||||
MealPlanViewModel? Delete(MealPlanBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IMemberStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IMemberStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IMemberStorage
|
||||
{
|
||||
List<MemberViewModel> GetFullList();
|
||||
|
||||
List<MemberViewModel> GetFilteredList(MemberSearchModel model);
|
||||
|
||||
MemberViewModel? GetElement(MemberSearchModel model);
|
||||
|
||||
MemberViewModel? Insert(MemberBindingModel model);
|
||||
|
||||
MemberViewModel? Update(MemberBindingModel model);
|
||||
|
||||
MemberViewModel? Delete(MemberBindingModel model);
|
||||
}
|
||||
}
|
21
Bank/BankContracts/StoragesContracts/IRoomStorage.cs
Normal file
21
Bank/BankContracts/StoragesContracts/IRoomStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IRoomStorage
|
||||
{
|
||||
List<RoomViewModel> GetFullList();
|
||||
|
||||
List<RoomViewModel> GetFilteredList(RoomSearchModel model);
|
||||
|
||||
RoomViewModel? GetElement(RoomSearchModel model);
|
||||
|
||||
RoomViewModel? Insert(RoomBindingModel model);
|
||||
|
||||
RoomViewModel? Update(RoomBindingModel model);
|
||||
|
||||
RoomViewModel? Delete(RoomBindingModel model);
|
||||
}
|
||||
}
|
25
Bank/BankContracts/ViewModels/ClercViewModel.cs
Normal file
25
Bank/BankContracts/ViewModels/ClercViewModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ClercViewModel : IClercModel
|
||||
{
|
||||
[DisplayName("ФИО организатора")]
|
||||
public string OrganiserFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль организатора")]
|
||||
public string OrganiserPassword { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин организатора")]
|
||||
public string OrganiserLogin { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Эл. почта организатора")]
|
||||
public string OrganiserEmail { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Номер телефона организатора")]
|
||||
public string OrganiserNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
19
Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs
Normal file
19
Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ConferenceBookingViewModel : IConferenceBookingModel
|
||||
{
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
public int ConferenceId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; }
|
||||
}
|
||||
}
|
19
Bank/BankContracts/ViewModels/ConferenceViewModel.cs
Normal file
19
Bank/BankContracts/ViewModels/ConferenceViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ConferenceViewModel : IConferenceModel
|
||||
{
|
||||
[DisplayName("Название конференции")]
|
||||
public string ConferenceName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата начала конференции")]
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IMemberModel> ConferenceMembers { get; set; }
|
||||
}
|
||||
}
|
19
Bank/BankContracts/ViewModels/DinnerViewModel.cs
Normal file
19
Bank/BankContracts/ViewModels/DinnerViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class DinnerViewModel : IDinnerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
[DisplayName("Название обеда")]
|
||||
public string DinnerName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Цена обеда")]
|
||||
public double DinnerPrice { get; set; }
|
||||
}
|
||||
}
|
||||
|
31
Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs
Normal file
31
Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs
Normal file
@ -0,0 +1,31 @@
|
||||
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 HeadwaiterViewModel : IHeadwaiterModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО метрдотеля")]
|
||||
public string HeadwaiterFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль метрдотеля")]
|
||||
public string HeadwaiterPassword { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин метрдотеля")]
|
||||
public string HeadwaiterLogin { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Mail метрдотеля")]
|
||||
public string HeadwaiterEmail { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Телефон метрдотеля")]
|
||||
public string HeadwaiterNumber { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
20
Bank/BankContracts/ViewModels/MealPlanViewModel.cs
Normal file
20
Bank/BankContracts/ViewModels/MealPlanViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class MealPlanViewModel : IMealPlanModel
|
||||
{
|
||||
[DisplayName("Название плана питания")]
|
||||
public string MealPlanName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Цена плана питания")]
|
||||
public double MealPlanPrice { get; set; }
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public Dictionary<int, IMemberModel> MealPlanMembers { get; set; }
|
||||
}
|
||||
}
|
18
Bank/BankContracts/ViewModels/MemberViewModel.cs
Normal file
18
Bank/BankContracts/ViewModels/MemberViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class MemberViewModel : IMemberModel
|
||||
{
|
||||
[DisplayName("ФИО участника")]
|
||||
public string MemberFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Гражданство")]
|
||||
public string Citizenship { get; set; } = string.Empty;
|
||||
|
||||
public int OrganiserId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportConferenceBindingRoomsViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string RoomName { get; set; } = string.Empty;
|
||||
public double RoomPrice { get; set; }
|
||||
public string RoomFrame { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportMealPlanDinnerViewModel
|
||||
{
|
||||
public string DinnerName { get; set; } = string.Empty;
|
||||
public List<Tuple<string, DateTime>> MealPlans { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportMemberConferenceViewModel
|
||||
{
|
||||
public string MemberFIO { get; set; } = string.Empty;
|
||||
public List<Tuple<string, DateTime>> Conferences { get; set; } = new();
|
||||
}
|
||||
}
|
12
Bank/BankContracts/ViewModels/ReportMembersViewModel.cs
Normal file
12
Bank/BankContracts/ViewModels/ReportMembersViewModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportMembersViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public string MemberFIO { get; set; } = string.Empty;
|
||||
public string ConferenceName { get; set; } = string.Empty;
|
||||
public string MealPlanName { get; set; } = string.Empty;
|
||||
public double MealPlanPrice { get; set; }
|
||||
}
|
||||
}
|
26
Bank/BankContracts/ViewModels/RoomViewModel.cs
Normal file
26
Bank/BankContracts/ViewModels/RoomViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
using BankDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class RoomViewModel : IRoomModel
|
||||
{
|
||||
public int HeadwaiterId { get; set; }
|
||||
|
||||
public int MealPlanId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название комнаты")]
|
||||
public string RoomName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Корпус комнаты")]
|
||||
public string RoomFrame { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стоимость комнаты")]
|
||||
public double RoomPrice { get; set; }
|
||||
public Dictionary<int, IDinnerModel> RoomDinners { get; set; }
|
||||
|
||||
}
|
||||
}
|
31
Bank/BankDataBaseImplement/BankDataBase.cs
Normal file
31
Bank/BankDataBaseImplement/BankDataBase.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using BankDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BankDataBaseImplement
|
||||
{
|
||||
public class BankDataBase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-VG5USAH\SQLEXPRESS;Initial Catalog=HotelDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Conference> Conferences { set; get; }
|
||||
public virtual DbSet<Room> Rooms { set; get; }
|
||||
public virtual DbSet<MealPlan> MealPlans { set; get; }
|
||||
public virtual DbSet<ConferenceBooking> ConferenceBookings { set; get; }
|
||||
public virtual DbSet<Member> Members { set; get; }
|
||||
public virtual DbSet<Dinner> Dinners { set; get; }
|
||||
public virtual DbSet<Clerc> Organisers { set; get; }
|
||||
public virtual DbSet<Headwaiter> Headwaiters { set; get; }
|
||||
public virtual DbSet<ConferenceMember> ConferenceMembers { set; get; }
|
||||
public virtual DbSet<RoomDinner> RoomDinners { set; get; }
|
||||
public virtual DbSet<MealPlanMember> MealPlanMembers { set; get; }
|
||||
public virtual DbSet<ConferenceBookingDinner> ConferenceBookingDinners { set; get; }
|
||||
|
||||
}
|
||||
}
|
22
Bank/BankDataBaseImplement/BankDataBaseImplement.csproj
Normal file
22
Bank/BankDataBaseImplement/BankDataBaseImplement.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<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.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BancContracts\BankContracts.csproj" />
|
||||
<ProjectReference Include="..\BankContracts\BankContracts.csproj" />
|
||||
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
|
||||
<ProjectReference Include="..\BankView\BankView.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
164
Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs
Normal file
164
Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs
Normal file
@ -0,0 +1,164 @@
|
||||
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.Implemets
|
||||
{
|
||||
public class ConferenceBookingStorage : IConferenceBookingStorage
|
||||
{
|
||||
public ConferenceBookingViewModel? Delete(ConferenceBookingBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.ConferenceBookings
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.ConferenceBookings.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConferenceBookingViewModel? GetElement(ConferenceBookingSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ConferenceBookingViewModel> GetFilteredList(ConferenceBookingSearchModel model)
|
||||
{
|
||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.HeadwaiterId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.Conference.StartDate >= model.DateFrom && x.Conference.StartDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.HeadwaiterId.HasValue)
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.HeadwaiterId == model.HeadwaiterId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ConferenceBookingViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ConferenceBookingViewModel? Insert(ConferenceBookingBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var newConferenceBooking = ConferenceBooking.Create(context, model);
|
||||
|
||||
if (newConferenceBooking == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.ConferenceBookings.Add(newConferenceBooking);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => x.Id == newConferenceBooking.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
|
||||
public ConferenceBookingViewModel? Update(ConferenceBookingBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var conferenceBooking = context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (conferenceBooking == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
conferenceBooking.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return conferenceBooking.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
159
Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs
Normal file
159
Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
public class ConferenceStorage : IConferenceStorage
|
||||
{
|
||||
public ConferenceViewModel? Delete(ConferenceBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Conferences
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Conferences.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConferenceViewModel? GetElement(ConferenceSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ConferenceViewModel> GetFilteredList(ConferenceSearchModel model)
|
||||
{
|
||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.OrganiserId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.StartDate >= model.DateFrom && x.StartDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.OrganiserId.HasValue)
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.OrganiserId == model.OrganiserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ConferenceViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ConferenceViewModel? Insert(ConferenceBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var newConference = Conference.Create(context,model);
|
||||
|
||||
if (newConference == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Conferences.Add(newConference);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.FirstOrDefault(x => x.Id == newConference.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
|
||||
public ConferenceViewModel? Update(ConferenceBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var conference = context.Conferences
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Organiser)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (conference == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
conference.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return conference.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
120
Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs
Normal file
120
Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs
Normal 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.Implemets
|
||||
{
|
||||
public class DinnerStorage : IDinnerStorage
|
||||
{
|
||||
public DinnerViewModel? Delete(DinnerBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Dinners.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Dinners.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public DinnerViewModel? GetElement(DinnerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DinnerName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Dinners
|
||||
.Include(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DinnerName) && x.DinnerName == model.DinnerName) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<DinnerViewModel> GetFilteredList(DinnerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DinnerName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Dinners
|
||||
.Include(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.Where(x => x.DinnerName.Contains(model.DinnerName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<DinnerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Dinners
|
||||
.Include(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public DinnerViewModel? Insert(DinnerBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var newDinner = Dinner.Create(model);
|
||||
|
||||
if (newDinner == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Dinners.Add(newDinner);
|
||||
context.SaveChanges();
|
||||
|
||||
return newDinner.GetViewModel;
|
||||
}
|
||||
|
||||
public DinnerViewModel? Update(DinnerBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var dinner = context.Dinners.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (dinner == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
dinner.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return dinner.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
127
Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs
Normal file
127
Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs
Normal file
@ -0,0 +1,127 @@
|
||||
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.Implemets
|
||||
{
|
||||
public class HeadwaiterStorage : IHeadwaiterStorage
|
||||
{
|
||||
public HeadwaiterViewModel? Delete(HeadwaiterBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Headwaiters.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Headwaiters.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public HeadwaiterViewModel? GetElement(HeadwaiterSearchModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Headwaiters
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.HeadwaiterLogin) && !string.IsNullOrEmpty(model.HeadwaiterPassword))
|
||||
return context.Headwaiters
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin) && x.HeadwaiterPassword.Equals(model.HeadwaiterPassword))?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.HeadwaiterLogin))
|
||||
return context.Headwaiters
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<HeadwaiterViewModel> GetFilteredList(HeadwaiterSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Headwaiters
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.Where(x => x.HeadwaiterLogin.Contains(model.HeadwaiterLogin) && x.HeadwaiterPassword == model.HeadwaiterPassword)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<HeadwaiterViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Headwaiters
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public HeadwaiterViewModel? Insert(HeadwaiterBindingModel model)
|
||||
{
|
||||
var newHeadwaiter = Headwaiter.Create(model);
|
||||
|
||||
if (newHeadwaiter == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
context.Headwaiters.Add(newHeadwaiter);
|
||||
context.SaveChanges();
|
||||
|
||||
return newHeadwaiter.GetViewModel;
|
||||
}
|
||||
|
||||
public HeadwaiterViewModel? Update(HeadwaiterBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var headwaiter = context.Headwaiters
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (headwaiter == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
headwaiter.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return headwaiter.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
113
Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs
Normal file
113
Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
public class MealPlanStorage : IMealPlanStorage
|
||||
{
|
||||
public MealPlanViewModel? Delete(MealPlanBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.MealPlans
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.MealPlans.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MealPlanViewModel? GetElement(MealPlanSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.MealPlans
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.Rooms)
|
||||
.Include(x => x.Organiser)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<MealPlanViewModel> GetFilteredList(MealPlanSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MealPlanName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.MealPlans
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.Rooms)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.MealPlanName.Contains(model.MealPlanName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<MealPlanViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
return context.MealPlans
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.Rooms)
|
||||
.Include(x => x.Organiser)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public MealPlanViewModel? Insert(MealPlanBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var newMealPlan = MealPlan.Create(context,model);
|
||||
|
||||
if (newMealPlan == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.MealPlans.Add(newMealPlan);
|
||||
context.SaveChanges();
|
||||
return newMealPlan.GetViewModel;
|
||||
}
|
||||
|
||||
public MealPlanViewModel? Update(MealPlanBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var mealPlan = context.MealPlans.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (mealPlan == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
mealPlan.Update(model);
|
||||
context.SaveChanges();
|
||||
return mealPlan.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
118
Bank/BankDataBaseImplement/Implemets/MemberStorage.cs
Normal file
118
Bank/BankDataBaseImplement/Implemets/MemberStorage.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
public class MemberStorage : IMemberStorage
|
||||
{
|
||||
public MemberViewModel? Delete(MemberBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Members.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Members.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MemberViewModel? GetElement(MemberSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MemberFIO) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Members
|
||||
.Include(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.Organiser)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.MemberFIO) && x.MemberFIO == model.MemberFIO) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<MemberViewModel> GetFilteredList(MemberSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MemberFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Members
|
||||
.Include(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.MemberFIO.Contains(model.MemberFIO))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<MemberViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Members
|
||||
.Include(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.MealPlanMember)
|
||||
.ThenInclude(x => x.MealPlan)
|
||||
.Include(x => x.Organiser)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public MemberViewModel? Insert(MemberBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var newMember = Member.Create(model);
|
||||
|
||||
if (newMember == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Members.Add(newMember);
|
||||
context.SaveChanges();
|
||||
|
||||
return newMember.GetViewModel;
|
||||
}
|
||||
|
||||
public MemberViewModel? Update(MemberBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var member = context.Members.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (member == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
member.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return member.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
122
Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs
Normal file
122
Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
public class OrganiserStorage : IClercStorage
|
||||
{
|
||||
public ClercViewModel? Delete(ClercBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Organisers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Organisers.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ClercViewModel? GetElement(ClercSearchModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.OrganiserLogin) && !string.IsNullOrEmpty(model.OrganiserPassword))
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin) && x.OrganiserPassword.Equals(model.OrganiserPassword))?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.OrganiserLogin))
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ClercViewModel> GetFilteredList(ClercSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.OrganiserFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.Where(x => x.OrganiserLogin.Contains(model.OrganiserLogin) && x.OrganiserPassword == model.OrganiserPassword)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ClercViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Organisers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ClercViewModel? Insert(ClercBindingModel model)
|
||||
{
|
||||
var newOrganiser = Clerc.Create(model);
|
||||
|
||||
if (newOrganiser == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
context.Organisers.Add(newOrganiser);
|
||||
context.SaveChanges();
|
||||
|
||||
return newOrganiser.GetViewModel;
|
||||
}
|
||||
|
||||
public ClercViewModel? Update(ClercBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var organiser = context.Organisers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (organiser == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
organiser.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return organiser.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
118
Bank/BankDataBaseImplement/Implemets/RoomStorage.cs
Normal file
118
Bank/BankDataBaseImplement/Implemets/RoomStorage.cs
Normal file
@ -0,0 +1,118 @@
|
||||
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.Implemets
|
||||
{
|
||||
public class RoomStorage : IRoomStorage
|
||||
{
|
||||
public RoomViewModel? Delete(RoomBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Rooms
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Rooms.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RoomViewModel? GetElement(RoomSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Rooms
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.Include(x => x.MealPlan)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<RoomViewModel> GetFilteredList(RoomSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.RoomName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Rooms
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.Include(x => x.MealPlan)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.RoomName.Contains(model.RoomName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RoomViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
return context.Rooms
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.ConferenceBookingDinners)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.Include(x => x.MealPlan)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RoomViewModel? Insert(RoomBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var newRoom = Room.Create(context, model);
|
||||
|
||||
if (newRoom == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Rooms.Add(newRoom);
|
||||
context.SaveChanges();
|
||||
return newRoom.GetViewModel;
|
||||
}
|
||||
|
||||
public RoomViewModel? Update(RoomBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var room = context.Rooms.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (room == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
room.Update(model);
|
||||
context.SaveChanges();
|
||||
return room.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
569
Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs
generated
Normal file
569
Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,569 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDataBase))]
|
||||
[Migration("20230405210621_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ConferenceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Conferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("ConferenceBookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceBookingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnercId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceBookingId");
|
||||
|
||||
b.HasIndex("DinnercId");
|
||||
|
||||
b.ToTable("ConferenceBookingDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("ConferenceMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DinnerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("DinnetPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("HeadwaiterEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Headwaiters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MealPlanName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("MealPlanPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("MealPlans");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("MealPlanMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Citizenship")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("OrganiserEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Organisers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RoomFrame")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RoomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RoomPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DinnerId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Conferences")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("ConferenceBookingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("ConferenceBookingDinners")
|
||||
.HasForeignKey("DinnercId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConferenceBooking");
|
||||
|
||||
b.Navigation("Dinner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("ConferenceMember")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiters")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Headwaiters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("MealPlans")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("MealPlanMember")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("RoomDinners")
|
||||
.HasForeignKey("DinnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dinner");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookingDinners");
|
||||
|
||||
b.Navigation("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Dinners");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Navigation("ConferenceMember");
|
||||
|
||||
b.Navigation("MealPlanMember");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Navigation("Conferences");
|
||||
|
||||
b.Navigation("MealPlans");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,415 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BankDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Headwaiters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
HeadwaiterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
HeadwaiterEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
HeadwaiterPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
HeadwaiterLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
HeadwaiterNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Headwaiters", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organisers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
OrganiserFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrganiserPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrganiserLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrganiserEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrganiserNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organisers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Dinners",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
|
||||
DinnerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DinnetPrice = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Dinners", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Dinners_Headwaiters_HeadwaiterId",
|
||||
column: x => x.HeadwaiterId,
|
||||
principalTable: "Headwaiters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Conferences",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ConferenceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
OrganiserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Conferences", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Conferences_Organisers_OrganiserId",
|
||||
column: x => x.OrganiserId,
|
||||
principalTable: "Organisers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MealPlans",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MealPlanName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MealPlanPrice = table.Column<double>(type: "float", nullable: false),
|
||||
OrganiserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MealPlans", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MealPlans_Organisers_OrganiserId",
|
||||
column: x => x.OrganiserId,
|
||||
principalTable: "Organisers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Members",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MemberFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Citizenship = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrganiserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Members", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Members_Organisers_OrganiserId",
|
||||
column: x => x.OrganiserId,
|
||||
principalTable: "Organisers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConferenceBookings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
|
||||
ConferenceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConferenceBookings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceBookings_Conferences_ConferenceId",
|
||||
column: x => x.ConferenceId,
|
||||
principalTable: "Conferences",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceBookings_Headwaiters_HeadwaiterId",
|
||||
column: x => x.HeadwaiterId,
|
||||
principalTable: "Headwaiters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Rooms",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RoomName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
RoomFrame = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
RoomPrice = table.Column<double>(type: "float", nullable: false),
|
||||
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
|
||||
MealPlanId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Rooms", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Rooms_Headwaiters_HeadwaiterId",
|
||||
column: x => x.HeadwaiterId,
|
||||
principalTable: "Headwaiters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Rooms_MealPlans_MealPlanId",
|
||||
column: x => x.MealPlanId,
|
||||
principalTable: "MealPlans",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConferenceMembers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MemberId = table.Column<int>(type: "int", nullable: false),
|
||||
ConferenceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConferenceMembers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceMembers_Conferences_ConferenceId",
|
||||
column: x => x.ConferenceId,
|
||||
principalTable: "Conferences",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceMembers_Members_MemberId",
|
||||
column: x => x.MemberId,
|
||||
principalTable: "Members",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MealPlanMembers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MemberId = table.Column<int>(type: "int", nullable: false),
|
||||
MealPlanId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MealPlanMembers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MealPlanMembers_MealPlans_MealPlanId",
|
||||
column: x => x.MealPlanId,
|
||||
principalTable: "MealPlans",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_MealPlanMembers_Members_MemberId",
|
||||
column: x => x.MemberId,
|
||||
principalTable: "Members",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConferenceBookingDinners",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ConferenceBookingId = table.Column<int>(type: "int", nullable: false),
|
||||
DinnerId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
DinnercId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId",
|
||||
column: x => x.ConferenceBookingId,
|
||||
principalTable: "ConferenceBookings",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_Dinners_DinnercId",
|
||||
column: x => x.DinnercId,
|
||||
principalTable: "Dinners",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RoomDinners",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RoomId = table.Column<int>(type: "int", nullable: false),
|
||||
DinnerId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RoomDinners", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RoomDinners_Dinners_DinnerId",
|
||||
column: x => x.DinnerId,
|
||||
principalTable: "Dinners",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RoomDinners_Rooms_RoomId",
|
||||
column: x => x.RoomId,
|
||||
principalTable: "Rooms",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookingDinners_ConferenceBookingId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "ConferenceBookingId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookingDinners_DinnercId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "DinnercId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookings_ConferenceId",
|
||||
table: "ConferenceBookings",
|
||||
column: "ConferenceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookings_HeadwaiterId",
|
||||
table: "ConferenceBookings",
|
||||
column: "HeadwaiterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceMembers_ConferenceId",
|
||||
table: "ConferenceMembers",
|
||||
column: "ConferenceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceMembers_MemberId",
|
||||
table: "ConferenceMembers",
|
||||
column: "MemberId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Conferences_OrganiserId",
|
||||
table: "Conferences",
|
||||
column: "OrganiserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Dinners_HeadwaiterId",
|
||||
table: "Dinners",
|
||||
column: "HeadwaiterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MealPlanMembers_MealPlanId",
|
||||
table: "MealPlanMembers",
|
||||
column: "MealPlanId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MealPlanMembers_MemberId",
|
||||
table: "MealPlanMembers",
|
||||
column: "MemberId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MealPlans_OrganiserId",
|
||||
table: "MealPlans",
|
||||
column: "OrganiserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Members_OrganiserId",
|
||||
table: "Members",
|
||||
column: "OrganiserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RoomDinners_DinnerId",
|
||||
table: "RoomDinners",
|
||||
column: "DinnerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RoomDinners_RoomId",
|
||||
table: "RoomDinners",
|
||||
column: "RoomId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Rooms_HeadwaiterId",
|
||||
table: "Rooms",
|
||||
column: "HeadwaiterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Rooms_MealPlanId",
|
||||
table: "Rooms",
|
||||
column: "MealPlanId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConferenceMembers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MealPlanMembers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RoomDinners");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConferenceBookings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Members");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Dinners");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Rooms");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Conferences");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Headwaiters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MealPlans");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organisers");
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user