Интерфейсы + бизнес логика

This commit is contained in:
Artyom_Yashin 2024-03-20 19:49:36 +04:00
parent ef6afd92dc
commit a0aa9878f1
40 changed files with 1206 additions and 7 deletions

View File

@ -1,6 +0,0 @@
namespace BArberShopDataModels
{
public class Class1
{
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopDataModels
{
public interface IAppointmentModel : IId
{
int ClientId { get; }
int EmployeeId { get; }
int ServiceId { get; }
DateTime Time { get; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopDataModels
{
public interface IClientModel : IId
{
string ClientName { get; }
long ClientPhone { get; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopDataModels
{
public interface IComponentModel : IId
{
string ComponentName { get; }
int ComponentPrice { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopDataModels
{
public interface IEmployeeModel : IId
{
string EmployeeName { get; }
string EmployeePosition { get; }
long EmployeePhone { get; }
}
}

View File

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

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopDataModels
{
public interface IServiceModel : IId
{
string ServiceName { get; }
int ServicePrice { get; }
int ServiceTime { get; }
Dictionary<int, (IComponentModel, int)> ServiceComponents { get; }
}
}

View File

@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BArberShopDataModels", "BArberShopDataModels\BArberShopDataModels.csproj", "{D6E96E29-B162-47C6-B052-2F0FBA58C76F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarberShopDataModels", "BArberShopDataModels\BarberShopDataModels.csproj", "{D6E96E29-B162-47C6-B052-2F0FBA58C76F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarberShopContracts", "BarberShopContracts\BarberShopContracts.csproj", "{6F783D5D-D6EC-4AF7-95F0-9F08B8905D23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BarberShopBusinessLogic", "BarberShopBusinessLogic\BarberShopBusinessLogic.csproj", "{0BA98D0D-1658-4553-8A5E-B1B0D70E57F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +19,14 @@ Global
{D6E96E29-B162-47C6-B052-2F0FBA58C76F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6E96E29-B162-47C6-B052-2F0FBA58C76F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6E96E29-B162-47C6-B052-2F0FBA58C76F}.Release|Any CPU.Build.0 = Release|Any CPU
{6F783D5D-D6EC-4AF7-95F0-9F08B8905D23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F783D5D-D6EC-4AF7-95F0-9F08B8905D23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F783D5D-D6EC-4AF7-95F0-9F08B8905D23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F783D5D-D6EC-4AF7-95F0-9F08B8905D23}.Release|Any CPU.Build.0 = Release|Any CPU
{0BA98D0D-1658-4553-8A5E-B1B0D70E57F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BA98D0D-1658-4553-8A5E-B1B0D70E57F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BA98D0D-1658-4553-8A5E-B1B0D70E57F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BA98D0D-1658-4553-8A5E-B1B0D70E57F8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,107 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.BusinessLogicContracts;
using BarberShopContracts.SearchModels;
using BarberShopContracts.StorageContracts;
using BarberShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopBusinessLogic
{
public class AppointmentLogic : IAppointmentLogic
{
public readonly ILogger _logger;
public readonly IAppointmentStorage _appointmentStorage;
public AppointmentLogic(ILogger<AppointmentLogic> logger, IAppointmentStorage appointmentStorage)
{
_logger = logger;
_appointmentStorage = appointmentStorage;
}
public List<AppointmentViewModel>? ReadList(AppointmentSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _appointmentStorage.GetFullList() : _appointmentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public AppointmentViewModel? ReadElement(AppointmentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _appointmentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(AppointmentBindingModel model)
{
CheckModel(model);
if (_appointmentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(AppointmentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_appointmentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(AppointmentBindingModel model)
{
CheckModel(model);
if (_appointmentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(AppointmentBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.Time < DateTime.Now)
{
throw new ArgumentNullException("Некорректная дата", nameof(model.Time));
}
_logger.LogInformation("Time. Time:{Time}. Id: { Id}", model.Time, model.Id);
}
}
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BarberShopContracts\BarberShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,120 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.BusinessLogicContracts;
using BarberShopContracts.SearchModels;
using BarberShopContracts.StorageContracts;
using BarberShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopBusinessLogic
{
public class ClientLogic : IClientLogic
{
public readonly ILogger _logger;
public readonly IClientStorage _clientStorage;
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
{
_logger = logger;
_clientStorage = clientStorage;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. ClientName:{ClientName}.Id:{ Id}", model?.ClientName, 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 ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ClientName:{ClientName}.Id:{ Id}", model.ClientName, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public 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 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 ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ClientName))
{
throw new ArgumentNullException("Нет имени клиента",
nameof(model.ClientName));
}
if (model.ClientPhone < 80000000000)
{
throw new ArgumentNullException("Введен некорректный номер телефона", nameof(model.ClientPhone));
}
_logger.LogInformation("Client. ClientName:{ClientName}.ClientPhone:{ ClientPhone}. Id: { Id}", model.ClientName, model.ClientPhone, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{
ClientName = model.ClientName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,119 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.StorageContracts;
using BarberShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopBusinessLogic
{
public class ComponentLogic
{
public readonly ILogger _logger;
public readonly IComponentStorage _componentStorage;
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
{
_logger = logger;
_componentStorage = componentStorage;
}
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ComponentViewModel? ReadElement(ComponentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
var element = _componentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ComponentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_componentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(ComponentBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ComponentName))
{
throw new ArgumentNullException("Нет названия компонента",
nameof(model.ComponentName));
}
if (model.ComponentPrice <= 0)
{
throw new ArgumentNullException("Цена должна быть больше 0", nameof(model.ComponentPrice));
}
_logger.LogInformation("Component. ComponentName:{ComponentName}.ComponentPrice:{ ComponentPrice}. Id: { Id}", model.ComponentName, model.ComponentPrice, model.Id);
var element = _componentStorage.GetElement(new ComponentSearchModel
{
ComponentName = model.ComponentName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Компонент с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,120 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.BusinessLogicContracts;
using BarberShopContracts.SearchModels;
using BarberShopContracts.StorageContracts;
using BarberShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopBusinessLogic
{
public class EmployeeLogic : IEmployeeLogic
{
public readonly ILogger _logger;
public readonly IEmployeeStorage _employeeStorage;
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage employeeStorage)
{
_logger = logger;
_employeeStorage = employeeStorage;
}
public List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model)
{
_logger.LogInformation("ReadList. EmployeeName:{EmployeeName}.Id:{ Id}", model?.EmployeeName, 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 EmployeeViewModel? ReadElement(EmployeeSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. EmployeeName:{EmployeeName}.Id:{ Id}", model.EmployeeName, model.Id);
var element = _employeeStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
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 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;
}
if (string.IsNullOrEmpty(model.EmployeeName))
{
throw new ArgumentNullException("Нет имени сотрудника",
nameof(model.EmployeeName));
}
if (model.EmployeePhone < 80000000000)
{
throw new ArgumentNullException("Введен некорректный номер телефона", nameof(model.EmployeePhone));
}
_logger.LogInformation("employee. EmployeeName:{EmployeeName}.EmployeePhone:{ EmployeePhone}. Id: { Id}", model.EmployeeName, model.EmployeePhone, model.Id);
var element = _employeeStorage.GetElement(new EmployeeSearchModel
{
EmployeeName = model.EmployeeName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Сотрудник с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,124 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.BusinessLogicContracts;
using BarberShopContracts.SearchModels;
using BarberShopContracts.StorageContracts;
using BarberShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopBusinessLogic
{
public class ServiceLogic : IServiceLogic
{
public readonly ILogger _logger;
public readonly IServiceStorage _serviceStorage;
public ServiceLogic(ILogger<ServiceLogic> logger, IServiceStorage serviceStorage)
{
_logger = logger;
_serviceStorage = serviceStorage;
}
public List<ServiceViewModel>? ReadList(ServiceSearchModel? model)
{
_logger.LogInformation("ReadList. ServiceName:{ServiceName}.Id:{ Id}", model?.ServiceName, model?.Id);
var list = model == null ? _serviceStorage.GetFullList() : _serviceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ServiceViewModel? ReadElement(ServiceSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ServiceName:{ServiceName}.Id:{ Id}", model.ServiceName, model.Id);
var element = _serviceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ServiceBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ServiceBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_serviceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(ServiceBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(ServiceBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ServiceName))
{
throw new ArgumentNullException("Нет названия услуги",
nameof(model.ServiceName));
}
if (model.ServicePrice <= 0)
{
throw new ArgumentNullException("Цена должна быть больше 0", nameof(model.ServicePrice));
}
if (model.ServiceTime <= 0)
{
throw new ArgumentNullException("Время должно быть больше 0", nameof(model.ServiceTime));
}
_logger.LogInformation("Service. ServiceName:{ServiceName}.ServicePhone:{ ServicePhone}.ServiceTime:{ ServiceTime}. Id: { Id}", model.ServiceName, model.ServicePrice, model.ServiceTime, model.Id);
var element = _serviceStorage.GetElement(new ServiceSearchModel
{
ServiceName = model.ServiceName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Услуга с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BArberShopDataModels\BarberShopDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,22 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BindingModels
{
public class AppointmentBindingModel : IAppointmentModel
{
public int ClientId { get; set; }
public int EmployeeId { get; set; }
public int ServiceId { get; set; }
public DateTime Time { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BindingModels
{
public class ClientBindingModel : IClientModel
{
public int Id { get; set; }
public string ClientName { get; set; } = string.Empty;
public long ClientPhone { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public string ComponentName { get; set; } = string.Empty;
public int ComponentPrice { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BindingModels
{
public class EmployeeBindingModel : IEmployeeModel
{
public string EmployeeName { get; set; } = string.Empty;
public string EmployeePosition { get; set; } = string.Empty;
public long EmployeePhone { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BindingModels
{
public class ServiceBindingModel : IServiceModel
{
public string ServiceName { get; set; } = string.Empty;
public int ServicePrice { get; set; }
public int ServiceTime { get; set; }
public int Id { get; set; }
public Dictionary<int, (IComponentModel, int)> ServiceComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,20 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BusinessLogicContracts
{
public interface IAppointmentLogic
{
List<AppointmentViewModel>? ReadList(AppointmentSearchModel? model);
AppointmentViewModel? ReadElement(AppointmentSearchModel model);
bool Create(AppointmentBindingModel model);
bool Update(AppointmentBindingModel model);
bool Delete(AppointmentBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BusinessLogicContracts
{
public interface IClientLogic
{
List<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BusinessLogicContracts
{
public interface IComponentLogic
{
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BusinessLogicContracts
{
public interface IEmployeeLogic
{
List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model);
EmployeeViewModel? ReadElement(EmployeeSearchModel model);
bool Create(EmployeeBindingModel model);
bool Update(EmployeeBindingModel model);
bool Delete(EmployeeBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.BusinessLogicContracts
{
public interface IServiceLogic
{
List<ServiceViewModel>? ReadList(ServiceSearchModel? model);
ServiceViewModel? ReadElement(ServiceSearchModel model);
bool Create(ServiceBindingModel model);
bool Update(ServiceBindingModel model);
bool Delete(ServiceBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.SearchModels
{
public class AppointmentSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.SearchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
public string? ClientName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.SearchModels
{
public class EmployeeSearchModel
{
public int? Id { get; set; }
public string? EmployeeName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.SearchModels
{
public class ServiceSearchModel
{
public int? Id { get; set; }
public string? ServiceName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.StorageContracts
{
public interface IAppointmentStorage
{
List<AppointmentViewModel> GetFullList();
List<AppointmentViewModel> GetFilteredList(AppointmentSearchModel model);
AppointmentViewModel? GetElement(AppointmentSearchModel model);
AppointmentViewModel? Insert(AppointmentBindingModel model);
AppointmentViewModel? Update(AppointmentBindingModel model);
AppointmentViewModel? Delete(AppointmentBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.StorageContracts
{
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.SearchModels;
using BarberShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.StorageContracts
{
public interface IComponentStorage
{
List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model);
}
}

View File

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

View File

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

View File

@ -0,0 +1,26 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.ViewModels
{
public class AppointmentViewModel : IAppointmentModel
{
public int Id { get; set; }
public int ClientId { get; set; }
[DisplayName("Имя клиента")]
public string ClientName { get; set; } = string.Empty;
public int EmployeeId { get; set; }
[DisplayName("Имя сотрудника")]
public string EmployeeName { get; set; } = string.Empty;
public int ServiceId { get; set; }
[DisplayName("Услуга")]
public string ServiceName { get; set; } = string.Empty;
public DateTime Time { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string ClientName { get; set; } = string.Empty;
[DisplayName("Телефон")]
public long ClientPhone { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
[DisplayName("Название")]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")]
public int ComponentPrice { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.ViewModels
{
public class EmployeeViewModel : IEmployeeModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string EmployeeName { get; set; } = string.Empty;
[DisplayName("Должность")]
public string EmployeePosition { get; set; } = string.Empty;
[DisplayName("Телефон")]
public long EmployeePhone { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using BarberShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarberShopContracts.ViewModels
{
public class ServiceViewModel : IServiceModel
{
public int Id { get; set; }
[DisplayName("Услуга")]
public string ServiceName { get; set; } = string.Empty;
[DisplayName("Цена")]
public int ServicePrice { get; set; }
[DisplayName("Длительность (мин)")]
public int ServiceTime { get; set; }
public Dictionary<int, (IComponentModel, int)> ServiceComponents { get; set; } = new();
}
}