Слияние
This commit is contained in:
parent
03944d150b
commit
e78b2309d2
59
JurassicZoo/JurassicZoo.sln
Normal file
59
JurassicZoo/JurassicZoo.sln
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JurassicZoo", "JurassicZoo\JurassicZoo.csproj", "{6BEB62C6-55C0-4A87-A29C-FA47E9AF3F9A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZooBusinessLogic", "ZooBusinessLogic\ZooBusinessLogic.csproj", "{039AC9DE-F7CE-419F-8285-F464FBD2E6D7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{71985B4A-E333-4553-A5F4-697AD9A52214} = {71985B4A-E333-4553-A5F4-697AD9A52214}
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12} = {7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZooContracts", "ZooContracts\ZooContracts.csproj", "{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{51227D08-FB94-4864-93D0-2CA9E5F9E64B} = {51227D08-FB94-4864-93D0-2CA9E5F9E64B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZooDatabaseImplements", "ZooDatabaseImplements\ZooDatabaseImplements.csproj", "{71985B4A-E333-4553-A5F4-697AD9A52214}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12} = {7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZooDataModels", "ZooDataModels\ZooDataModels.csproj", "{51227D08-FB94-4864-93D0-2CA9E5F9E64B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6BEB62C6-55C0-4A87-A29C-FA47E9AF3F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6BEB62C6-55C0-4A87-A29C-FA47E9AF3F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6BEB62C6-55C0-4A87-A29C-FA47E9AF3F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6BEB62C6-55C0-4A87-A29C-FA47E9AF3F9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{039AC9DE-F7CE-419F-8285-F464FBD2E6D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{039AC9DE-F7CE-419F-8285-F464FBD2E6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{039AC9DE-F7CE-419F-8285-F464FBD2E6D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{039AC9DE-F7CE-419F-8285-F464FBD2E6D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7DA51D9D-D23D-4A43-BF92-E7ADE28A8F12}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71985B4A-E333-4553-A5F4-697AD9A52214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71985B4A-E333-4553-A5F4-697AD9A52214}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71985B4A-E333-4553-A5F4-697AD9A52214}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71985B4A-E333-4553-A5F4-697AD9A52214}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{51227D08-FB94-4864-93D0-2CA9E5F9E64B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{51227D08-FB94-4864-93D0-2CA9E5F9E64B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{51227D08-FB94-4864-93D0-2CA9E5F9E64B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{51227D08-FB94-4864-93D0-2CA9E5F9E64B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {00BB5CC0-10EA-448E-9161-DF4DB5C6D1FC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
9
JurassicZoo/JurassicZoo/JurassicZoo.csproj
Normal file
9
JurassicZoo/JurassicZoo/JurassicZoo.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
8
JurassicZoo/ReportLogic.cs
Normal file
8
JurassicZoo/ReportLogic.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
151
JurassicZoo/ZooBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
151
JurassicZoo/ZooBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,151 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _clientStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientEmail))
|
||||
{
|
||||
_logger.LogWarning("Email is empty");
|
||||
throw new ArgumentException("Не введён email");
|
||||
}
|
||||
if (model.ClientEmail.Length > 35)
|
||||
{
|
||||
_logger.LogWarning("Email {Email} length > 35", model.ClientEmail);
|
||||
throw new ArgumentException("Длина email не должна превышать 35 символов");
|
||||
}
|
||||
var existingClient = _clientStorage.GetElement(new()
|
||||
{
|
||||
ClientEmail = model.ClientEmail
|
||||
});
|
||||
if (existingClient != null)
|
||||
{
|
||||
_logger.LogWarning("Client with email {Email} already exists", model.ClientEmail);
|
||||
throw new ArgumentException("Клиент с таким email уже существует");
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientPassword))
|
||||
{
|
||||
_logger.LogWarning("Password is empty");
|
||||
throw new ArgumentException("Не введён пароль");
|
||||
}
|
||||
if (model.ClientPassword.Length < 7 || model.ClientPassword.Length > 30)
|
||||
{
|
||||
_logger.LogWarning("Password {Password} length > 30 or < 7", model.ClientPassword);
|
||||
throw new ArgumentException("Длина пароля должна быть в промежутке между 7 и 30 символами");
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientName))
|
||||
{
|
||||
_logger.LogWarning("Name is empty");
|
||||
throw new ArgumentException("Не введёно имя");
|
||||
}
|
||||
if (model.ClientName.Length > 30)
|
||||
{
|
||||
_logger.LogWarning("Name {Name} length > 30", model.ClientName);
|
||||
throw new ArgumentException("Длина имени не должна превышать 30 символов");
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientPhone))
|
||||
{
|
||||
_logger.LogWarning("Phone is empty");
|
||||
throw new ArgumentException("Не введён телефон");
|
||||
}
|
||||
if (model.ClientPhone.Length == 11)
|
||||
{
|
||||
_logger.LogWarning("Phone {Phone} length == 11", model.ClientPhone);
|
||||
throw new ArgumentException("Длина телефона должна быть 11 символов");
|
||||
}
|
||||
_logger.LogInformation("Client. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
102
JurassicZoo/ZooBusinessLogic/BusinessLogics/CostLogic.cs
Normal file
102
JurassicZoo/ZooBusinessLogic/BusinessLogics/CostLogic.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CostLogic : ICostLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICostStorage _CostStorage;
|
||||
public CostLogic(ILogger<RouteCostLogic> logger, ICostStorage CostStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_CostStorage = CostStorage;
|
||||
}
|
||||
|
||||
public bool Create(CostBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_CostStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(CostBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_CostStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CostViewModel? ReadElement(CostSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _CostStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<CostViewModel>? ReadList(CostSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _CostStorage.GetFullList() : _CostStorage.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(CostBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_CostStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(CostBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Cost. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
101
JurassicZoo/ZooBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
101
JurassicZoo/ZooBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
public bool Create(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_employeeStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_employeeStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? ReadElement(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _employeeStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _employeeStorage.GetFullList() : _employeeStorage.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(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_employeeStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(EmployeeBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Employee. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
63
JurassicZoo/ZooBusinessLogic/BusinessLogics/PaymentLogic.cs
Normal file
63
JurassicZoo/ZooBusinessLogic/BusinessLogics/PaymentLogic.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class PaymentLogic : IPaymentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPaymentStorage _paymentStorage;
|
||||
public PaymentLogic(ILogger<PaymentLogic> logger, IPaymentStorage paymentStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_paymentStorage = paymentStorage;
|
||||
}
|
||||
public bool Create(PaymentBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Delete(PaymentBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PaymentViewModel? ReadElement(PaymentSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<PaymentViewModel>? ReadList(PaymentSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(PaymentBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
private void CheckModel(ReserveBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Reserve. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
46
JurassicZoo/ZooBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
46
JurassicZoo/ZooBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IRouteStorage _RouteStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ReportLogic(ILogger _logger, IRouteStorage RouteStorage)
|
||||
{
|
||||
//_logger = logger;
|
||||
_RouteStorage = RouteStorage;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка кружков с указанием списка затрат по ним за определенное время
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ReportRouteReservesViewModel> GetReserveRoutes(ReportBindingModel model)
|
||||
{
|
||||
return _RouteStorage.GetReserveRoutes(new() { SelectedRoutesIds = model.SelectedRoutes });
|
||||
}
|
||||
|
||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
internal class ReportReserveLogic
|
||||
{
|
||||
}
|
||||
}
|
101
JurassicZoo/ZooBusinessLogic/BusinessLogics/ReserveLogic.cs
Normal file
101
JurassicZoo/ZooBusinessLogic/BusinessLogics/ReserveLogic.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReserveLogic : IReserveLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReserveStorage _ReserveStorage;
|
||||
public ReserveLogic(ILogger<ReserveLogic> logger, IReserveStorage ReserveStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_ReserveStorage = ReserveStorage;
|
||||
}
|
||||
public bool Create(ReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ReserveStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_ReserveStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ReserveViewModel? ReadElement(ReserveSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _ReserveStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ReserveViewModel>? ReadList(ReserveSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _ReserveStorage.GetFullList() : _ReserveStorage.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(ReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ReserveStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ReserveBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Reserve. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
103
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteCostLogic.cs
Normal file
103
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteCostLogic.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class RouteCostLogic : IRouteCostLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouteCostStorage _RouteCostStorage;
|
||||
public RouteCostLogic(ILogger<RouteCostLogic> logger, IRouteCostStorage RouteCostStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_RouteCostStorage = RouteCostStorage;
|
||||
}
|
||||
|
||||
public bool Create(RouteCostBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteCostStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(RouteCostBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_RouteCostStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public RouteCostViewModel? ReadElement(RouteCostSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _RouteCostStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<RouteCostViewModel>? ReadList(RouteCostSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _RouteCostStorage.GetFullList() : _RouteCostStorage.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(RouteCostBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteCostStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(RouteCostBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("RouteCost. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
103
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteLogic.cs
Normal file
103
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteLogic.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class RouteLogic : IRouteLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouteStorage _RouteStorage;
|
||||
public RouteLogic(ILogger<RouteLogic> logger, IRouteStorage RouteStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_RouteStorage = RouteStorage;
|
||||
}
|
||||
|
||||
public bool Create(RouteBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(RouteBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_RouteStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public RouteViewModel? ReadElement(RouteSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _RouteStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<RouteViewModel>? ReadList(RouteSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _RouteStorage.GetFullList() : _RouteStorage.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(RouteBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(RouteBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Route. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
102
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteReserveLogic.cs
Normal file
102
JurassicZoo/ZooBusinessLogic/BusinessLogics/RouteReserveLogic.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements.Implements;
|
||||
|
||||
namespace ZooBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class RouteReserveLogic : IRouteReserveLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouteReserveStorage _RouteReserveStorage;
|
||||
public RouteReserveLogic(ILogger<RouteReserveLogic> logger, IRouteReserveStorage RouteReserveStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_RouteReserveStorage = RouteReserveStorage;
|
||||
}
|
||||
|
||||
public bool Create(RouteReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteReserveStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(RouteReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_RouteReserveStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public RouteReserveViewModel? ReadElement(RouteReserveSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _RouteReserveStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<RouteReserveViewModel>? ReadList(RouteReserveSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _RouteReserveStorage.GetFullList() : _RouteReserveStorage.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(RouteReserveBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RouteReserveStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(RouteReserveBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("RouteReserve. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
18
JurassicZoo/ZooBusinessLogic/ZooBusinessLogic.csproj
Normal file
18
JurassicZoo/ZooBusinessLogic/ZooBusinessLogic.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZooContracts\ZooContracts.csproj" />
|
||||
<ProjectReference Include="..\ZooDatabaseImplements\ZooDatabaseImplements.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
18
JurassicZoo/ZooContracts/BindingModels/ClientBindingModel.cs
Normal file
18
JurassicZoo/ZooContracts/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
public string ClientPhone { get; set; } = string.Empty;
|
||||
public string ClientPassword { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
16
JurassicZoo/ZooContracts/BindingModels/CostBindingModel.cs
Normal file
16
JurassicZoo/ZooContracts/BindingModels/CostBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class CostBindingModel : ICostModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public string CostName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
public string EmployeePassword { get; set; } = string.Empty;
|
||||
public string EmployeeEmail { get; set; } = string.Empty;
|
||||
public string EmployeePhone { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class PaymentBindingModel: IPaymentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public double PaySum { get; set; }
|
||||
public DateTime? DateOfPayment { get; set; } = DateTime.Now;
|
||||
public int RouteReserveId { get; set; }
|
||||
}
|
||||
}
|
25
JurassicZoo/ZooContracts/BindingModels/ReportBindingModel.cs
Normal file
25
JurassicZoo/ZooContracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Выбранные маршруты для отчета
|
||||
/// </summary>
|
||||
public List<int>? SelectedCircles { get; set; }
|
||||
/// <summary>
|
||||
/// Начало периода для отчета по затратам
|
||||
/// </summary>
|
||||
public DateTime? DateFrom { get; set; }
|
||||
/// <summary>
|
||||
/// Конец периода для отчета по затратам
|
||||
/// </summary>
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class ReserveBindingModel : IReserveModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ReserveName { get; set; }
|
||||
public double ReservePrice { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
18
JurassicZoo/ZooContracts/BindingModels/RouteBindingModel.cs
Normal file
18
JurassicZoo/ZooContracts/BindingModels/RouteBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class RouteBindingModel : IRouteModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime DateStart { get; set; } = DateTime.Now;
|
||||
public int ClientId { get; set; }
|
||||
public int ReserveId { get; set; }
|
||||
public double Remains { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class RouteCostBindingModel : IRouteCostModel
|
||||
{
|
||||
public int RouteId { get; set; }
|
||||
|
||||
public int CostId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BindingModels
|
||||
{
|
||||
public class RouteReserveBindingModel : IRouteReserveModel
|
||||
{
|
||||
public int RouteId { get; set; }
|
||||
|
||||
public int ReserveId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
bool Create(ClientBindingModel model);
|
||||
bool Update(ClientBindingModel model);
|
||||
bool Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICostLogic
|
||||
{
|
||||
List<CostViewModel>? ReadList(CostSearchModel? model);
|
||||
CostViewModel? ReadElement(CostSearchModel model);
|
||||
bool Create(CostBindingModel model);
|
||||
bool Update(CostBindingModel model);
|
||||
bool Delete(CostBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model);
|
||||
EmployeeViewModel? ReadElement(EmployeeSearchModel model);
|
||||
bool Create(EmployeeBindingModel model);
|
||||
bool Update(EmployeeBindingModel model);
|
||||
bool Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IPaymentLogic
|
||||
{
|
||||
List<PaymentViewModel>? ReadList(PaymentSearchModel? model);
|
||||
PaymentViewModel? ReadElement(PaymentSearchModel model);
|
||||
bool Create(PaymentBindingModel model);
|
||||
bool Update(PaymentBindingModel model);
|
||||
bool Delete(PaymentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение списка Маршрутов по заповедникам
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportRouteReservesViewModel> GetReserveRoutes(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение компонент в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveComponentsToWordFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveComponentToExcelFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportReservesLogic
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReserveLogic
|
||||
{
|
||||
List<ReserveViewModel>? ReadList(ReserveSearchModel? model);
|
||||
ReserveViewModel? ReadElement(ReserveSearchModel model);
|
||||
bool Create(ReserveBindingModel model);
|
||||
bool Update(ReserveBindingModel model);
|
||||
bool Delete(ReserveBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IRouteCostLogic
|
||||
{
|
||||
List<RouteCostViewModel>? ReadList(RouteCostSearchModel? model);
|
||||
RouteCostViewModel? ReadElement(RouteCostSearchModel model);
|
||||
bool Create(RouteCostBindingModel model);
|
||||
bool Update(RouteCostBindingModel model);
|
||||
bool Delete(RouteCostBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IRouteLogic
|
||||
{
|
||||
List<RouteViewModel>? ReadList(RouteSearchModel? model);
|
||||
RouteViewModel? ReadElement(RouteSearchModel model);
|
||||
bool Create(RouteBindingModel model);
|
||||
bool Update(RouteBindingModel model);
|
||||
bool Delete(RouteBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IRouteReserveLogic
|
||||
{
|
||||
List<RouteReserveViewModel>? ReadList(RouteReserveSearchModel? model);
|
||||
RouteReserveViewModel? ReadElement(RouteReserveSearchModel model);
|
||||
bool Create(RouteReserveBindingModel model);
|
||||
bool Update(RouteReserveBindingModel model);
|
||||
bool Delete(RouteReserveBindingModel model);
|
||||
}
|
||||
}
|
12
JurassicZoo/ZooContracts/Properties/launchSettings.json
Normal file
12
JurassicZoo/ZooContracts/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"ZooContracts": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53043;http://localhost:53045"
|
||||
}
|
||||
}
|
||||
}
|
15
JurassicZoo/ZooContracts/SearchModel/ClientSearchModel.cs
Normal file
15
JurassicZoo/ZooContracts/SearchModel/ClientSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ClientEmail { get; set; }
|
||||
public string? ClientPassword { get; set; }
|
||||
}
|
||||
}
|
16
JurassicZoo/ZooContracts/SearchModel/CostSearchModel.cs
Normal file
16
JurassicZoo/ZooContracts/SearchModel/CostSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class CostSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string CostName { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
}
|
||||
}
|
15
JurassicZoo/ZooContracts/SearchModel/EmployeeSearchModel.cs
Normal file
15
JurassicZoo/ZooContracts/SearchModel/EmployeeSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class EmployeeSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? EmployeeName { get; set; }
|
||||
public int? EmployeePassword { get; set; }
|
||||
}
|
||||
}
|
14
JurassicZoo/ZooContracts/SearchModel/PaymentSearchModel.cs
Normal file
14
JurassicZoo/ZooContracts/SearchModel/PaymentSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class PaymentSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? RouteReserveId { get; set; }
|
||||
}
|
||||
}
|
14
JurassicZoo/ZooContracts/SearchModel/ReserveSearchModel.cs
Normal file
14
JurassicZoo/ZooContracts/SearchModel/ReserveSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class ReserveSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ReserveName { get; set; }
|
||||
}
|
||||
}
|
13
JurassicZoo/ZooContracts/SearchModel/RouteCostSearchModel.cs
Normal file
13
JurassicZoo/ZooContracts/SearchModel/RouteCostSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class RouteCostSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class RouteReserveSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooContracts/SearchModel/RouteSearchModel.cs
Normal file
20
JurassicZoo/ZooContracts/SearchModel/RouteSearchModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.SearchModel
|
||||
{
|
||||
public class RouteSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
/// <summary>
|
||||
/// Id выбранных маршрутов
|
||||
/// </summary>
|
||||
public List<int>? SelectedRoutesIds { get; set; }
|
||||
}
|
||||
}
|
21
JurassicZoo/ZooContracts/StoragesContracts/IClientStorage.cs
Normal file
21
JurassicZoo/ZooContracts/StoragesContracts/IClientStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
21
JurassicZoo/ZooContracts/StoragesContracts/ICostStorage.cs
Normal file
21
JurassicZoo/ZooContracts/StoragesContracts/ICostStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface ICostStorage
|
||||
{
|
||||
List<CostViewModel> GetFullList();
|
||||
List<CostViewModel> GetFilteredList(CostSearchModel model);
|
||||
CostViewModel GetElement(CostSearchModel model);
|
||||
CostViewModel? Insert(CostBindingModel model);
|
||||
CostViewModel? Update(CostBindingModel model);
|
||||
CostViewModel? Delete(CostBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model);
|
||||
EmployeeViewModel GetElement(EmployeeSearchModel model);
|
||||
EmployeeViewModel? Insert(EmployeeBindingModel model);
|
||||
EmployeeViewModel? Update(EmployeeBindingModel model);
|
||||
EmployeeViewModel? Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IPaymentStorage
|
||||
{
|
||||
List<PaymentViewModel> GetFullList();
|
||||
List<PaymentViewModel> GetFilteredList(PaymentSearchModel model);
|
||||
PaymentViewModel GetElement(PaymentSearchModel model);
|
||||
PaymentViewModel? Insert(PaymentBindingModel model);
|
||||
PaymentViewModel? Update(PaymentBindingModel model);
|
||||
PaymentViewModel? Delete(PaymentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IReserveStorage
|
||||
{
|
||||
List<ReserveViewModel> GetFullList();
|
||||
List<ReserveViewModel> GetFilteredList(ReserveSearchModel model);
|
||||
ReserveViewModel GetElement(ReserveSearchModel model);
|
||||
ReserveViewModel? Insert(ReserveBindingModel model);
|
||||
ReserveViewModel? Update(ReserveBindingModel model);
|
||||
ReserveViewModel? Delete(ReserveBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IRouteCostStorage
|
||||
{
|
||||
List<RouteCostViewModel> GetFullList();
|
||||
List<RouteCostViewModel> GetFilteredList(RouteCostSearchModel model);
|
||||
RouteCostViewModel GetElement(RouteCostSearchModel model);
|
||||
RouteCostViewModel? Insert(RouteCostBindingModel model);
|
||||
RouteCostViewModel? Update(RouteCostBindingModel model);
|
||||
RouteCostViewModel? Delete(RouteCostBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IRouteReserveStorage
|
||||
{
|
||||
List<RouteReserveViewModel> GetFullList();
|
||||
List<RouteReserveViewModel> GetFilteredList(RouteReserveSearchModel model);
|
||||
RouteReserveViewModel GetElement(RouteReserveSearchModel model);
|
||||
RouteReserveViewModel? Insert(RouteReserveBindingModel model);
|
||||
RouteReserveViewModel? Update(RouteReserveBindingModel model);
|
||||
RouteReserveViewModel? Delete(RouteReserveBindingModel model);
|
||||
}
|
||||
}
|
22
JurassicZoo/ZooContracts/StoragesContracts/IRouteStorage.cs
Normal file
22
JurassicZoo/ZooContracts/StoragesContracts/IRouteStorage.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooContracts.StoragesContracts
|
||||
{
|
||||
public interface IRouteStorage
|
||||
{
|
||||
List<RouteViewModel> GetFullList();
|
||||
List<RouteViewModel> GetFilteredList(RouteSearchModel model);
|
||||
List<ReportRouteReservesViewModel> GetLessonRoutes(RouteSearchModel model);
|
||||
RouteViewModel? GetElement(RouteSearchModel model);
|
||||
RouteViewModel? Insert(RouteBindingModel model);
|
||||
RouteViewModel? Update(RouteBindingModel model);
|
||||
RouteViewModel? Delete(RouteBindingModel model);
|
||||
}
|
||||
}
|
18
JurassicZoo/ZooContracts/ViewModels/ClientViewModel.cs
Normal file
18
JurassicZoo/ZooContracts/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
public string ClientPassword { get; set; } = string.Empty;
|
||||
public string ClientPhone { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
16
JurassicZoo/ZooContracts/ViewModels/CostViewModel.cs
Normal file
16
JurassicZoo/ZooContracts/ViewModels/CostViewModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class CostViewModel : ICostModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string CostName { get; set; }
|
||||
public double Sum { get; set; }
|
||||
}
|
||||
}
|
18
JurassicZoo/ZooContracts/ViewModels/EmployeeViewModel.cs
Normal file
18
JurassicZoo/ZooContracts/ViewModels/EmployeeViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ZooDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
public string EmployeeEmail { get; set; } = string.Empty;
|
||||
public string EmployeePhone { get; set; } = string.Empty;
|
||||
public string EmployeePassword { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
17
JurassicZoo/ZooContracts/ViewModels/PaymentViewModel.cs
Normal file
17
JurassicZoo/ZooContracts/ViewModels/PaymentViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
internal class PaymentViewModel : IPaymentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public double PaySum { get; set; }
|
||||
public DateTime? DateOfPayment { get; set; }
|
||||
public int RouteReserveId { get; set; }
|
||||
}
|
||||
}
|
17
JurassicZoo/ZooContracts/ViewModels/ReportCostViewModel.cs
Normal file
17
JurassicZoo/ZooContracts/ViewModels/ReportCostViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ReportCostViewModel
|
||||
{
|
||||
[DisplayName("Название затраты")]
|
||||
public string CostName { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ReportReserveRoutesViewModel
|
||||
{
|
||||
public int ReserveId { get; set; }
|
||||
public int RoutesCount { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ReportRouteReservesViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Номер маршрута
|
||||
/// </summary>
|
||||
public int RouteId { get; set; }
|
||||
/// <summary>
|
||||
/// Заповедник в Маршруте
|
||||
/// </summary>
|
||||
public List<ReportReserveRouteViewModel> RouteLessons { get; set; } = new();
|
||||
}
|
||||
}
|
23
JurassicZoo/ZooContracts/ViewModels/ReportViewModel.cs
Normal file
23
JurassicZoo/ZooContracts/ViewModels/ReportViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ReportViewModel
|
||||
{
|
||||
[DisplayName("Название маршрута")]
|
||||
public int RouteNumber { get; set; }
|
||||
[DisplayName("Дата записи")]
|
||||
public DateTime Date { get; set; }
|
||||
[DisplayName("Сумма затрат")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Кол-во заповедников")]
|
||||
public int RouteCount { get; set; }
|
||||
[DisplayName("Название затраты")]
|
||||
public List<ReportCostViewModel> Cost { get; set; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooContracts/ViewModels/ReserveViewModel.cs
Normal file
20
JurassicZoo/ZooContracts/ViewModels/ReserveViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class ReserveViewModel : IReserveModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название заповедника")]
|
||||
public string ReserveName { get; set; } = string.Empty;
|
||||
[DisplayName("стоимость посешения заповедника")]
|
||||
public double ReservePrice { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
}
|
||||
}
|
19
JurassicZoo/ZooContracts/ViewModels/RouteCostViewModel.cs
Normal file
19
JurassicZoo/ZooContracts/ViewModels/RouteCostViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class RouteCostViewModel : IRouteCostModel
|
||||
{
|
||||
[DisplayName("Id маршрута")]
|
||||
public int RouteId { get; set; }
|
||||
[DisplayName("Id затраты")]
|
||||
public int CostId { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
19
JurassicZoo/ZooContracts/ViewModels/RouteReserveViewModel.cs
Normal file
19
JurassicZoo/ZooContracts/ViewModels/RouteReserveViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class RouteReserveViewModel : IRouteReserveModel
|
||||
{
|
||||
[DisplayName("Id маршрута")]
|
||||
public int RouteId { get; set; }
|
||||
[DisplayName("Id заповедника")]
|
||||
public int ReserveId { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooContracts/ViewModels/RouteViewModel.cs
Normal file
20
JurassicZoo/ZooContracts/ViewModels/RouteViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooContracts.ViewModels
|
||||
{
|
||||
public class RouteViewModel : IRouteModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя клиента")]
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
[DisplayName("Дата начала ")]
|
||||
public DateTime DateStart { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
}
|
||||
}
|
13
JurassicZoo/ZooContracts/ZooContracts.csproj
Normal file
13
JurassicZoo/ZooContracts/ZooContracts.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZooDataModels\ZooDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
13
JurassicZoo/ZooDataModels/IId.cs
Normal file
13
JurassicZoo/ZooDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
28
JurassicZoo/ZooDataModels/Models/IClientModel.cs
Normal file
28
JurassicZoo/ZooDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Имя
|
||||
/// </summary>
|
||||
public string ClientName { get; }
|
||||
/// <summary>
|
||||
/// Почта
|
||||
/// </summary>
|
||||
public string ClientEmail { get; }
|
||||
/// <summary>
|
||||
/// Телефон
|
||||
/// </summary>
|
||||
public string ClientPhone { get; }
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
public string ClientPassword { get; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooDataModels/Models/ICostModel.cs
Normal file
20
JurassicZoo/ZooDataModels/Models/ICostModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface ICostModel: IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Сумма затраты
|
||||
/// </summary>
|
||||
public double Sum { get; }
|
||||
/// <summary>
|
||||
/// Название
|
||||
/// </summary>
|
||||
public string CostName { get; }
|
||||
}
|
||||
}
|
28
JurassicZoo/ZooDataModels/Models/IEmployeeModel.cs
Normal file
28
JurassicZoo/ZooDataModels/Models/IEmployeeModel.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IEmployeeModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Имя
|
||||
/// </summary>
|
||||
public string EmployeeName { get; set; }
|
||||
/// <summary>
|
||||
/// Почта
|
||||
/// </summary>
|
||||
public string EmployeeEmail { get; set; }
|
||||
/// <summary>
|
||||
/// Телефон
|
||||
/// </summary>
|
||||
public string EmployeePhone { get; set; }
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
public string EmployeePassword { get; set; }
|
||||
}
|
||||
}
|
24
JurassicZoo/ZooDataModels/Models/IPaymentModel.cs
Normal file
24
JurassicZoo/ZooDataModels/Models/IPaymentModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IPaymentModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Оплаченная сумма
|
||||
/// </summary>
|
||||
public double PaySum { get; set; }
|
||||
/// <summary>
|
||||
/// Дата платежа
|
||||
/// </summary>
|
||||
public DateTime? DateOfPayment { get; set; }
|
||||
/// <summary>
|
||||
/// Id заповедника маршрута
|
||||
/// </summary>
|
||||
public int RouteReserveId { get; set; }
|
||||
}
|
||||
}
|
24
JurassicZoo/ZooDataModels/Models/IReserveModel.cs
Normal file
24
JurassicZoo/ZooDataModels/Models/IReserveModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IReserveModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Название
|
||||
/// </summary>
|
||||
public string ReserveName { get; set; }
|
||||
/// <summary>
|
||||
/// Стоимость
|
||||
/// </summary>
|
||||
public double ReservePrice { get; set; }
|
||||
/// <summary>
|
||||
/// Id Сотрудника
|
||||
/// </summary>
|
||||
public int EmployeeId { get; set; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooDataModels/Models/IRouteCostModel.cs
Normal file
20
JurassicZoo/ZooDataModels/Models/IRouteCostModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IRouteCostModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Id маршрута
|
||||
/// </summary>
|
||||
public int RouteId { get; }
|
||||
/// <summary>
|
||||
/// Id затрат
|
||||
/// </summary>
|
||||
public int CostId { get; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooDataModels/Models/IRouteModel.cs
Normal file
20
JurassicZoo/ZooDataModels/Models/IRouteModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IRouteModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Дата начала
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; }
|
||||
/// <summary>
|
||||
/// Id клиента
|
||||
/// </summary>
|
||||
public int ClientId { get; }
|
||||
}
|
||||
}
|
20
JurassicZoo/ZooDataModels/Models/IRouteReserveModel.cs
Normal file
20
JurassicZoo/ZooDataModels/Models/IRouteReserveModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZooDataModels.Models
|
||||
{
|
||||
public interface IRouteReserveModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Id маршрута
|
||||
/// </summary>
|
||||
public int RouteId { get; }
|
||||
/// /// <summary>
|
||||
/// Id заповедника
|
||||
/// </summary>
|
||||
public int ReserveId { get; }
|
||||
}
|
||||
}
|
12
JurassicZoo/ZooDataModels/Properties/launchSettings.json
Normal file
12
JurassicZoo/ZooDataModels/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"ZooDataModels": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53044;http://localhost:53046"
|
||||
}
|
||||
}
|
||||
}
|
9
JurassicZoo/ZooDataModels/ZooDataModels.csproj
Normal file
9
JurassicZoo/ZooDataModels/ZooDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
if (model.ClientEmail != null)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Clients
|
||||
.Where(rec => rec.ClientEmail.Contains(model.ClientEmail))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)
|
||||
return context.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.ClientEmail != null && model.ClientPassword != null)
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => x.ClientEmail == model.ClientEmail
|
||||
&& x.ClientPassword == model.ClientPassword)?.GetViewModel;
|
||||
if (model.ClientEmail != null)
|
||||
return context.Clients.FirstOrDefault(x => x.ClientEmail == model.ClientEmail)?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var res = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
res?.Update(model);
|
||||
context.SaveChanges();
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var res = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
context.Clients.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
90
JurassicZoo/ZooDatabaseImplements/Implements/CostStorage.cs
Normal file
90
JurassicZoo/ZooDatabaseImplements/Implements/CostStorage.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class CostStorage : ICostStorage
|
||||
{
|
||||
public CostViewModel? Delete(CostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var element = context.Costs.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Costs.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CostViewModel GetElement(CostSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)//сначала ищем по Id
|
||||
{
|
||||
return context.Costs
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.CostName))//затем по названию
|
||||
{
|
||||
return context.Costs
|
||||
.FirstOrDefault(x => x.CostName == model.CostName)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<CostViewModel> GetFilteredList(CostSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Costs
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CostViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Costs
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CostViewModel? Insert(CostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var newCost = Cost.Create(model);
|
||||
if (newCost == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Costs.Add(newCost);
|
||||
context.SaveChanges();
|
||||
return newCost.GetViewModel;
|
||||
}
|
||||
|
||||
public CostViewModel? Update(CostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var Cost = context.Costs.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Cost == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Cost.Update(model);
|
||||
context.SaveChanges();
|
||||
return Cost.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
public List<CostViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Employees
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<CostViewModel> GetFilteredList(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
if (model.EmployeeName != null)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Employees
|
||||
.Where(rec => rec.EmployeeName.Contains(model.EmployeeName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public CostViewModel? GetElement(EmployeeSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)
|
||||
return context.Employees.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.EmployeeName != null && model.EmployeePassword != null)
|
||||
return context.Employees
|
||||
.FirstOrDefault(x => x.EmployeeName.Equals(model.EmployeeName)
|
||||
&& x.EmployeePassword.Equals(model.EmployeePassword))
|
||||
?.GetViewModel;
|
||||
if (model.EmployeeName != null)
|
||||
return context.Employees.FirstOrDefault(x => x.EmployeeName.Contains(model.EmployeeName))?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
public CostViewModel? Insert(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var res = Employee.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
context.Employees.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
public CostViewModel? Update(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var res = context.Employees.FirstOrDefault(x => x.Id == model.Id);
|
||||
res?.Update(model);
|
||||
context.SaveChanges();
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
public CostViewModel? Delete(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var res = context.Employees.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
context.Employees.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
113
JurassicZoo/ZooDatabaseImplements/Implements/PaymentStorage.cs
Normal file
113
JurassicZoo/ZooDatabaseImplements/Implements/PaymentStorage.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class PaymentStorage : IPaymentStorage
|
||||
{
|
||||
public List<PaymentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Payments
|
||||
.Include(rec => rec.RouteReserve)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PaymentViewModel> GetFilteredList(PaymentSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
var list = context.Payments.Where(x => x.RouteReserveId == model.RouteReserveId)
|
||||
.OrderBy(x => x.DateOfPayment)
|
||||
.Include(x => x.RouteReserve);
|
||||
return list
|
||||
.Select(x => new PaymentViewModel
|
||||
{
|
||||
DateOfPayment = x.DateOfPayment,
|
||||
Id = x.Id,
|
||||
PaySum = x.PaySum,
|
||||
RouteReserveId = x.RouteReserveId
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
public PaymentViewModel GetElement(PaymentSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
{
|
||||
var payment = context.Payments.Include(x => x.RouteReserve)
|
||||
.FirstOrDefault(x => x.RouteReserveId == model.RouteReserveId);
|
||||
return payment != null ? new PaymentViewModel
|
||||
{
|
||||
DateOfPayment = payment.DateOfPayment,
|
||||
Id = payment.Id,
|
||||
PaySum = payment.PaySum,
|
||||
RouteReserveId = payment.RouteReserveId
|
||||
} :
|
||||
null;
|
||||
}
|
||||
}
|
||||
public PaymentViewModel? Insert(PaymentBindingModel model)
|
||||
{
|
||||
var context = new ZooDatabase();
|
||||
var newPayment = Payment.Create(context, model);
|
||||
if (newPayment == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Payments.Add(newPayment);
|
||||
context.SaveChanges();
|
||||
return newPayment.GetViewModel;
|
||||
}
|
||||
|
||||
public PaymentViewModel? Update(PaymentBindingModel model)
|
||||
{
|
||||
var context = new ZooDatabase();
|
||||
var element = context.Payments.
|
||||
Include(x => x.RouteReserve)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Оплата не найдена");
|
||||
}
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
public PaymentViewModel? Delete(PaymentBindingModel model)
|
||||
{
|
||||
var context = new ZooDatabase();
|
||||
|
||||
var element = context.Payments
|
||||
.Include(x => x.RouteReserve)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Payments.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element?.GetViewModel;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Оплата не найдена");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class ReserveStorage : IReserveStorage
|
||||
{
|
||||
public List<ReserveViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Reserves
|
||||
.Include(x => x.Employee)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ReserveViewModel> GetFilteredList(ReserveSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Reserves
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Employee)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ReserveViewModel? GetElement(ReserveSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)//сначала ищем по Id
|
||||
{
|
||||
return context.Reserves
|
||||
.Include(x => x.Employee)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.ReserveName))//ищем по названию
|
||||
{
|
||||
return context.Reserves
|
||||
.Include(x => x.Employee)
|
||||
.FirstOrDefault(x => x.ReserveName == model.ReserveName)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ReserveViewModel? Insert(ReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var newReserve = Reserve.Create(context, model);
|
||||
if (newReserve == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Reserves.Add(newReserve);
|
||||
context.SaveChanges();
|
||||
return newReserve.GetViewModel;
|
||||
}
|
||||
public ReserveViewModel? Update(ReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var Reserve = context.Reserves.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Reserve == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Reserve.Update(model);
|
||||
context.SaveChanges();
|
||||
return Reserve.GetViewModel;
|
||||
}
|
||||
public ReserveViewModel? Delete(ReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var element = context.Reserves.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Reserves.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class RouteCostStorage : IRouteCostStorage
|
||||
{
|
||||
public RouteCostViewModel? Delete(RouteCostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var RouteCost = context.RouteCosts.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (RouteCost != null)
|
||||
{
|
||||
context.RouteCosts.Remove(RouteCost);
|
||||
context.SaveChanges();
|
||||
return RouteCost.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RouteCostViewModel GetElement(RouteCostSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.RouteCosts.Include(x => x.Route)
|
||||
.Include(x => x.Cost)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RouteCostViewModel> GetFilteredList(RouteCostSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.RouteCosts
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Route)
|
||||
.Include(x => x.Cost)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RouteCostViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.RouteCosts
|
||||
.Include(x => x.Route)
|
||||
.Include(x => x.Cost)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RouteCostViewModel? Insert(RouteCostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var newRouteCost = RouteCost.Create(context, model);
|
||||
if (newRouteCost == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.RouteCosts.Add(newRouteCost);
|
||||
context.SaveChanges();
|
||||
return newRouteCost.GetViewModel;
|
||||
}
|
||||
|
||||
public RouteCostViewModel? Update(RouteCostBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var RouteCost = context.RouteCosts.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (RouteCost == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RouteCost.Update(model);
|
||||
context.SaveChanges();
|
||||
return RouteCost.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class RouteReserveStorage : IRouteReserveStorage
|
||||
{
|
||||
public RouteReserveViewModel? Delete(RouteReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var RouteReserve = context.RouteReserves.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (RouteReserve != null)
|
||||
{
|
||||
context.RouteReserves.Remove(RouteReserve);
|
||||
context.SaveChanges();
|
||||
return RouteReserve.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RouteReserveViewModel? GetElement(RouteReserveSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.RouteReserves.Include(x => x.Route)
|
||||
.Include(x => x.Reserve)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RouteReserveViewModel> GetFilteredList(RouteReserveSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.RouteReserves
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Route)
|
||||
.Include(x => x.Reserve)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RouteReserveViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.RouteReserves
|
||||
.Include(x => x.Route)
|
||||
.Include(x => x.Reserve)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RouteReserveViewModel? Insert(RouteReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var newRouteReserve = RouteReserve.Create(context, model);
|
||||
if (newRouteReserve == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.RouteReserves.Add(newRouteReserve);
|
||||
context.SaveChanges();
|
||||
return newRouteReserve.GetViewModel;
|
||||
}
|
||||
|
||||
public RouteReserveViewModel? Update(RouteReserveBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var RouteReserve = context.RouteReserves.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (RouteReserve == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RouteReserve.Update(model);
|
||||
context.SaveChanges();
|
||||
return RouteReserve.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
128
JurassicZoo/ZooDatabaseImplements/Implements/RouteStorage.cs
Normal file
128
JurassicZoo/ZooDatabaseImplements/Implements/RouteStorage.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModel;
|
||||
using ZooContracts.StoragesContracts;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDatabaseImplements;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Implements
|
||||
{
|
||||
public class RouteStorage : IRouteStorage
|
||||
{
|
||||
public List<RouteViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
return context.Routes
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<RouteViewModel> GetFilteredList(RouteSearchModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по id, значит ищем по диапазону дат
|
||||
{
|
||||
return context.Routes
|
||||
.Where(x => model.DateFrom <= x.DateStart.Date && x.DateStart <= model.DateTo)
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Routes
|
||||
.Where(x => x.Client.Id == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public RouteViewModel? GetElement(RouteSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Routes.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public RouteViewModel? Insert(RouteBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var newRoute = Route.Create(context, model);
|
||||
if (newRoute == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Routes.Add(newRoute);
|
||||
context.SaveChanges();
|
||||
return newRoute.GetViewModel;
|
||||
}
|
||||
public RouteViewModel? Update(RouteBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var Route = context.Routes.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Route == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Route.Update(model);
|
||||
context.SaveChanges();
|
||||
return Route.GetViewModel;
|
||||
}
|
||||
public RouteViewModel? Delete(RouteBindingModel model)
|
||||
{
|
||||
using var context = new ZooDatabase();
|
||||
var Route = context.Routes.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (Route != null)
|
||||
{
|
||||
context.Routes.Remove(Route);
|
||||
context.SaveChanges();
|
||||
return Route.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ReportRouteReservesViewModel> GetReserveRoutes(RouteSearchModel model)
|
||||
{
|
||||
if (model.SelectedRoutesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ZooDatabase();
|
||||
return context.Routes
|
||||
.Where(c => model.SelectedRoutesIds.Contains(c.Id))
|
||||
.Select(c => new ReportRouteReservesViewModel()
|
||||
{
|
||||
RouteReserves = GetRouteReserves(context, new() { Id = c.Id })
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка заповедников по выбранному маршруту
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
private static List<ReportReserveRoutesViewModel> GetRouteReserves(ZooDatabase context, RouteSearchModel model)
|
||||
{
|
||||
return context.Routes
|
||||
.Include(wir => wir.RouteReserves)
|
||||
.Where(wir => wir.Id == model.Id)
|
||||
.Select(wir => new ReportReserveRoutesViewModel()
|
||||
{
|
||||
ReserveId = wir.RouteReserves.Id
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
62
JurassicZoo/ZooDatabaseImplements/Models/Client.cs
Normal file
62
JurassicZoo/ZooDatabaseImplements/Models/Client.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ClientName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string ClientPhone { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string ClientPassword { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string ClientEmail { get; private set; } = string.Empty;
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Route> Routes { get; set; } = new();
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientName = model.ClientName,
|
||||
ClientEmail = model.ClientEmail,
|
||||
ClientPassword = model.ClientPassword,
|
||||
ClientPhone = model.ClientPhone
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientName = model.ClientName;
|
||||
ClientEmail = model.ClientEmail;
|
||||
ClientPassword = model.ClientPassword;
|
||||
ClientPhone = model.ClientPhone;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientName = ClientName,
|
||||
ClientEmail = ClientEmail,
|
||||
ClientPassword = ClientPassword,
|
||||
ClientPhone = ClientPhone
|
||||
};
|
||||
}
|
||||
}
|
52
JurassicZoo/ZooDatabaseImplements/Models/Cost.cs
Normal file
52
JurassicZoo/ZooDatabaseImplements/Models/Cost.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Cost : ICostModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string CostName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
[ForeignKey("CostId")]
|
||||
public virtual List<RouteCost> RouteCosts { get; set; } = new();
|
||||
public static Cost? Create(CostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
CostName = model.CostName,
|
||||
Sum = model.Sum
|
||||
};
|
||||
}
|
||||
public void Update(CostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CostName = model.CostName;
|
||||
Sum = model.Sum;
|
||||
}
|
||||
|
||||
public CostViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CostName = CostName,
|
||||
Sum = Sum
|
||||
};
|
||||
}
|
||||
}
|
59
JurassicZoo/ZooDatabaseImplements/Models/Employee.cs
Normal file
59
JurassicZoo/ZooDatabaseImplements/Models/Employee.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Employee : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string EmployeePhone { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string EmployeeEmail { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string EmployeePassword { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
[ForeignKey("EmployeeId")]
|
||||
public virtual List<Reserve> Reserves { get; set; } = new();
|
||||
public static Employee? Create(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
EmployeeName = model.EmployeeName,
|
||||
EmployeeEmail = model.EmployeeEmail,
|
||||
EmployeePassword = model.EmployeePassword,
|
||||
EmployeePhone = model.EmployeePhone
|
||||
};
|
||||
}
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EmployeeName = model.EmployeeName;
|
||||
EmployeeEmail = model.EmployeeEmail;
|
||||
EmployeePassword = model.EmployeePassword;
|
||||
EmployeePhone = model.EmployeePhone;
|
||||
}
|
||||
|
||||
public CostViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id
|
||||
};
|
||||
}
|
||||
}
|
66
JurassicZoo/ZooDatabaseImplements/Models/Payment.cs
Normal file
66
JurassicZoo/ZooDatabaseImplements/Models/Payment.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Payment : IPaymentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int RouteReserveId { get; private set; }
|
||||
[Required]
|
||||
public double PaySum { get; private set; }
|
||||
[Required]
|
||||
public DateTime? DateOfPayment { get; private set; } = DateTime.Now;
|
||||
public virtual RouteReserve RouteReserve { get; private set; } = new();
|
||||
public static Payment? Create(ZooDatabase context, PaymentBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Payment()
|
||||
{
|
||||
Id = model.Id,
|
||||
RouteReserve = context.RouteReserves.First(x => x.Id == model.RouteReserveId),
|
||||
PaySum = model.PaySum,
|
||||
DateOfPayment = model.DateOfPayment
|
||||
};
|
||||
}
|
||||
public void Update(PaymentBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
RouteReserveId = model.RouteReserveId;
|
||||
PaySum = model.PaySum;
|
||||
DateOfPayment = model.DateOfPayment;
|
||||
}
|
||||
|
||||
|
||||
public PaymentViewModel GetViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
var context = new ZooDatabase();
|
||||
return new()
|
||||
{
|
||||
Id = Id,
|
||||
RouteReserveId = RouteReserveId,
|
||||
PaySum = PaySum,
|
||||
DateOfPayment = DateOfPayment
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
70
JurassicZoo/ZooDatabaseImplements/Models/Reserve.cs
Normal file
70
JurassicZoo/ZooDatabaseImplements/Models/Reserve.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Reserve : IReserveModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ReserveName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double ReservePrice { get; private set; }
|
||||
[Required]
|
||||
public int EmployeeId { get; private set; }
|
||||
public virtual Employee Employee { get; private set; } = new();
|
||||
[ForeignKey("ReserveId")]
|
||||
public virtual List<RouteReserve> RouteReserves { get; set; } = new();
|
||||
[ForeignKey("ReserveId")]
|
||||
public virtual List<Payment> Payments { get; set; } = new();
|
||||
public static Reserve? Create(ZooDatabase context, ReserveBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Reserve()
|
||||
{
|
||||
Id = model.Id,
|
||||
ReserveName = model.ReserveName,
|
||||
ReservePrice = model.ReservePrice,
|
||||
Employee = context.Employees.First(x => x.Id == model.EmployeeId)
|
||||
};
|
||||
}
|
||||
public static Reserve Create(ReserveViewModel model)
|
||||
{
|
||||
return new Reserve
|
||||
{
|
||||
Id = model.Id,
|
||||
ReserveName = model.ReserveName,
|
||||
ReservePrice = model.ReservePrice,
|
||||
EmployeeId = model.EmployeeId
|
||||
};
|
||||
}
|
||||
public void Update(ReserveBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ReserveName = model.ReserveName;
|
||||
ReservePrice = model.ReservePrice;
|
||||
EmployeeId = model.EmployeeId;
|
||||
}
|
||||
public ReserveViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ReserveName = ReserveName,
|
||||
ReservePrice = ReservePrice,
|
||||
EmployeeId = EmployeeId
|
||||
};
|
||||
}
|
||||
}
|
51
JurassicZoo/ZooDatabaseImplements/Models/Route.cs
Normal file
51
JurassicZoo/ZooDatabaseImplements/Models/Route.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooDataModels.Models;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class Route : IRouteModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public DateTime DateStart { get; private set; } = DateTime.Now;
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public virtual Client Client { get; private set; } = new();
|
||||
[ForeignKey("RouteId")]
|
||||
public virtual RouteReserve RouteReserves { get; set; } = new();
|
||||
[ForeignKey("RouteId")]
|
||||
public virtual List<RouteCost> RouteCosts { get; set; } = new();
|
||||
public static Route Create(ZooDatabase context, RouteBindingModel model)
|
||||
{
|
||||
return new Route()
|
||||
{
|
||||
Id = model.Id,
|
||||
DateStart = model.DateStart,
|
||||
Client = context.Clients.First(x => x.Id == model.ClientId)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RouteBindingModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
DateStart = model.DateStart;
|
||||
ClientId = model.ClientId;
|
||||
}
|
||||
|
||||
public RouteViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DateStart = DateStart,
|
||||
ClientId = ClientId,
|
||||
ClientName = Client.ClientName
|
||||
};
|
||||
}
|
||||
}
|
45
JurassicZoo/ZooDatabaseImplements/Models/RouteCost.cs
Normal file
45
JurassicZoo/ZooDatabaseImplements/Models/RouteCost.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class RouteCost : IRouteCostModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int CostId { get; set; }
|
||||
[Required]
|
||||
public int RouteId { get; set; }
|
||||
public virtual Cost Cost { get; set; } = new();
|
||||
public virtual Route Route { get; set; } = new();
|
||||
public static RouteCost? Create(ZooDatabase context, RouteCostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Route = context.Routes.First(x => x.Id == model.RouteId),
|
||||
Cost = context.Costs.First(x => x.Id == model.CostId)
|
||||
};
|
||||
}
|
||||
public void Update(RouteCostBindingModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
}
|
||||
|
||||
public RouteCostViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id
|
||||
};
|
||||
}
|
||||
}
|
47
JurassicZoo/ZooDatabaseImplements/Models/RouteReserve.cs
Normal file
47
JurassicZoo/ZooDatabaseImplements/Models/RouteReserve.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooDatabaseImplements.Models
|
||||
{
|
||||
public class RouteReserve : IRouteReserveModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int RouteId { get; set; }
|
||||
[Required]
|
||||
public int ReserveId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Reserve Reserve { get; set; } = new();
|
||||
public virtual Route Route { get; set; } = new();
|
||||
[ForeignKey("RouteReserveId")]
|
||||
public virtual List<Payment> Payments { get; set; } = new();
|
||||
public static RouteReserve Create(ZooDatabase context, RouteReserveBindingModel model)
|
||||
{
|
||||
return new RouteReserve()
|
||||
{
|
||||
Id = model.Id,
|
||||
Route = context.Routes.First(x => x.Id == model.RouteId),
|
||||
Reserve = context.Reserves.First(x => x.Id == model.ReserveId)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RouteReserveBindingModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
}
|
||||
|
||||
public RouteReserveViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id
|
||||
};
|
||||
}
|
||||
}
|
29
JurassicZoo/ZooDatabaseImplements/ZooDatabase.cs
Normal file
29
JurassicZoo/ZooDatabaseImplements/ZooDatabase.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ZooDatabaseImplement.Models;
|
||||
using System.Collections.Generic;
|
||||
using ZooDatabaseImplements.Models;
|
||||
|
||||
namespace ZooDatabaseImplements
|
||||
{
|
||||
public class ZooDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-5NJEOK79\SQLEXPRESS;Database=SchoolDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
}
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<RouteReserve> RouteReserves { set; get; }
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
public virtual DbSet<Payment> Payments { set; get; }
|
||||
public virtual DbSet<Cost> Costs { set; get; }
|
||||
public virtual DbSet<Route> Routes { set; get; }
|
||||
public virtual DbSet<Reserve> Reserves { set; get; }
|
||||
public virtual DbSet<RouteCost> RouteCosts { set; get; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<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.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZooContracts\ZooContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user