Contracts и DataModels
This commit is contained in:
parent
a5e3fb9620
commit
06ad198c12
43
Device.sln
Normal file
43
Device.sln
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceDataModels", "DeviceDataModels\DeviceDataModels.csproj", "{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceContracts", "DeviceContracts\DeviceContracts.csproj", "{FA3605A8-7525-47B5-BE3E-4A90001971B5}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436} = {E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceBusinessLogic", "DeviceBusinessLogic\DeviceBusinessLogic.csproj", "{6C1D1FDB-1C09-4A68-8EF3-F4899C7D6472}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{FA3605A8-7525-47B5-BE3E-4A90001971B5} = {FA3605A8-7525-47B5-BE3E-4A90001971B5}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E4D8A5BF-C4ED-4E90-A630-A8880C4B4436}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA3605A8-7525-47B5-BE3E-4A90001971B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA3605A8-7525-47B5-BE3E-4A90001971B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA3605A8-7525-47B5-BE3E-4A90001971B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA3605A8-7525-47B5-BE3E-4A90001971B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C1D1FDB-1C09-4A68-8EF3-F4899C7D6472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C1D1FDB-1C09-4A68-8EF3-F4899C7D6472}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C1D1FDB-1C09-4A68-8EF3-F4899C7D6472}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C1D1FDB-1C09-4A68-8EF3-F4899C7D6472}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {82B350BB-9E8B-4A68-B9B7-284015C2B352}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
Device/Class1.cs
Normal file
7
Device/Class1.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Device
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
9
Device/Device.csproj
Normal file
9
Device/Device.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
165
DeviceBusinessLogic/BusinessLogics/CabinetLogic.cs
Normal file
165
DeviceBusinessLogic/BusinessLogics/CabinetLogic.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.BusinessLogicsContracts;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.StoragesContracts;
|
||||
using DeviceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DeviceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
public ClientLogic(ILogger<ClientLogic> logger,
|
||||
IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Snils: {Snils}", model.Snils);
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
"ReadList. ClientSurname: {ClientSurname} {ClientName} " +
|
||||
"{ClientPatronomic}. Snils: {Snils}", model?.ClientSurname,
|
||||
model?.ClientName, model?.ClientPatronymic, model?.Snils);
|
||||
var list = model == null ? _clientStorage.GetFullList() :
|
||||
_clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation(
|
||||
"ReadElement. ClientFullname: {ClientSurname} {ClientName} " +
|
||||
"{ClientPatronomic}. Snils: {Snils}", model.ClientSurname,
|
||||
model.ClientName, model.ClientPatronymic, model.Snils);
|
||||
var element = _clientStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Snils: {Snils}",
|
||||
element.Snils);
|
||||
return element;
|
||||
}
|
||||
private void CheckModel(ClientBindingModel model,
|
||||
bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Snils))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует СНИЛС клиента",
|
||||
nameof(model.Snils));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientSurname))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует фамилия клиента",
|
||||
nameof(model.ClientSurname));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientName))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует имя клиента",
|
||||
nameof(model.ClientName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientPatronymic))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует отчество клиента",
|
||||
nameof(model.ClientPatronymic));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Phone))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует номер телефона клиента",
|
||||
nameof(model.Phone));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PasswordHash))
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Отсутствует пароль клиента",
|
||||
nameof(model.PasswordHash));
|
||||
}
|
||||
if (model.WorkerId <= 0)
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"Идентификатор работника должен быть больше 0",
|
||||
nameof(model.WorkerId));
|
||||
}
|
||||
_logger.LogInformation("Client. Snils: {Snils}. ClientFullname: " +
|
||||
"{ClientSurname} {ClientName} {ClientPatronymic}. Phone: " +
|
||||
"{Phone}. Email: {Email}. PasswordHash: {PasswordHash}.",
|
||||
model.Snils, model.ClientSurname, model.ClientName,
|
||||
model.ClientPatronymic, model.Phone, model.Email,
|
||||
model.PasswordHash);
|
||||
var elementByEmail = _clientStorage.GetElement(
|
||||
new ClientSearchModel
|
||||
{
|
||||
Email = model.Email,
|
||||
});
|
||||
var elementByPhone = _clientStorage.GetElement(
|
||||
new ClientSearchModel
|
||||
{
|
||||
Phone = model.Phone,
|
||||
});
|
||||
if ((elementByEmail != null && elementByEmail.Snils != model.Snils)
|
||||
|| (elementByPhone != null && elementByPhone.Snils
|
||||
!= model.Snils))
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с такой почтой " +
|
||||
"или номером телефона уже существует");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
DeviceBusinessLogic/DeviceBusinessLogic.csproj
Normal file
16
DeviceBusinessLogic/DeviceBusinessLogic.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DeviceContracts\DeviceContracts.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
10
DeviceContracts/BindingModels/CabinetBindingModel.cs
Normal file
10
DeviceContracts/BindingModels/CabinetBindingModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class CabinetBindingModel : ICabinetModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Room { get; set; } = string.Empty;
|
||||
public int Building { get; set; }
|
||||
}
|
||||
}
|
15
DeviceContracts/BindingModels/DeviceBindingModel.cs
Normal file
15
DeviceContracts/BindingModels/DeviceBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class DeviceBindingModel : IDeviceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Model { get; set; } = string.Empty;
|
||||
public string? SerialNumber { get; set; } = string.Empty;
|
||||
public DateOnly? ProductionDate { get; set; }
|
||||
public int? WarrantyPeriod { get; set; }
|
||||
public bool Condition { get; set; }
|
||||
public int KindId { get; set; }
|
||||
public int? KitId { get; set; }
|
||||
}
|
||||
}
|
10
DeviceContracts/BindingModels/KindBindingModel.cs
Normal file
10
DeviceContracts/BindingModels/KindBindingModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class KindBindingModel : IKindModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public int Frequency { get; set; }
|
||||
}
|
||||
}
|
10
DeviceContracts/BindingModels/KitBindingModel.cs
Normal file
10
DeviceContracts/BindingModels/KitBindingModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class KitBindingModel : IKitModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public int? CabinetId { get; set; }
|
||||
}
|
||||
}
|
12
DeviceContracts/BindingModels/ServiceBindingModel.cs
Normal file
12
DeviceContracts/BindingModels/ServiceBindingModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class ServiceBindingModel : IServiceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public DateOnly StartDate { get; set; }
|
||||
public DateOnly? EndDate { get; set; }
|
||||
public int DeviceId { get; set; }
|
||||
}
|
||||
}
|
16
DeviceContracts/BindingModels/StaffBindingModel.cs
Normal file
16
DeviceContracts/BindingModels/StaffBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using DeviceDataModels.Enums;
|
||||
using DeviceDataModels.Models;
|
||||
namespace DeviceContracts.BindingModels
|
||||
{
|
||||
public class StaffBindingModel : IStaffModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
public string Department { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public AccessLevel AccessLevel { get; }
|
||||
public Dictionary<int, (IKitModel, int)> Ownership { get; set; }
|
||||
= new();
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/ICabinetLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/ICabinetLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICabinetLogic
|
||||
{
|
||||
List<CabinetViewModel>? ReadList(CabinetSearchModel? model);
|
||||
CabinetViewModel? ReadElement(CabinetSearchModel model);
|
||||
bool Create(CabinetBindingModel model);
|
||||
bool Update(CabinetBindingModel model);
|
||||
bool Delete(CabinetBindingModel model);
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/IDeviceLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/IDeviceLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IDeviceLogic
|
||||
{
|
||||
List<DeviceViewModel>? ReadList(DeviceSearchModel? model);
|
||||
DeviceViewModel? ReadElement(DeviceSearchModel model);
|
||||
bool Create(DeviceBindingModel model);
|
||||
bool Update(DeviceBindingModel model);
|
||||
bool Delete(DeviceBindingModel model);
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/IKindLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/IKindLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IKindLogic
|
||||
{
|
||||
List<KindViewModel>? ReadList(KindSearchModel? model);
|
||||
KindViewModel? ReadElement(KindSearchModel model);
|
||||
bool Create(KindBindingModel model);
|
||||
bool Update(KindBindingModel model);
|
||||
bool Delete(KindBindingModel model);
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/IKitLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/IKitLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IKitLogic
|
||||
{
|
||||
List<KitViewModel>? ReadList(KitSearchModel? model);
|
||||
KitViewModel? ReadElement(KitSearchModel model);
|
||||
bool Create(KitBindingModel model);
|
||||
bool Update(KitBindingModel model);
|
||||
bool Delete(KitBindingModel model);
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/IServiceLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/IServiceLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IServiceLogic
|
||||
{
|
||||
List<ServiceViewModel>? ReadList(ServiceSearchModel? model);
|
||||
ServiceViewModel? ReadElement(ServiceSearchModel model);
|
||||
bool Create(ServiceBindingModel model);
|
||||
bool Update(ServiceBindingModel model);
|
||||
bool Delete(ServiceBindingModel model);
|
||||
}
|
||||
}
|
14
DeviceContracts/BusinessLogicsContracts/IStaffLogic.cs
Normal file
14
DeviceContracts/BusinessLogicsContracts/IStaffLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStaffLogic
|
||||
{
|
||||
List<StaffViewModel>? ReadList(StaffSearchModel? model);
|
||||
StaffViewModel? ReadElement(StaffSearchModel model);
|
||||
bool Create(StaffBindingModel model);
|
||||
bool Update(StaffBindingModel model);
|
||||
bool Delete(StaffBindingModel model);
|
||||
}
|
||||
}
|
12
DeviceContracts/DeviceContracts.csproj
Normal file
12
DeviceContracts/DeviceContracts.csproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DeviceDataModels\DeviceDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
9
DeviceContracts/SearchModels/CabinetSearchModel.cs
Normal file
9
DeviceContracts/SearchModels/CabinetSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class CabinetSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Room { get; set; }
|
||||
public int? Building { get; set; }
|
||||
}
|
||||
}
|
15
DeviceContracts/SearchModels/DeviceSearchModel.cs
Normal file
15
DeviceContracts/SearchModels/DeviceSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class DeviceSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Model { get; set; }
|
||||
public string? SerialNumber { get; set; }
|
||||
public DateOnly? ProductionDate { get; set; }
|
||||
public int? WarrantyPeriod { get; set; }
|
||||
public bool? Condition { get; set; }
|
||||
public int KindId { get; set; }
|
||||
public int? KitId { get; set; }
|
||||
|
||||
}
|
||||
}
|
9
DeviceContracts/SearchModels/KindSearchModel.cs
Normal file
9
DeviceContracts/SearchModels/KindSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class KindSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? Frequency { get; set; }
|
||||
}
|
||||
}
|
9
DeviceContracts/SearchModels/KitSearchModel.cs
Normal file
9
DeviceContracts/SearchModels/KitSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class KitSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? CabinetId { get; set; }
|
||||
}
|
||||
}
|
11
DeviceContracts/SearchModels/ServiceSearchModel.cs
Normal file
11
DeviceContracts/SearchModels/ServiceSearchModel.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class ServiceSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateOnly? StartDate { get; set; }
|
||||
public DateOnly? EndDate { get; set; }
|
||||
public int? DeviceId { get; set; }
|
||||
}
|
||||
}
|
13
DeviceContracts/SearchModels/StaffSearchModel.cs
Normal file
13
DeviceContracts/SearchModels/StaffSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using DeviceDataModels.Enums;
|
||||
namespace DeviceContracts.SearchModels
|
||||
{
|
||||
public class StaffSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
public string? Department { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public AccessLevel? AccessLevel { get; }
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/ICabinetStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/ICabinetStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface ICabinetStorage
|
||||
{
|
||||
List<CabinetViewModel> GetFullList();
|
||||
List<CabinetViewModel> GetFilteredList(CabinetSearchModel model);
|
||||
CabinetViewModel? GetElement(CabinetSearchModel model);
|
||||
CabinetViewModel? Insert(CabinetBindingModel model);
|
||||
CabinetViewModel? Update(CabinetBindingModel model);
|
||||
CabinetViewModel? Delete(CabinetBindingModel model);
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/IDeviceStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/IDeviceStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface IDeviceStorage
|
||||
{
|
||||
List<DeviceViewModel> GetFullList();
|
||||
List<DeviceViewModel> GetFilteredList(DeviceSearchModel model);
|
||||
DeviceViewModel? GetElement(DeviceSearchModel model);
|
||||
DeviceViewModel? Insert(DeviceBindingModel model);
|
||||
DeviceViewModel? Update(DeviceBindingModel model);
|
||||
DeviceViewModel? Delete(DeviceBindingModel model);
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/IKindStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/IKindStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface IKindStorage
|
||||
{
|
||||
List<KindViewModel> GetFullList();
|
||||
List<KindViewModel> GetFilteredList(KindSearchModel model);
|
||||
KindViewModel? GetElement(KindSearchModel model);
|
||||
KindViewModel? Insert(KindBindingModel model);
|
||||
KindViewModel? Update(KindBindingModel model);
|
||||
KindViewModel? Delete(KindBindingModel model);
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/IKitStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/IKitStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface IKitStorage
|
||||
{
|
||||
List<KitViewModel> GetFullList();
|
||||
List<KitViewModel> GetFilteredList(KitSearchModel model);
|
||||
KitViewModel? GetElement(KitSearchModel model);
|
||||
KitViewModel? Insert(KitBindingModel model);
|
||||
KitViewModel? Update(KitBindingModel model);
|
||||
KitViewModel? Delete(KitBindingModel model);
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/IServiceStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/IServiceStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface IServiceStorage
|
||||
{
|
||||
List<ServiceViewModel> GetFullList();
|
||||
List<ServiceViewModel> GetFilteredList(ServiceSearchModel model);
|
||||
ServiceViewModel? GetElement(ServiceSearchModel model);
|
||||
ServiceViewModel? Insert(ServiceBindingModel model);
|
||||
ServiceViewModel? Update(ServiceBindingModel model);
|
||||
ServiceViewModel? Delete(ServiceBindingModel model);
|
||||
}
|
||||
}
|
15
DeviceContracts/StoragesContracts/IStaffStorage.cs
Normal file
15
DeviceContracts/StoragesContracts/IStaffStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using DeviceContracts.BindingModels;
|
||||
using DeviceContracts.SearchModels;
|
||||
using DeviceContracts.ViewModels;
|
||||
namespace DeviceContracts.StoragesContracts
|
||||
{
|
||||
public interface IStaffStorage
|
||||
{
|
||||
List<StaffViewModel> GetFullList();
|
||||
List<StaffViewModel> GetFilteredList(StaffSearchModel model);
|
||||
StaffViewModel? GetElement(StaffSearchModel model);
|
||||
StaffViewModel? Insert(StaffBindingModel model);
|
||||
StaffViewModel? Update(StaffBindingModel model);
|
||||
StaffViewModel? Delete(StaffBindingModel model);
|
||||
}
|
||||
}
|
13
DeviceContracts/ViewModels/CabinetViewModel.cs
Normal file
13
DeviceContracts/ViewModels/CabinetViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class CabinetViewModel : ICabinetModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Кабинет")]
|
||||
public string Room { get; set; } = string.Empty;
|
||||
[DisplayName("Корпус")]
|
||||
public int Building { get; set; }
|
||||
}
|
||||
}
|
23
DeviceContracts/ViewModels/DeviceViewModel.cs
Normal file
23
DeviceContracts/ViewModels/DeviceViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class DeviceViewModel : IDeviceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Модель")]
|
||||
public string? Model { get; set; } = string.Empty;
|
||||
[DisplayName("Серийный номер")]
|
||||
public string? SerialNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Дата изготовления")]
|
||||
public DateOnly? ProductionDate { get; set; }
|
||||
[DisplayName("Гарантийный период")]
|
||||
public int? WarrantyPeriod { get; set; }
|
||||
[DisplayName("Работоспособность")]
|
||||
public bool Condition { get; set; }
|
||||
[DisplayName("Идентификатор вида")]
|
||||
public int KindId { get; set; }
|
||||
[DisplayName("Идентификатор комплекта")]
|
||||
public int? KitId { get; set; }
|
||||
}
|
||||
}
|
17
DeviceContracts/ViewModels/KindViewModel.cs
Normal file
17
DeviceContracts/ViewModels/KindViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class KindViewModel : IKindModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
[DisplayName("Частота обслуживания")]
|
||||
public int Frequency { get; set; }
|
||||
[DisplayName("Идентификатор вида")]
|
||||
public int KindId { get; set; }
|
||||
[DisplayName("Идентификатор комплекта")]
|
||||
public int? KitId { get; set; }
|
||||
}
|
||||
}
|
13
DeviceContracts/ViewModels/KitViewModel.cs
Normal file
13
DeviceContracts/ViewModels/KitViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class KitViewModel : IKitModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
[DisplayName("Идентификатор кабинета")]
|
||||
public int? CabinetId { get; set; }
|
||||
}
|
||||
}
|
17
DeviceContracts/ViewModels/ServiceViewModel.cs
Normal file
17
DeviceContracts/ViewModels/ServiceViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class ServiceViewModel : IServiceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[DisplayName("Дата начала")]
|
||||
public DateOnly StartDate { get; set; }
|
||||
[DisplayName("Дата конца")]
|
||||
public DateOnly? EndDate { get; set; }
|
||||
[DisplayName("Идентификатор устройства")]
|
||||
public int DeviceId { get; set; }
|
||||
}
|
||||
}
|
22
DeviceContracts/ViewModels/StaffViewModel.cs
Normal file
22
DeviceContracts/ViewModels/StaffViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using DeviceDataModels.Enums;
|
||||
using DeviceDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
namespace DeviceContracts.ViewModels
|
||||
{
|
||||
public class StaffViewModel : IStaffModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО")]
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
[DisplayName("Отдел")]
|
||||
public string Department { get; set; } = string.Empty;
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DisplayName("Уровень доступа")]
|
||||
public AccessLevel AccessLevel { get; }
|
||||
public Dictionary<int, IKitModel> Ownership { get; set; }
|
||||
= new();
|
||||
}
|
||||
}
|
9
DeviceDataModels/DeviceDataModels.csproj
Normal file
9
DeviceDataModels/DeviceDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
9
DeviceDataModels/Enums/AccessLevel.cs
Normal file
9
DeviceDataModels/Enums/AccessLevel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DeviceDataModels.Enums
|
||||
{
|
||||
public enum AccessLevel
|
||||
{
|
||||
Сотрудник = 0,
|
||||
Техник = 1,
|
||||
Админ = 2
|
||||
}
|
||||
}
|
7
DeviceDataModels/IId.cs
Normal file
7
DeviceDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace DeviceDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
8
DeviceDataModels/Models/ICabinetModel.cs
Normal file
8
DeviceDataModels/Models/ICabinetModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface ICabinetModel : IId
|
||||
{
|
||||
string Room { get; }
|
||||
int Building { get; }
|
||||
}
|
||||
}
|
13
DeviceDataModels/Models/IDeviceModel.cs
Normal file
13
DeviceDataModels/Models/IDeviceModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface IDeviceModel : IId
|
||||
{
|
||||
string Model { get; }
|
||||
string? SerialNumber { get; }
|
||||
DateOnly? ProductionDate { get; }
|
||||
int? WarrantyPeriod { get; }
|
||||
bool Condition { get; }
|
||||
int KindId { get; }
|
||||
int? KitId { get; }
|
||||
}
|
||||
}
|
8
DeviceDataModels/Models/IKindModel.cs
Normal file
8
DeviceDataModels/Models/IKindModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface IKindModel : IId
|
||||
{
|
||||
string Title { get; }
|
||||
int Frequency { get; }
|
||||
}
|
||||
}
|
8
DeviceDataModels/Models/IKitModel.cs
Normal file
8
DeviceDataModels/Models/IKitModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface IKitModel : IId
|
||||
{
|
||||
string Title { get; }
|
||||
int? CabinetId { get; }
|
||||
}
|
||||
}
|
10
DeviceDataModels/Models/IServiceModel.cs
Normal file
10
DeviceDataModels/Models/IServiceModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface IServiceModel : IId
|
||||
{
|
||||
string Description { get; }
|
||||
DateOnly StartDate { get; }
|
||||
DateOnly? EndDate { get; }
|
||||
int DeviceId { get; }
|
||||
}
|
||||
}
|
13
DeviceDataModels/Models/IStaffModel.cs
Normal file
13
DeviceDataModels/Models/IStaffModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using DeviceDataModels.Enums;
|
||||
namespace DeviceDataModels.Models
|
||||
{
|
||||
public interface IStaffModel : IId
|
||||
{
|
||||
string FullName { get; }
|
||||
string Department { get; }
|
||||
string Email { get; }
|
||||
string Password { get; }
|
||||
AccessLevel AccessLevel { get; }
|
||||
Dictionary<int, IKitModel> Ownership { get; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user