From 29578db964ca61f7daffcf5f6172106aa23eb77d Mon Sep 17 00:00:00 2001 From: georgiy semikolenov Date: Sat, 8 Apr 2023 15:04:58 +0400 Subject: [PATCH] done --- .../ServiceStation.sln | 49 ++++++ .../BusinessLogics/CarLogic.cs | 112 ++++++++++++++ .../BusinessLogics/EmployerLogic.cs | 111 +++++++++++++ .../BusinessLogics/MaintenanceLogic.cs | 99 ++++++++++++ .../BusinessLogics/ReportLogic.cs | 59 +++++++ .../BusinessLogics/ServiceLogic.cs | 91 +++++++++++ .../BusinessLogics/SpareLogic.cs | 109 +++++++++++++ .../BusinessLogics/StorekeeperLogic.cs | 113 ++++++++++++++ .../BusinessLogics/WorkDurationLogic.cs | 96 ++++++++++++ .../BusinessLogics/WorkLogic.cs | 108 +++++++++++++ .../ServiceStationBusinessLogic.csproj | 26 ++++ .../BindingModels/CarBindingModel.cs | 14 ++ .../BindingModels/EmployerBindingModel.cs | 12 ++ .../BindingModels/MaintenanceBindingModel.cs | 13 ++ .../BindingModels/ReportBindingModel.cs | 15 ++ .../BindingModels/ServiceBindingModel.cs | 10 ++ .../BindingModels/SpareBindingModel.cs | 13 ++ .../BindingModels/StorekeeperBindingModel.cs | 15 ++ .../BindingModels/WorkBindingModel.cs | 23 +++ .../BindingModels/WorkDurationBindingModel.cs | 11 ++ .../BusinessLogicsContracts/ICarLogic.cs | 15 ++ .../BusinessLogicsContracts/IEmployerLogic.cs | 15 ++ .../IMaintenanceLogic.cs | 15 ++ .../BusinessLogicsContracts/IReportLogic.cs | 13 ++ .../BusinessLogicsContracts/IServiceLogic.cs | 15 ++ .../BusinessLogicsContracts/ISpareLogic.cs | 15 ++ .../IStorekeeperLogic.cs | 15 ++ .../IWorkDurationLogic.cs | 15 ++ .../BusinessLogicsContracts/IWorkLogic.cs | 15 ++ .../SearchModels/CarSearchModel.cs | 10 ++ .../SearchModels/EmployerSearchModel.cs | 10 ++ .../SearchModels/MaintenanceSearchModel.cs | 11 ++ .../SearchModels/ServiceSearchModel.cs | 8 + .../SearchModels/SpareSearchModel.cs | 13 ++ .../SearchModels/StorekeeperSearchModel.cs | 15 ++ .../SearchModels/WorkDurationSearchModel.cs | 11 ++ .../SearchModels/WorkSearchModel.cs | 21 +++ .../ServiceStationContracts.csproj | 13 ++ .../StoragesContracts/ICarStorage.cs | 18 +++ .../StoragesContracts/IEmployerStorage.cs | 16 ++ .../StoragesContracts/IMaintenanceStorage.cs | 18 +++ .../StoragesContracts/IServiceStorage.cs | 16 ++ .../StoragesContracts/ISpareStorage.cs | 16 ++ .../StoragesContracts/IStorekeeperStorage.cs | 16 ++ .../StoragesContracts/IWorkDurationStorage.cs | 16 ++ .../StoragesContracts/IWorkStorage.cs | 16 ++ .../ViewModels/CarViewModel.cs | 20 +++ .../ViewModels/EmployerViewModel.cs | 16 ++ .../ViewModels/MaintenanceViewModel.cs | 16 ++ .../ViewModels/ReportViewModel.cs | 10 ++ .../ViewModels/ServiceViewModel.cs | 12 ++ .../ViewModels/SpareViewModel.cs | 15 ++ .../ViewModels/StorekeeperViewModel.cs | 16 ++ .../ViewModels/WorkDurationViewModel.cs | 12 ++ .../ViewModels/WorkViewModel.cs | 22 +++ .../ServiceStationDataModels/IId.cs | 7 + .../Models/ICarModel.cs | 10 ++ .../Models/IEmployerModel.cs | 10 ++ .../Models/IMaintenanceModel.cs | 10 ++ .../Models/IServiceModel.cs | 7 + .../Models/ISpareModel.cs | 9 ++ .../Models/IStorekeeperModel.cs | 10 ++ .../Models/IWorkDurationModel.cs | 7 + .../Models/IWorkModel.cs | 16 ++ .../ServiceStationDataModels.csproj | 19 +++ .../Implements/CarStorage.cs | 96 ++++++++++++ .../Implements/EmployerStorage.cs | 79 ++++++++++ .../Implements/MaintenanceStorage.cs | 116 ++++++++++++++ .../Implements/ServiceStorage.cs | 85 ++++++++++ .../Implements/SpareStorage.cs | 72 +++++++++ .../Implements/StorekeeperStorage.cs | 79 ++++++++++ .../Implements/WorkDurationStorage.cs | 72 +++++++++ .../Implements/WorkStorage.cs | 78 ++++++++++ .../Models/Car.cs | 92 +++++++++++ .../Models/CarSpare.cs | 21 +++ .../Models/Employer.cs | 48 ++++++ .../Models/Maintenance.cs | 92 +++++++++++ .../Models/MaintenanceCar.cs | 21 +++ .../Models/Service.cs | 32 ++++ .../Models/Spare.cs | 43 ++++++ .../Models/Storekeeper.cs | 48 ++++++ .../Models/Work.cs | 146 ++++++++++++++++++ .../Models/WorkDuration.cs | 37 +++++ .../Models/WorkMaintence.cs | 23 +++ .../Models/WorkSpare.cs | 23 +++ .../ServiceStationDatabase.cs | 30 ++++ .../ServiceStationDatabaseImplement.csproj | 23 +++ .../ServiceStationView/Form1.Designer.cs | 46 ++++++ .../ServiceStationView/Form1.cs | 15 ++ .../ServiceStationView/Form1.resx | 60 +++++++ .../ServiceStationView/Program.cs | 40 +++++ .../ServiceStationView.csproj | 26 ++++ 92 files changed, 3263 insertions(+) create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStation.sln create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/CarLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/EmployerLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/MaintenanceLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ServiceLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/SpareLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/StorekeeperLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkDurationLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/ServiceStationBusinessLogic.csproj create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/CarBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/EmployerBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/MaintenanceBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ReportBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ServiceBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/SpareBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/StorekeeperBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkDurationBindingModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ICarLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IEmployerLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IMaintenanceLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IServiceLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ISpareLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IStorekeeperLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkDurationLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkLogic.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/CarSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/EmployerSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/MaintenanceSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/ServiceSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/SpareSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/StorekeeperSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkDurationSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkSearchModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ICarStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IEmployerStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IMaintenanceStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IServiceStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ISpareStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IStorekeeperStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkDurationStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/CarViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/EmployerViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/MaintenanceViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ReportViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ServiceViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/SpareViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/StorekeeperViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkDurationViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkViewModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/IId.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ICarModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IEmployerModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IMaintenanceModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IServiceModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ISpareModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IStorekeeperModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkDurationModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkModel.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/ServiceStationDataModels.csproj create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/CarStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/EmployerStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/MaintenanceStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/ServiceStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/SpareStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/StorekeeperStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkDurationStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkStorage.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Car.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/CarSpare.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Employer.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Maintenance.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/MaintenanceCar.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Service.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Spare.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Storekeeper.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Work.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkDuration.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkMaintence.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkSpare.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabaseImplement.csproj create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.Designer.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.resx create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Program.cs create mode 100644 Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/ServiceStationView.csproj diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStation.sln b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStation.sln new file mode 100644 index 0000000..41c13ba --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStation.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationView", "ServiceStationView\ServiceStationView.csproj", "{57B42CA9-DC03-4705-BCDA-4B367028857E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationDataModels", "ServiceStationDataModels\ServiceStationDataModels.csproj", "{A3F34BD4-4F04-4E21-8C8B-115E681957E8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationContracts", "ServiceStationContracts\ServiceStationContracts.csproj", "{F5B0E7C1-7436-43A3-A497-21FA04882360}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationBusinessLogic", "ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj", "{90FBC077-24C7-4EF8-8AC9-172AB6A7DC8C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationDatabaseImplement", "ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj", "{E6195FD3-5524-4AD7-A387-4925559485CE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57B42CA9-DC03-4705-BCDA-4B367028857E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57B42CA9-DC03-4705-BCDA-4B367028857E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57B42CA9-DC03-4705-BCDA-4B367028857E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57B42CA9-DC03-4705-BCDA-4B367028857E}.Release|Any CPU.Build.0 = Release|Any CPU + {A3F34BD4-4F04-4E21-8C8B-115E681957E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3F34BD4-4F04-4E21-8C8B-115E681957E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3F34BD4-4F04-4E21-8C8B-115E681957E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3F34BD4-4F04-4E21-8C8B-115E681957E8}.Release|Any CPU.Build.0 = Release|Any CPU + {F5B0E7C1-7436-43A3-A497-21FA04882360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5B0E7C1-7436-43A3-A497-21FA04882360}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5B0E7C1-7436-43A3-A497-21FA04882360}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5B0E7C1-7436-43A3-A497-21FA04882360}.Release|Any CPU.Build.0 = Release|Any CPU + {90FBC077-24C7-4EF8-8AC9-172AB6A7DC8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90FBC077-24C7-4EF8-8AC9-172AB6A7DC8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90FBC077-24C7-4EF8-8AC9-172AB6A7DC8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90FBC077-24C7-4EF8-8AC9-172AB6A7DC8C}.Release|Any CPU.Build.0 = Release|Any CPU + {E6195FD3-5524-4AD7-A387-4925559485CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6195FD3-5524-4AD7-A387-4925559485CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6195FD3-5524-4AD7-A387-4925559485CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6195FD3-5524-4AD7-A387-4925559485CE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4E0AA942-CAF9-486C-9B34-FAC331F8F845} + EndGlobalSection +EndGlobal diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/CarLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/CarLogic.cs new file mode 100644 index 0000000..13e3c59 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/CarLogic.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class CarLogic : ICarLogic + { + private readonly ILogger _logger; + private readonly ICarStorage _carStorage; + public CarLogic(ILogger logger, ICarStorage carStorage) + { + _logger = logger; + _carStorage = carStorage; + } + public List? ReadList(CarSearchModel? model) + { + _logger.LogInformation("ReadList.CarId:{ CarId}", model?.Id); + var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public CarViewModel? ReadElement(CarSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. CarId:{ CarId}", model?.Id); + var element = _carStorage.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(CarBindingModel model) + { + CheckModel(model); + if (_carStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(CarBindingModel model) + { + CheckModel(model); + if (_carStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(CarBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_carStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(CarBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Brand)) + { + throw new ArgumentNullException("Нет бренда автомобиля", nameof(model.Brand)); + } + if (string.IsNullOrEmpty(model.Model)) + { + throw new ArgumentNullException("Нет модели автомобиля", nameof(model.Model)); + } + if (string.IsNullOrEmpty(model.VIN)) + { + throw new ArgumentNullException("Нет VIN автомобиля", nameof(model.Model)); + } + var element = _carStorage.GetElement(new CarSearchModel + { + VIN = model.VIN + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Автомобиль с таким VIN уже есть"); + } + _logger.LogInformation("Car. Id:{ Id}.CarBrand:{CarBrand}.CarModel:{CarModel}.CarVIN:{CarVIN}", model?.Id, model?.Brand, model?.Brand, model?.VIN); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/EmployerLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/EmployerLogic.cs new file mode 100644 index 0000000..8863a7b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/EmployerLogic.cs @@ -0,0 +1,111 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class EmployerLogic : IEmployerLogic + { + private readonly ILogger _logger; + private readonly IEmployerStorage _employerStorage; + public EmployerLogic(ILogger logger, IEmployerStorage employerStorage) + { + _logger = logger; + _employerStorage = employerStorage; + } + public List? ReadList(EmployerSearchModel? model) + { + _logger.LogInformation("ReadList. EmployerId:{ EmployerId}", model?.Id); + var list = model == null ? _employerStorage.GetFullList() : _employerStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public EmployerViewModel? ReadElement(EmployerSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. EmployerId:{ EmployerId}", model?.Id); + var element = _employerStorage.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(EmployerBindingModel model) + { + CheckModel(model); + if (_employerStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(EmployerBindingModel model) + { + CheckModel(model); + if (_employerStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(EmployerBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_employerStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(EmployerBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Login)) + { + throw new ArgumentNullException("Нет логина работника", nameof(model.Login)); + } + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Нет почты работника", nameof(model.Email)); + } + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Нет пароля работника", nameof(model.Password)); + } + var element = _employerStorage.GetElement(new EmployerSearchModel + { + Login = model.Login + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("работник с таким логином уже есть"); + } + _logger.LogInformation("Employer. EmployerId:{ Id}.EmployerLogin:{EmployerLogin}.EmployerEmail:{EmployerEmail}", model?.Id, model?.Login, model?.Email); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/MaintenanceLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/MaintenanceLogic.cs new file mode 100644 index 0000000..6ab82bb --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/MaintenanceLogic.cs @@ -0,0 +1,99 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class MaintenanceLogic : IMaintenanceLogic + { + private readonly ILogger _logger; + private readonly IMaintenanceStorage _maintenanceStorage; + public MaintenanceLogic(ILogger logger, IMaintenanceStorage maintenanceStorage) + { + _logger = logger; + _maintenanceStorage = maintenanceStorage; + } + public List? ReadList(MaintenanceSearchModel? model) + { + _logger.LogInformation("ReadList. MaintenanceId:{ MaintenanceId}", model?.Id); + var list = model == null ? _maintenanceStorage.GetFullList() : _maintenanceStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public MaintenanceViewModel? ReadElement(MaintenanceSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. MaintenanceId:{ MaintenanceId}", model?.Id); + var element = _maintenanceStorage.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(MaintenanceBindingModel model) + { + CheckModel(model); + if (_maintenanceStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(MaintenanceBindingModel model) + { + CheckModel(model); + if (_maintenanceStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(MaintenanceBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_maintenanceStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(MaintenanceBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.EmployerId<0) + { + throw new ArgumentNullException("Некорректный идентификатор работника", nameof(model.EmployerId)); + } + if (model.Cost<=0) + { + throw new ArgumentNullException("Стоимость должна быть больше нуля", nameof(model.Cost)); + } + _logger.LogInformation("Maintenance. MaintenanceId:{MaintenanceId}.EmployerId: { EmployerId}.Cost:{Cost}", model.Id, model.EmployerId, model.Cost); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ReportLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ReportLogic.cs new file mode 100644 index 0000000..eee900c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ReportLogic.cs @@ -0,0 +1,59 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using System.Security.Cryptography.X509Certificates; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class ReportLogic : IReportLogic + { + private readonly IMaintenanceStorage _maintenanceStorage; + private readonly ISpareStorage _spareStorage; + private readonly ICarStorage _carStorage; + public ReportLogic(IMaintenanceStorage maintenanceStorage, ISpareStorage spareStorage, ICarStorage carStorage) + { + _carStorage = carStorage; + _maintenanceStorage = maintenanceStorage; + _spareStorage = spareStorage; + } + public List GetCarsAndSpares(ReportBindingModel model) + { + var maintenances = _maintenanceStorage.GetFilteredList(new MaintenanceSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }); + var result = new List(); + foreach (var maintenance in maintenances) { + var cars = _maintenanceStorage.GetMaintenaceCars(new MaintenanceSearchModel { Id = maintenance.Id }).ToList(); + List cars_spares = new List(); + foreach (var car in cars) + { + var spare = _maintenanceStorage.GetCarsSpares(new MaintenanceSearchModel { Id = maintenance.Id }, new CarSearchModel { Id = car.Id }).Select(x => x.Name).ToList(); + cars_spares.AddRange(spare); + } + result.Add(new ReportViewModel + { + Cost = maintenance.Cost, + Spares = cars_spares, + Cars = cars.Select(x => x.VIN).ToList() + + }); + } + return result; + } + + public void SaveToPdfFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveToExcelFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveToWordFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ServiceLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ServiceLogic.cs new file mode 100644 index 0000000..c21a57e --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ServiceLogic.cs @@ -0,0 +1,91 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class ServiceLogic : IServiceLogic + { + private readonly ILogger _logger; + private readonly IServiceStorage _serviceStorage; + public ServiceLogic(ILogger logger, IServiceStorage serviceStorage) + { + _logger = logger; + _serviceStorage = serviceStorage; + } + public List? ReadList(ServiceSearchModel? model) + { + _logger.LogInformation("ReadList. ServiceId:{ ServiceId}", 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. ServiceId:{ ServiceId}", 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 Update(ServiceBindingModel model) + { + CheckModel(model); + if (_serviceStorage.Update(model) == null) + { + _logger.LogWarning("Update 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; + } + private void CheckModel(ServiceBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("Service. ServiceId: { ServiceId}.", model.Id); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/SpareLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/SpareLogic.cs new file mode 100644 index 0000000..5658243 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/SpareLogic.cs @@ -0,0 +1,109 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class SpareLogic : ISpareLogic + { + private readonly ILogger _logger; + private readonly ISpareStorage _spareStorage; + public SpareLogic(ILogger logger, ISpareStorage spareStorage) + { + _logger = logger; + _spareStorage = spareStorage; + } + public List? ReadList(SpareSearchModel? model) + { + _logger.LogInformation("ReadList.SpareId:{Id}", model?.Id); + var list = model == null ? _spareStorage.GetFullList() : _spareStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public SpareViewModel? ReadElement(SpareSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. SpareId:{Id}", model?.Id); + var element = _spareStorage.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(SpareBindingModel model) + { + CheckModel(model); + if (_spareStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(SpareBindingModel model) + { + CheckModel(model); + if (_spareStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(SpareBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_spareStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(SpareBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Name)) + { + throw new ArgumentNullException("Нет название детали", nameof(model.Name)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Неправильная цена детали", nameof(model.Price)); + } + + var element = _spareStorage.GetElement(new SpareSearchModel + { + Name = model.Name + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Деталь с таким названием уже есть"); + } + _logger.LogInformation("Spare. Id:{ Id}.Name:{Name}.Price:{Price}", model?.Id, model?.Name, model?.Price); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/StorekeeperLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/StorekeeperLogic.cs new file mode 100644 index 0000000..9c310c8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/StorekeeperLogic.cs @@ -0,0 +1,113 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class StorekeeperLogic : IStorekeeperLogic + { + private readonly ILogger _logger; + private readonly IStorekeeperStorage _storekeeperStorage; + public StorekeeperLogic(ILogger logger, IStorekeeperStorage storekeeperStorage) + { + _logger = logger; + _storekeeperStorage = storekeeperStorage; + } + public List? ReadList(StorekeeperSearchModel? model) + { + _logger.LogInformation("ReadList.StorekeeperId:{Id}", model?.Id); + var list = model == null ? _storekeeperStorage.GetFullList() : _storekeeperStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public StorekeeperViewModel? ReadElement(StorekeeperSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. StorekeeperId:{Id}", model?.Id); + var element = _storekeeperStorage.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(StorekeeperBindingModel model) + { + CheckModel(model); + if (_storekeeperStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(StorekeeperBindingModel model) + { + CheckModel(model); + if (_storekeeperStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(StorekeeperBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_storekeeperStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(StorekeeperBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Login)) + { + throw new ArgumentNullException("Нет логина кладовщика", nameof(model.Login)); + } + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Нет пароля кладовщика", nameof(model.Password)); + } + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Нет почты кладовщика", nameof(model.Email)); + } + var element = _storekeeperStorage.GetElement(new StorekeeperSearchModel + { + Login = model.Login, + Email = model.Email + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Кладовщик с такими параметрами уже есть"); + } + _logger.LogInformation("Storekeeper. Id:{ Id}.Login:{Login}.Email:{Email}.Password:{Password}", model?.Id, model?.Login, model?.Email, model?.Password); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkDurationLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkDurationLogic.cs new file mode 100644 index 0000000..1c20c6b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkDurationLogic.cs @@ -0,0 +1,96 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class WorkDurationLogic : IWorkDurationLogic + { + private readonly ILogger _logger; + private readonly IWorkDurationStorage _workDurationStorage; + public WorkDurationLogic(ILogger logger, IWorkDurationStorage workDurationStorage) + { + _logger = logger; + _workDurationStorage = workDurationStorage; + } + public List? ReadList(WorkDurationSearchModel? model) + { + _logger.LogInformation("ReadList.WorkDurationId:{Id}", model?.Id); + var list = model == null ? _workDurationStorage.GetFullList() : _workDurationStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public WorkDurationViewModel? ReadElement(WorkDurationSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. WorkDurationId:{Id}", model?.Id); + var element = _workDurationStorage.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(WorkDurationBindingModel model) + { + CheckModel(model); + if (_workDurationStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(WorkDurationBindingModel model) + { + CheckModel(model); + if (_workDurationStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(WorkDurationBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_workDurationStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(WorkDurationBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Duration < 0) + { + throw new ArgumentNullException("Нет длительности", nameof(model.Duration)); + } + _logger.LogInformation("WorkDuration. Id:{ Id}.Duration:{Duration}", model?.Id, model?.Duration); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkLogic.cs new file mode 100644 index 0000000..3a67f96 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/BusinessLogics/WorkLogic.cs @@ -0,0 +1,108 @@ +using Microsoft.Extensions.Logging; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationBusinessLogic.BusinessLogics +{ + public class WorkLogic : IWorkLogic + { + private readonly ILogger _logger; + private readonly IWorkStorage _workStorage; + public WorkLogic(ILogger logger, IWorkStorage workStorage) + { + _logger = logger; + _workStorage = workStorage; + } + public List? ReadList(WorkSearchModel? model) + { + _logger.LogInformation("ReadList.WorkId:{Id}", model?.Id); + var list = model == null ? _workStorage.GetFullList() : _workStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public WorkViewModel? ReadElement(WorkSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. WorkId:{ Id}", model?.Id); + var element = _workStorage.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(WorkBindingModel model) + { + CheckModel(model); + if (_workStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(WorkBindingModel model) + { + CheckModel(model); + if (_workStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(WorkBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_workStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(WorkBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Title)) + { + throw new ArgumentNullException("Нет названия работы", nameof(model.Title)); + } + if (model.Price < 0) + { + throw new ArgumentNullException("Нет цены работы", nameof(model.Price)); + } + var element = _workStorage.GetElement(new WorkSearchModel + { + Title = model.Title, + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Работа с таким именем уже есть"); + } + _logger.LogInformation("Work. Id:{ Id}.Title:{Title}.Price:{Price}", model?.Id, model?.Title, model?.Price); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/ServiceStationBusinessLogic.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/ServiceStationBusinessLogic.csproj new file mode 100644 index 0000000..c0f88d3 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationBusinessLogic/ServiceStationBusinessLogic.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + + + + diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/CarBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/CarBindingModel.cs new file mode 100644 index 0000000..e7775bc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/CarBindingModel.cs @@ -0,0 +1,14 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class CarBindingModel : ICarModel + { + public int Id { get; set; } + public string Brand { get; set; } = string.Empty; + public string Model { get; set; } = string.Empty; + public string VIN { get; set; } = string.Empty; + public Dictionary CarSpares { get; set; } = new(); + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/EmployerBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/EmployerBindingModel.cs new file mode 100644 index 0000000..09cf245 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/EmployerBindingModel.cs @@ -0,0 +1,12 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class EmployerBindingModel : IEmployerModel + { + public int Id { get; set; } + public string Login { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/MaintenanceBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/MaintenanceBindingModel.cs new file mode 100644 index 0000000..252c4bd --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/MaintenanceBindingModel.cs @@ -0,0 +1,13 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class MaintenanceBindingModel : IMaintenanceModel + { + public int Id { get; set; } + public int EmployerId { get; set; } + public double Cost { get; set; } + public DateTime DateCreate { get; set; } + public Dictionary MaintenanceCars { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ReportBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..55b6e2b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ServiceBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ServiceBindingModel.cs new file mode 100644 index 0000000..6189f79 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/ServiceBindingModel.cs @@ -0,0 +1,10 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class ServiceBindingModel : IServiceModel + { + public int Id { get; set; } + public string ServiceDescription { get; set; }=string.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/SpareBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/SpareBindingModel.cs new file mode 100644 index 0000000..1e27cc8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/SpareBindingModel.cs @@ -0,0 +1,13 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class SpareBindingModel : ISpareModel + { + public int Id { get; set; } + + public string Name { get; set; } = String.Empty; + + public double Price { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/StorekeeperBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/StorekeeperBindingModel.cs new file mode 100644 index 0000000..adefd80 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/StorekeeperBindingModel.cs @@ -0,0 +1,15 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class StorekeeperBindingModel : IStorekeeperModel + { + public int Id { get; set; } + + public string Login { get; set; } = String.Empty; + + public string Password { get; set; } = String.Empty; + + public string Email { get; set; } = String.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkBindingModel.cs new file mode 100644 index 0000000..c3f0fbf --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkBindingModel.cs @@ -0,0 +1,23 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class WorkBindingModel : IWorkModel + { + public int Id { get; set; } + + public string Title { get; set; } = String.Empty; + + public double Price { get; set; } + + public int StorekeeperId { get; set; } + + public int DurationId { get; set; } + + public Dictionary WorkSpares { get; set; } = new(); + + public Dictionary WorkMaintences { get; set; } = new(); + + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkDurationBindingModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkDurationBindingModel.cs new file mode 100644 index 0000000..bb200c4 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BindingModels/WorkDurationBindingModel.cs @@ -0,0 +1,11 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.BindingModels +{ + public class WorkDurationBindingModel : IWorkDurationModel + { + public int Id { get; set; } + + public int Duration { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ICarLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ICarLogic.cs new file mode 100644 index 0000000..70fc66a --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ICarLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface ICarLogic + { + List? ReadList(CarSearchModel? model); + CarViewModel? ReadElement(CarSearchModel? model); + bool Create(CarBindingModel model); + bool Update(CarBindingModel model); + bool Delete(CarBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IEmployerLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IEmployerLogic.cs new file mode 100644 index 0000000..ca45e88 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IEmployerLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IEmployerLogic + { + List? ReadList(EmployerSearchModel? model); + EmployerViewModel? ReadElement(EmployerSearchModel? model); + bool Create(EmployerBindingModel model); + bool Update(EmployerBindingModel model); + bool Delete(EmployerBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IMaintenanceLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IMaintenanceLogic.cs new file mode 100644 index 0000000..42ee532 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IMaintenanceLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IMaintenanceLogic + { + List? ReadList(MaintenanceSearchModel? model); + MaintenanceViewModel? ReadElement(MaintenanceSearchModel? model); + bool Create(MaintenanceBindingModel model); + bool Update(MaintenanceBindingModel model); + bool Delete(MaintenanceBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IReportLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IReportLogic.cs new file mode 100644 index 0000000..7c50808 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IReportLogic.cs @@ -0,0 +1,13 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IReportLogic + { + List GetCarsAndSpares(ReportBindingModel model); + void SaveToWordFile(ReportBindingModel model); + void SaveToExcelFile(ReportBindingModel model); + void SaveToPdfFile(ReportBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IServiceLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IServiceLogic.cs new file mode 100644 index 0000000..c32b7f1 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IServiceLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IServiceLogic + { + List? ReadList(ServiceSearchModel? model); + ServiceViewModel? ReadElement(ServiceSearchModel? model); + bool Create(ServiceBindingModel model); + bool Update(ServiceBindingModel model); + bool Delete(ServiceBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ISpareLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ISpareLogic.cs new file mode 100644 index 0000000..9dba873 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/ISpareLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface ISpareLogic + { + List? ReadList(SpareSearchModel? model); + SpareViewModel? ReadElement(SpareSearchModel? model); + bool Create(SpareBindingModel model); + bool Update(SpareBindingModel model); + bool Delete(SpareBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IStorekeeperLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IStorekeeperLogic.cs new file mode 100644 index 0000000..026afc2 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IStorekeeperLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IStorekeeperLogic + { + List? ReadList(StorekeeperSearchModel? model); + StorekeeperViewModel? ReadElement(StorekeeperSearchModel? model); + bool Create(StorekeeperBindingModel model); + bool Update(StorekeeperBindingModel model); + bool Delete(StorekeeperBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkDurationLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkDurationLogic.cs new file mode 100644 index 0000000..f1a4488 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkDurationLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IWorkDurationLogic + { + List? ReadList(WorkDurationSearchModel? model); + WorkDurationViewModel? ReadElement(WorkDurationSearchModel? model); + bool Create(WorkDurationBindingModel model); + bool Update(WorkDurationBindingModel model); + bool Delete(WorkDurationBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkLogic.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkLogic.cs new file mode 100644 index 0000000..78b050b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/BusinessLogicsContracts/IWorkLogic.cs @@ -0,0 +1,15 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.BusinessLogicsContracts +{ + public interface IWorkLogic + { + List? ReadList(WorkSearchModel? model); + WorkViewModel? ReadElement(WorkSearchModel? model); + bool Create(WorkBindingModel model); + bool Update(WorkBindingModel model); + bool Delete(WorkBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/CarSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/CarSearchModel.cs new file mode 100644 index 0000000..ed17286 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/CarSearchModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationContracts.SearchModels +{ + public class CarSearchModel + { + public int? Id { get; set; } + public string? Brand { get; set; } + public string? Model { get; set; } + public string? VIN { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/EmployerSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/EmployerSearchModel.cs new file mode 100644 index 0000000..124ef70 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/EmployerSearchModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationContracts.SearchModels +{ + public class EmployerSearchModel + { + public int? Id { get; set; } + public string? Login { get; set; } + public string? Password { get; set; } + public string? Email { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/MaintenanceSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/MaintenanceSearchModel.cs new file mode 100644 index 0000000..abf37a3 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/MaintenanceSearchModel.cs @@ -0,0 +1,11 @@ +namespace ServiceStationContracts.SearchModels +{ + public class MaintenanceSearchModel + { + public int? Id { get; set; } + public int? EmployerId { get; set; } + public double? Cost { get; set; } + public DateTime? DateTo { get; set; } + public DateTime? DateFrom { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/ServiceSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/ServiceSearchModel.cs new file mode 100644 index 0000000..d0785dc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/ServiceSearchModel.cs @@ -0,0 +1,8 @@ +namespace ServiceStationContracts.SearchModels +{ + public class ServiceSearchModel + { + public int? Id { get; set; } + public string? ServiceDescription { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/SpareSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/SpareSearchModel.cs new file mode 100644 index 0000000..f6b7573 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/SpareSearchModel.cs @@ -0,0 +1,13 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.SearchModels +{ + public class SpareSearchModel + { + public int? Id { get; set; } + + public string? Name { get; set; } + + public double? Price { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/StorekeeperSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/StorekeeperSearchModel.cs new file mode 100644 index 0000000..b4649a9 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/StorekeeperSearchModel.cs @@ -0,0 +1,15 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.SearchModels +{ + public class StorekeeperSearchModel + { + public int? Id { get; set; } + + public string? Login { get; set; } + + public string? Password { get; set; } + + public string? Email { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkDurationSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkDurationSearchModel.cs new file mode 100644 index 0000000..c08eb95 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkDurationSearchModel.cs @@ -0,0 +1,11 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.SearchModels +{ + public class WorkDurationSearchModel + { + public int? Id { get; set; } + + public int? Duration { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkSearchModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkSearchModel.cs new file mode 100644 index 0000000..886aa03 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/SearchModels/WorkSearchModel.cs @@ -0,0 +1,21 @@ +using ServiceStationDataModels.Models; + +namespace ServiceStationContracts.SearchModels +{ + public class WorkSearchModel + { + public int? Id { get; set; } + + public string? Title { get; set; } + + public double? Price { get; set; } + + public int? StorekeeperId { get; set; } + + public int? DurationId { get; set; } + + public Dictionary? WorkSpares { get; set; } + + public Dictionary? WorkMaintenances { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj new file mode 100644 index 0000000..18fee99 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ICarStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ICarStorage.cs new file mode 100644 index 0000000..4f2d5e4 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ICarStorage.cs @@ -0,0 +1,18 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface ICarStorage + { + List GetFullList(); + List GetFilteredList(CarSearchModel model); + CarViewModel? GetElement(CarSearchModel model); + CarViewModel? Insert(CarBindingModel model); + CarViewModel? Update(CarBindingModel model); + CarViewModel? Delete(CarBindingModel model); + + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IEmployerStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IEmployerStorage.cs new file mode 100644 index 0000000..f255f47 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IEmployerStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IEmployerStorage + { + List GetFullList(); + List GetFilteredList(EmployerSearchModel model); + EmployerViewModel? GetElement(EmployerSearchModel model); + EmployerViewModel? Insert(EmployerBindingModel model); + EmployerViewModel? Update(EmployerBindingModel model); + EmployerViewModel? Delete(EmployerBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IMaintenanceStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IMaintenanceStorage.cs new file mode 100644 index 0000000..6959f9e --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IMaintenanceStorage.cs @@ -0,0 +1,18 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IMaintenanceStorage + { + List GetFullList(); + List GetFilteredList(MaintenanceSearchModel model); + MaintenanceViewModel? GetElement(MaintenanceSearchModel model); + MaintenanceViewModel? Insert(MaintenanceBindingModel model); + MaintenanceViewModel? Update(MaintenanceBindingModel model); + MaintenanceViewModel? Delete(MaintenanceBindingModel model); + public List GetMaintenaceCars(MaintenanceSearchModel model); + public List GetCarsSpares(MaintenanceSearchModel model1, CarSearchModel model2); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IServiceStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IServiceStorage.cs new file mode 100644 index 0000000..05eae90 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IServiceStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IServiceStorage + { + List GetFullList(); + List GetFilteredList(ServiceSearchModel model); + ServiceViewModel? GetElement(ServiceSearchModel model); + ServiceViewModel? Insert(ServiceBindingModel model); + ServiceViewModel? Update(ServiceBindingModel model); + ServiceViewModel? Delete(ServiceBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ISpareStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ISpareStorage.cs new file mode 100644 index 0000000..411b23c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/ISpareStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface ISpareStorage + { + List GetFullList(); + List GetFilteredList(SpareSearchModel model); + SpareViewModel? GetElement(SpareSearchModel model); + SpareViewModel? Insert(SpareBindingModel model); + SpareViewModel? Update(SpareBindingModel model); + SpareViewModel? Delete(SpareBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IStorekeeperStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IStorekeeperStorage.cs new file mode 100644 index 0000000..3aa1911 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IStorekeeperStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IStorekeeperStorage + { + List GetFullList(); + List GetFilteredList(StorekeeperSearchModel model); + StorekeeperViewModel? GetElement(StorekeeperSearchModel model); + StorekeeperViewModel? Insert(StorekeeperBindingModel model); + StorekeeperViewModel? Update(StorekeeperBindingModel model); + StorekeeperViewModel? Delete(StorekeeperBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkDurationStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkDurationStorage.cs new file mode 100644 index 0000000..d169626 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkDurationStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IWorkDurationStorage + { + List GetFullList(); + List GetFilteredList(WorkDurationSearchModel model); + WorkDurationViewModel? GetElement(WorkDurationSearchModel model); + WorkDurationViewModel? Insert(WorkDurationBindingModel model); + WorkDurationViewModel? Update(WorkDurationBindingModel model); + WorkDurationViewModel? Delete(WorkDurationBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkStorage.cs new file mode 100644 index 0000000..3628f42 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/StoragesContracts/IWorkStorage.cs @@ -0,0 +1,16 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; + +namespace ServiceStationContracts.StoragesContracts +{ + public interface IWorkStorage + { + List GetFullList(); + List GetFilteredList(WorkSearchModel model); + WorkViewModel? GetElement(WorkSearchModel model); + WorkViewModel? Insert(WorkBindingModel model); + WorkViewModel? Update(WorkBindingModel model); + WorkViewModel? Delete(WorkBindingModel model); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/CarViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/CarViewModel.cs new file mode 100644 index 0000000..4abebaa --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/CarViewModel.cs @@ -0,0 +1,20 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class CarViewModel : ICarModel + { + public int Id { get; set; } + + [DisplayName("Название бренда")] + public string Brand { get; set; } = string.Empty; + + [DisplayName("Название модели")] + public string Model { get; set; } = string.Empty; + + [DisplayName("VIN номер")] + public string VIN { get; set; } = string.Empty; + public Dictionary CarSpares { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/EmployerViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/EmployerViewModel.cs new file mode 100644 index 0000000..2523f4e --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/EmployerViewModel.cs @@ -0,0 +1,16 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class EmployerViewModel : IEmployerModel + { + public int Id { get; set; } + [DisplayName("Логин")] + public string Login { get; set; } = string.Empty; + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; + [DisplayName("Почта")] + public string Email { get; set; } = string.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/MaintenanceViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/MaintenanceViewModel.cs new file mode 100644 index 0000000..fb2b87c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/MaintenanceViewModel.cs @@ -0,0 +1,16 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class MaintenanceViewModel : IMaintenanceModel + { + public int Id { get; set; } + public int EmployerId { get; set; } + [DisplayName("Стоимость")] + public double Cost { get; set; } + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } + public Dictionary MaintenanceCars { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ReportViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ReportViewModel.cs new file mode 100644 index 0000000..5195e0c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ReportViewModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationContracts.ViewModels +{ + public class ReportViewModel + { + public double Cost { get; set; } + public List Cars { get; set; } = new(); + + public List Spares { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ServiceViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ServiceViewModel.cs new file mode 100644 index 0000000..2aaa0d0 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/ServiceViewModel.cs @@ -0,0 +1,12 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class ServiceViewModel : IServiceModel + { + public int Id { get; set; } + [DisplayName("Описание сервиса")] + public string ServiceDescription { get; set; } = string.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/SpareViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/SpareViewModel.cs new file mode 100644 index 0000000..93c5dfc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/SpareViewModel.cs @@ -0,0 +1,15 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class SpareViewModel : ISpareModel + { + public int Id { get; set; } + + [DisplayName("Название")] + public string Name { get; set; } = String.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/StorekeeperViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/StorekeeperViewModel.cs new file mode 100644 index 0000000..5ab31dc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/StorekeeperViewModel.cs @@ -0,0 +1,16 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class StorekeeperViewModel : IStorekeeperModel + { + public int Id { get; set; } + [DisplayName("Логин")] + public string Login { get; set; } = String.Empty; + [DisplayName("Пароль")] + public string Password { get; set; } = String.Empty; + [DisplayName("Почта")] + public string Email { get; set; } = String.Empty; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkDurationViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkDurationViewModel.cs new file mode 100644 index 0000000..332c8e8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkDurationViewModel.cs @@ -0,0 +1,12 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class WorkDurationViewModel : IWorkDurationModel + { + public int Id { get; set; } + [DisplayName("Длительность")] + public int Duration { get; set; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkViewModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkViewModel.cs new file mode 100644 index 0000000..f0c0ddc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationContracts/ViewModels/WorkViewModel.cs @@ -0,0 +1,22 @@ +using ServiceStationDataModels.Models; +using System.ComponentModel; + +namespace ServiceStationContracts.ViewModels +{ + public class WorkViewModel : IWorkModel + { + public int Id { get; set; } + [DisplayName("Название")] + public string Title { get; set; } = String.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public int DurationId { get; set; } + public int StorekeeperId { get; set; } + + public Dictionary WorkSpares { get; set; } = new(); + + public Dictionary WorkMaintences { get; set; } = new(); + + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/IId.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/IId.cs new file mode 100644 index 0000000..b34386c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace ServiceStationDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ICarModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ICarModel.cs new file mode 100644 index 0000000..b11f2bc --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ICarModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationDataModels.Models +{ + public interface ICarModel : IId + { + string Brand { get; } + string Model { get; } + string VIN { get; } + Dictionary CarSpares { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IEmployerModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IEmployerModel.cs new file mode 100644 index 0000000..020529c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IEmployerModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationDataModels.Models +{ + public interface IEmployerModel : IId + { + string Login { get; } + + string Password { get; } + string Email { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IMaintenanceModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IMaintenanceModel.cs new file mode 100644 index 0000000..9401147 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IMaintenanceModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationDataModels.Models +{ + public interface IMaintenanceModel : IId + { + int EmployerId { get; } + double Cost { get; } + DateTime DateCreate { get; } + Dictionary MaintenanceCars { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IServiceModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IServiceModel.cs new file mode 100644 index 0000000..b301a7b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IServiceModel.cs @@ -0,0 +1,7 @@ +namespace ServiceStationDataModels.Models +{ + public interface IServiceModel : IId + { + string ServiceDescription { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ISpareModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ISpareModel.cs new file mode 100644 index 0000000..2b3f4d8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/ISpareModel.cs @@ -0,0 +1,9 @@ +namespace ServiceStationDataModels.Models +{ + public interface ISpareModel : IId + { + string Name { get; } + + double Price { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IStorekeeperModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IStorekeeperModel.cs new file mode 100644 index 0000000..ba28958 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IStorekeeperModel.cs @@ -0,0 +1,10 @@ +namespace ServiceStationDataModels.Models +{ + public interface IStorekeeperModel : IId + { + string Login { get; } + + string Password { get; } + string Email { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkDurationModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkDurationModel.cs new file mode 100644 index 0000000..c5a51b8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkDurationModel.cs @@ -0,0 +1,7 @@ +namespace ServiceStationDataModels.Models +{ + public interface IWorkDurationModel : IId + { + int Duration { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkModel.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkModel.cs new file mode 100644 index 0000000..32371eb --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/Models/IWorkModel.cs @@ -0,0 +1,16 @@ +namespace ServiceStationDataModels.Models +{ + public interface IWorkModel : IId + { + string Title { get; } + + double Price { get; } + + int StorekeeperId { get; } + + int DurationId { get; } + + Dictionary WorkSpares { get; } + Dictionary WorkMaintences { get; } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/ServiceStationDataModels.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/ServiceStationDataModels.csproj new file mode 100644 index 0000000..72a0126 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDataModels/ServiceStationDataModels.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/CarStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/CarStorage.cs new file mode 100644 index 0000000..6804af8 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/CarStorage.cs @@ -0,0 +1,96 @@ +using Microsoft.EntityFrameworkCore; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class CarStorage : ICarStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Cars.Include(x => x.Spares).ThenInclude(x => x.Spare).ToList() + .Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(CarSearchModel model) + { + if (string.IsNullOrEmpty(model.Brand)) + { + return new(); + } + using var context = new ServiceStationDatabase(); + return context.Cars.Include(x => x.Spares).ThenInclude(x => x.Spare) + .Where(x => x.Brand.Contains(model.Brand)).ToList().Select(x => x.GetViewModel).ToList(); + } + + public CarViewModel? GetElement(CarSearchModel model) + { + if (string.IsNullOrEmpty(model.Brand) && !model.Id.HasValue) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Cars.Include(x => x.Spares).ThenInclude(x => x.Spare) + .FirstOrDefault(x => + (!string.IsNullOrEmpty(model.Brand) && x.Brand == model.Brand) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public CarViewModel? Insert(CarBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newCar = Car.Create(context, model); + if (newCar == null) + { + return null; + } + context.Cars.Add(newCar); + context.SaveChanges(); + return newCar.GetViewModel; + } + + public CarViewModel? Update(CarBindingModel model) + { + using var context = new ServiceStationDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var Car = context.Cars.FirstOrDefault(rec => rec.Id == model.Id); + if (Car == null) + { + return null; + } + Car.Update(model); + context.SaveChanges(); + Car.UpdateComponents(context, model); + transaction.Commit(); + return Car.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public CarViewModel? Delete(CarBindingModel model) + { + using var context = new ServiceStationDatabase(); + var element = context.Cars.Include(x => x.Spares).FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Cars.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/EmployerStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/EmployerStorage.cs new file mode 100644 index 0000000..ba8e4f6 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/EmployerStorage.cs @@ -0,0 +1,79 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class EmployerStorage : IEmployerStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Employers.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(EmployerSearchModel model) + { + if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email)) + { + return new(); + } + using var context = new ServiceStationDatabase(); + return context.Employers.Where(x => (!string.IsNullOrEmpty(model.Login) && x.Login.Contains(model.Login)) || + (!string.IsNullOrEmpty(model.Email) && !x.Email.Contains(model.Email))).Select(x => x.GetViewModel).ToList(); + } + + public EmployerViewModel? GetElement(EmployerSearchModel model) + { + if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password))) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Employers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || + (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) || + (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password) && x.Email == model.Email && x.Password == model.Password))?.GetViewModel; + } + + public EmployerViewModel? Insert(EmployerBindingModel model) + { + var newEmployer = Employer.Create(model); + if (newEmployer == null) + { + return null; + } + using var context = new ServiceStationDatabase(); + context.Employers.Add(newEmployer); + context.SaveChanges(); + return newEmployer.GetViewModel; + } + + public EmployerViewModel? Update(EmployerBindingModel model) + { + using var context = new ServiceStationDatabase(); + var storekeeper = context.Employers.FirstOrDefault(x => x.Id == model.Id); + if (storekeeper == null) + { + return null; + } + storekeeper.Update(model); + context.SaveChanges(); + return storekeeper.GetViewModel; + } + + public EmployerViewModel? Delete(EmployerBindingModel model) + { + using var context = new ServiceStationDatabase(); + var storekeeper = context.Employers.FirstOrDefault(x => x.Id == model.Id); + if (storekeeper != null) + { + context.Employers.Remove(storekeeper); + context.SaveChanges(); + return storekeeper.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/MaintenanceStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/MaintenanceStorage.cs new file mode 100644 index 0000000..4766f8f --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/MaintenanceStorage.cs @@ -0,0 +1,116 @@ +using Microsoft.EntityFrameworkCore; +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class MaintenanceStorage : IMaintenanceStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Maintenances.Include(x => x.Cars).ThenInclude(x => x.Car).ToList() + .Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(MaintenanceSearchModel model) + { + using var context = new ServiceStationDatabase(); + return context.Maintenances.Include(x => x.Cars).ThenInclude(x => x.Car).ToList().Select(x => x.GetViewModel).ToList(); + } + + public MaintenanceViewModel? GetElement(MaintenanceSearchModel model) + { + if ( !model.Id.HasValue) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Maintenances.Include(x => x.Cars).ThenInclude(x => x.Car) + .FirstOrDefault(x => + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public MaintenanceViewModel? Insert(MaintenanceBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newMaintenance = Maintenance.Create(context, model); + if (newMaintenance == null) + { + return null; + } + context.Maintenances.Add(newMaintenance); + context.SaveChanges(); + return newMaintenance.GetViewModel; + } + + public MaintenanceViewModel? Update(MaintenanceBindingModel model) + { + using var context = new ServiceStationDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var Maintenance = context.Maintenances.FirstOrDefault(rec => rec.Id == model.Id); + if (Maintenance == null) + { + return null; + } + Maintenance.Update(model); + context.SaveChanges(); + Maintenance.UpdateComponents(context, model); + transaction.Commit(); + return Maintenance.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public MaintenanceViewModel? Delete(MaintenanceBindingModel model) + { + using var context = new ServiceStationDatabase(); + var element = context.Maintenances.Include(x => x.Cars).FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Maintenances.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public List GetMaintenaceCars(MaintenanceSearchModel model) + { + if (model == null) + { + return new(); + } + using var context = new ServiceStationDatabase(); + var cars = context.MaintenanceCars + .Where(x => x.MaintenanceId == model.Id) + .Select(x => x.Car.GetViewModel) + .ToList(); + return cars; + } + + public List GetCarsSpares(MaintenanceSearchModel model1, CarSearchModel model2) + { + if (model1 == null || model2 == null) + { + return new(); + } + using var context = new ServiceStationDatabase(); + + var cars = context.MaintenanceCars.Where(x => x.MaintenanceId == model1.Id).Select(x=>x.Car).ToList(); + var spare = context.CarSpares.Where(x => cars.Contains(x.Car)).Select(x => x.Spare.GetViewModel).ToList(); + + return spare; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/ServiceStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/ServiceStorage.cs new file mode 100644 index 0000000..acc02f7 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/ServiceStorage.cs @@ -0,0 +1,85 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class ServiceStorage : IServiceStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Services.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(ServiceSearchModel model) + { + using var context = new ServiceStationDatabase(); + return context.Services.Select(x => x.GetViewModel).ToList(); + } + + public ServiceViewModel? GetElement(ServiceSearchModel model) + { + if (string.IsNullOrEmpty(model.ServiceDescription) && !model.Id.HasValue) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Services.FirstOrDefault(x => + (!string.IsNullOrEmpty(model.ServiceDescription) && x.ServiceDescription == model.ServiceDescription) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public ServiceViewModel? Insert(ServiceBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newService = Service.Create(model); + if (newService == null) + { + return null; + } + context.Services.Add(newService); + context.SaveChanges(); + return newService.GetViewModel; + } + + public ServiceViewModel? Update(ServiceBindingModel model) + { + using var context = new ServiceStationDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var Service = context.Services.FirstOrDefault(rec => rec.Id == model.Id); + if (Service == null) + { + return null; + } + Service.Update(model); + context.SaveChanges(); + transaction.Commit(); + return Service.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public ServiceViewModel? Delete(ServiceBindingModel model) + { + using var context = new ServiceStationDatabase(); + var element = context.Services.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Services.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/SpareStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/SpareStorage.cs new file mode 100644 index 0000000..ab26b52 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/SpareStorage.cs @@ -0,0 +1,72 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class SpareStorage : ISpareStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Spares.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(SpareSearchModel model) + { + using var context = new ServiceStationDatabase(); + return context.Spares.Select(x => x.GetViewModel).ToList(); + } + + public SpareViewModel? GetElement(SpareSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Spares.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + + public SpareViewModel? Insert(SpareBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newSpares = Spare.Create( model); + if(newSpares == null) + { + return null; + } + context.Spares.Add(newSpares); + context.SaveChanges(); + return newSpares.GetViewModel; + } + + public SpareViewModel? Update(SpareBindingModel model) + { + using var context = new ServiceStationDatabase(); + var spares = context.Spares.FirstOrDefault(x=>x.Id == model.Id); + if(spares == null) + { + return null; + } + spares.Update(model); + context.SaveChanges(); + return spares.GetViewModel; + } + + public SpareViewModel? Delete(SpareBindingModel model) + { + using var context = new ServiceStationDatabase(); + var spare = context.Spares.FirstOrDefault(x=>x.Id==model.Id); + if(spare != null) + { + context.Spares.Remove(spare); + context.SaveChanges(); + return spare.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/StorekeeperStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/StorekeeperStorage.cs new file mode 100644 index 0000000..7c0a06c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/StorekeeperStorage.cs @@ -0,0 +1,79 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class StorekeeperStorage : IStorekeeperStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Storekeepers.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(StorekeeperSearchModel model) + { + if(string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email)) + { + return new(); + } + using var context = new ServiceStationDatabase(); + return context.Storekeepers.Where(x => (!string.IsNullOrEmpty(model.Login) && x.Login.Contains(model.Login)) || + (!string.IsNullOrEmpty(model.Email) && !x.Email.Contains(model.Email))).Select(x => x.GetViewModel).ToList(); + } + + public StorekeeperViewModel? GetElement(StorekeeperSearchModel model) + { + if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password))) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Storekeepers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || + (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) || + (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password) && x.Email == model.Email && x.Password == model.Password))?.GetViewModel; + } + + public StorekeeperViewModel? Insert(StorekeeperBindingModel model) + { + var newStorekeeper = Storekeeper.Create(model); + if(newStorekeeper == null) + { + return null; + } + using var context = new ServiceStationDatabase(); + context.Storekeepers.Add(newStorekeeper); + context.SaveChanges(); + return newStorekeeper.GetViewModel; + } + + public StorekeeperViewModel? Update(StorekeeperBindingModel model) + { + using var context = new ServiceStationDatabase(); + var storekeeper = context.Storekeepers.FirstOrDefault(x=>x.Id == model.Id); + if(storekeeper == null) + { + return null; + } + storekeeper.Update(model); + context.SaveChanges(); + return storekeeper.GetViewModel; + } + + public StorekeeperViewModel? Delete(StorekeeperBindingModel model) + { + using var context = new ServiceStationDatabase(); + var storekeeper = context.Storekeepers.FirstOrDefault(x=>x.Id==model.Id); + if(storekeeper != null) + { + context.Storekeepers.Remove(storekeeper); + context.SaveChanges(); + return storekeeper.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkDurationStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkDurationStorage.cs new file mode 100644 index 0000000..e1a9b48 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkDurationStorage.cs @@ -0,0 +1,72 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class WorkDurationStorage : IWorkDurationStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.WorkDurations.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(WorkDurationSearchModel model) + { + using var context = new ServiceStationDatabase(); + return context.WorkDurations.Select(x => x.GetViewModel).ToList(); + } + + public WorkDurationViewModel? GetElement(WorkDurationSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.WorkDurations.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + + public WorkDurationViewModel? Insert(WorkDurationBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newWorkDuration = WorkDuration.Create( model); + if(newWorkDuration == null) + { + return null; + } + context.WorkDurations.Add(newWorkDuration); + context.SaveChanges(); + return newWorkDuration.GetViewModel; + } + + public WorkDurationViewModel? Update(WorkDurationBindingModel model) + { + using var context = new ServiceStationDatabase(); + var workDuration = context.WorkDurations.FirstOrDefault(x=>x.Id == model.Id); + if(workDuration == null) + { + return null; + } + workDuration.Update(model); + context.SaveChanges(); + return workDuration.GetViewModel; + } + + public WorkDurationViewModel? Delete(WorkDurationBindingModel model) + { + using var context = new ServiceStationDatabase(); + var workDuration = context.WorkDurations.FirstOrDefault(x=>x.Id==model.Id); + if(workDuration != null) + { + context.WorkDurations.Remove(workDuration); + context.SaveChanges(); + return workDuration.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkStorage.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkStorage.cs new file mode 100644 index 0000000..92eedfb --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Implements/WorkStorage.cs @@ -0,0 +1,78 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StoragesContracts; +using ServiceStationContracts.ViewModels; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement.Implements +{ + public class WorkStorage : IWorkStorage + { + public List GetFullList() + { + using var context = new ServiceStationDatabase(); + return context.Works.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(WorkSearchModel model) + { + if(string.IsNullOrEmpty(model.Title)) + { + return new(); + } + using var context = new ServiceStationDatabase(); + return context.Works.Select(x => x.GetViewModel).ToList(); + } + + public WorkViewModel? GetElement(WorkSearchModel model) + { + if (!model.Id.HasValue && string.IsNullOrEmpty(model.Title)) + { + return null; + } + using var context = new ServiceStationDatabase(); + return context.Works.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || + (!string.IsNullOrEmpty(model.Title) && x.Title == model.Title))?.GetViewModel; + } + + public WorkViewModel? Insert(WorkBindingModel model) + { + using var context = new ServiceStationDatabase(); + var newWork = Work.Create(context, model); + if(newWork == null) + { + return null; + } + context.Works.Add(newWork); + context.SaveChanges(); + return newWork.GetViewModel; + } + + public WorkViewModel? Update(WorkBindingModel model) + { + using var context = new ServiceStationDatabase(); + var work = context.Works.FirstOrDefault(x=>x.Id == model.Id); + if(work == null) + { + return null; + } + work.Update(model); + work.UpdateSpares(context, model); + context.SaveChanges(); + return work.GetViewModel; + } + + public WorkViewModel? Delete(WorkBindingModel model) + { + using var context = new ServiceStationDatabase(); + var work = context.Works.FirstOrDefault(x=>x.Id==model.Id); + if(work != null) + { + context.Works.Remove(work); + context.SaveChanges(); + return work.GetViewModel; + } + return null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Car.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Car.cs new file mode 100644 index 0000000..a095a9b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Car.cs @@ -0,0 +1,92 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Car : ICarModel + { + public int Id { get; set; } + [Required] + public string Brand { get; set; } =string.Empty; + [Required] + public string Model { get; set; } = string.Empty; + [Required] + public string VIN { get; set; } = string.Empty; + + [ForeignKey("CarId")] + public virtual List Services { get; set; } = new(); + + private Dictionary? _carSpares = null; + [NotMapped] + public Dictionary CarSpares + { + get + { + if (_carSpares == null) + { + _carSpares = Spares.ToDictionary(recCS => recCS.SpareId, recCS => (recCS.Spare as ISpareModel, recCS.Count)); + } + return _carSpares; + } + } + [ForeignKey("CarId")] + public virtual List Spares { get; set; } = new(); + public static Car Create(ServiceStationDatabase context, CarBindingModel model) + { + return new Car() + { + Id = model.Id, + Brand = model.Brand, + Model = model.Model, + VIN = model.VIN, + Spares = model.CarSpares.Select(x => new CarSpare + { + Car = context.Cars.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList() + }; + } + public void Update(CarBindingModel model) + { + } + public CarViewModel GetViewModel => new() + { + Id = Id, + Brand = Brand, + Model = Model, + VIN = VIN, + CarSpares = CarSpares + }; + public void UpdateComponents(ServiceStationDatabase context, CarBindingModel model) + { + var CarSpares = context.CarSpares.Where(recCS => recCS.CarId == model.Id).ToList(); + if (CarSpares != null && CarSpares.Count > 0) + { + context.CarSpares.RemoveRange(CarSpares.Where(rec => !model.CarSpares.ContainsKey(rec.CarId))); + context.SaveChanges(); + CarSpares = context.CarSpares.Where(rec => rec.CarId == model.Id).ToList(); + foreach (var updateComponent in CarSpares) + { + updateComponent.Count = model.CarSpares[updateComponent.CarId].Item2; + model.CarSpares.Remove(updateComponent.CarId); + } + context.SaveChanges(); + } + var Car = context.Cars.First(x => x.Id == Id); + foreach (var pc in model.CarSpares) + { + context.CarSpares.Add(new CarSpare + { + Car = Car, + Spare = context.Spares.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _carSpares = null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/CarSpare.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/CarSpare.cs new file mode 100644 index 0000000..3dc8b06 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/CarSpare.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class CarSpare + { + public int Id { get; set; } + + [Required] + public int SpareId { get; set; } + + [Required] + public int CarId { get; set; } + [Required] + public int Count { get; set; } + + public virtual Car Car { get; set; } = new(); + + public virtual Spare Spare { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Employer.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Employer.cs new file mode 100644 index 0000000..ac15bb2 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Employer.cs @@ -0,0 +1,48 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Employer : IEmployerModel + { + public int Id { get; set; } + [Required] + public string Login { get; set; } = String.Empty; + [Required] + public string Password { get; set; } = String.Empty; + [Required] + public string Email { get; set; } = String.Empty; + [ForeignKey("EmployerId")] + public virtual List Maintenances { get; set; } = new(); + + + public static Employer Create(EmployerBindingModel model) + { + return new Employer() + { + Id = model.Id, + Login = model.Login, + Password = model.Password, + Email = model.Email, + }; + } + + public void Update(EmployerBindingModel model) + { + Login = model.Login; + Password = model.Password; + Email = model.Email; + } + + public EmployerViewModel GetViewModel => new() + { + Id = Id, + Login = Login, + Email = Email, + Password = Password + }; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Maintenance.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Maintenance.cs new file mode 100644 index 0000000..a9cc865 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Maintenance.cs @@ -0,0 +1,92 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Maintenance : IMaintenanceModel + { + public int Id { get; set; } + [Required] + public int EmployerId { get; set; } + [Required] + public double Cost { get; set; } + [Required] + public DateTime DateCreate { get; set; } + + private Dictionary _maintenanceCars = null; + [NotMapped] + public Dictionary MaintenanceCars + { + get + { + if (_maintenanceCars == null) + { + _maintenanceCars = Cars + .ToDictionary(recCM => recCM.CarId, recCM => (recCM.Car as ICarModel,recCM.Count)); + } + return _maintenanceCars; + } + } + [ForeignKey("MaintenanceId")] + public virtual List Cars { get; set; } = new(); + + public static Maintenance Create(ServiceStationDatabase context, MaintenanceBindingModel model) + { + return new Maintenance() + { + Id = model.Id, + EmployerId = model.EmployerId, + Cars = model.MaintenanceCars.Select(x => new MaintenanceCar + { + Car = context.Cars.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList() + }; + } + + public void Update(MaintenanceBindingModel model) + { + Cost = model.Cost; + } + + public MaintenanceViewModel GetViewModel => new() + { + Id = Id, + EmployerId = EmployerId, + Cost = Cost, + DateCreate = DateCreate, + MaintenanceCars = MaintenanceCars + }; + public void UpdateComponents(ServiceStationDatabase context, MaintenanceBindingModel model) + { + var MaintenanceCars = context.MaintenanceCars.Where(rec => rec.MaintenanceId == model.Id).ToList(); + if (MaintenanceCars != null && MaintenanceCars.Count > 0) + { + context.MaintenanceCars.RemoveRange(MaintenanceCars.Where(rec => !model.MaintenanceCars.ContainsKey(rec.CarId))); + context.SaveChanges(); + MaintenanceCars = context.MaintenanceCars.Where(rec => rec.MaintenanceId == model.Id).ToList(); + foreach (var updateComponent in MaintenanceCars) + { + updateComponent.Count = model.MaintenanceCars[updateComponent.CarId].Item2; + model.MaintenanceCars.Remove(updateComponent.CarId); + } + context.SaveChanges(); + } + var Maintenance = context.Maintenances.First(x => x.Id == Id); + foreach (var pc in model.MaintenanceCars) + { + context.MaintenanceCars.Add(new MaintenanceCar + { + Maintenance = Maintenance, + Car = context.Cars.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _maintenanceCars = null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/MaintenanceCar.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/MaintenanceCar.cs new file mode 100644 index 0000000..125c2d5 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/MaintenanceCar.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class MaintenanceCar + { + public int Id { get; set; } + + [Required] + public int MaintenanceId { get; set; } + + [Required] + public int CarId { get; set; } + [Required] + public int Count { get; set; } + + public virtual Car Car { get; set; } = new(); + + public virtual Maintenance Maintenance { get; set; } = new(); + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Service.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Service.cs new file mode 100644 index 0000000..f27e823 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Service.cs @@ -0,0 +1,32 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Service : IServiceModel + { + public int Id { get; set; } + [Required] + public string ServiceDescription { get; set; } = string.Empty; + + public static Service Create(ServiceBindingModel model) + { + return new Service() + { + Id = model.Id, + ServiceDescription = model.ServiceDescription, + }; + } + public void Update(ServiceBindingModel model) + { + ServiceDescription = model.ServiceDescription; + } + public ServiceViewModel GetViewModel => new() + { + Id = Id, + ServiceDescription = ServiceDescription, + }; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Spare.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Spare.cs new file mode 100644 index 0000000..e91f6bf --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Spare.cs @@ -0,0 +1,43 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Spare : ISpareModel + { + public int Id { get; set; } + + [Required] + public string Name { get; set; } = String.Empty; + [Required] + public double Price { get; set; } + + public static Spare Create(SpareBindingModel model) + { + return new Spare + { + Id = model.Id, + Name = model.Name, + Price = model.Price, + }; + } + + public void Update(SpareBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + } + + public SpareViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Price = Price, + }; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Storekeeper.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Storekeeper.cs new file mode 100644 index 0000000..54f895c --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Storekeeper.cs @@ -0,0 +1,48 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Storekeeper : IStorekeeperModel + { + public int Id { get; set; } + [Required] + public string Login { get; set; } = String.Empty; + [Required] + public string Password { get; set; } = String.Empty; + [Required] + public string Email { get; set; } = String.Empty; + [ForeignKey("StorekeeperId")] + public virtual List Works { get; set; } = new(); + + + public static Storekeeper Create(StorekeeperBindingModel model) + { + return new Storekeeper() + { + Id = model.Id, + Login = model.Login, + Password = model.Password, + Email = model.Email, + }; + } + + public void Update(StorekeeperBindingModel model) + { + Login = model.Login; + Password = model.Password; + Email = model.Email; + } + + public StorekeeperViewModel GetViewModel => new() + { + Id = Id, + Login = Login, + Email = Email, + Password = Password + }; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Work.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Work.cs new file mode 100644 index 0000000..ad0cc41 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/Work.cs @@ -0,0 +1,146 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class Work : IWorkModel + { + public int Id { get; set; } + [Required] + public string Title { get; set; } = String.Empty; + [Required] + public double Price { get; set; } + [Required] + public int StorekeeperId { get; set; } + [Required] + public int DurationId { get; set; } + + private Dictionary? _workSpares { get; set; } = null; + [NotMapped] + public Dictionary WorkSpares { + get + { + if (_workSpares == null) + { + _workSpares = Spares.ToDictionary(recWS => recWS.SpareId, recWS => + (recWS.Spare as ISpareModel, recWS.Count)); + } + return _workSpares; + } + } + + [ForeignKey("WorkId")] + public virtual List Spares { get; set; } = new(); + + private Dictionary? _workMaintenances = null; + + [NotMapped] + public Dictionary WorkMaintences + { + get + { + if (_workMaintenances == null) + { + _workMaintenances = Maintences.ToDictionary(recWM => recWM.MaintenceId, recWM => + (recWM.Maintenance as IMaintenanceModel, recWM.Count)); + } + return _workMaintenances; + } + } + [ForeignKey("WorkId")] + public virtual List Maintences { get; set; } = new(); + + public static Work Create(ServiceStationDatabase context, WorkBindingModel model) + { + return new Work() + { + Id = model.Id, + Title = model.Title, + Price = model.Price, + Spares = model.WorkSpares.Select(x => new WorkSpare { + Spare = context.Spares.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList(), + Maintences = model.WorkMaintences.Select(x => new WorkMaintence + { + Maintenance = context.Maintenances.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList() + }; + } + + public void Update(WorkBindingModel model) + { + Title = model.Title; + Price = model.Price; + } + + public WorkViewModel GetViewModel => new() + { + Id = Id, + Title = Title, + Price = Price, + }; + + + + public void UpdateSpares(ServiceStationDatabase context, WorkBindingModel model) + { + var WorkSpares = context.WorkSpares.Where(rec => rec.WorkId == model.Id).ToList(); + if (WorkSpares != null && WorkSpares.Count > 0) + { + context.WorkSpares.RemoveRange(WorkSpares.Where(rec => !model.WorkSpares.ContainsKey(rec.SpareId))); + context.SaveChanges(); + foreach (var updateComponent in WorkSpares) + { + updateComponent.Count = model.WorkSpares[updateComponent.SpareId].Item2; + model.WorkSpares.Remove(updateComponent.SpareId); + } + context.SaveChanges(); + } + var Work = context.Works.First(x => x.Id == Id); + foreach (var pc in model.WorkSpares) + { + context.WorkSpares.Add(new WorkSpare + { + Work = Work, + Spare = context.Spares.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _workSpares = null; + } + + public void UpdateMaintences(ServiceStationDatabase context, WorkBindingModel model) + { + var WorkMaintence = context.WorkMaintences.Where(rec => rec.WorkId == model.Id).ToList(); + if (WorkMaintence != null && WorkMaintence.Count > 0) + { + context.WorkMaintences.RemoveRange(WorkMaintence.Where(rec => !model.WorkMaintences.ContainsKey(rec.MaintenceId))); + context.SaveChanges(); + foreach (var updateComponent in WorkMaintence) + { + updateComponent.Count = model.WorkMaintences[updateComponent.MaintenceId].Item2; + model.WorkMaintences.Remove(updateComponent.MaintenceId); + } + context.SaveChanges(); + } + var Work = context.Works.First(x => x.Id == Id); + foreach (var pc in model.WorkMaintences) + { + context.WorkMaintences.Add(new WorkMaintence + { + Work = Work, + Maintenance = context.Maintenances.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _workMaintenances = null; + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkDuration.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkDuration.cs new file mode 100644 index 0000000..dd2b8f3 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkDuration.cs @@ -0,0 +1,37 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.ViewModels; +using ServiceStationDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ServiceStationDatabaseImplement.Models +{ + public class WorkDuration : IWorkDurationModel + { + public int Id { get; set; } + + [Required] + public int Duration { get; set; } + + [ForeignKey("DurationId")] + public virtual List Works { get; set; } + + public static WorkDuration Create(WorkDurationBindingModel model) + { + return new WorkDuration() + { + Id = model.Id, + Duration = model.Duration, + }; + } + public void Update(WorkDurationBindingModel model) + { + Duration = model.Duration; + } + public WorkDurationViewModel GetViewModel => new() + { + Id = Id, + Duration = Duration, + }; + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkMaintence.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkMaintence.cs new file mode 100644 index 0000000..f2846f3 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkMaintence.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class WorkMaintence + { + public int Id { get; set; } + + [Required] + public int WorkId { get; set; } + + [Required] + public int MaintenceId { get; set; } + + [Required] + public int Count { get; set; } + + public virtual Work Work { get; set; } = new(); + + public virtual Maintenance Maintenance { get; set; } = new(); + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkSpare.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkSpare.cs new file mode 100644 index 0000000..5f3d622 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Models/WorkSpare.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; + +namespace ServiceStationDatabaseImplement.Models +{ + public class WorkSpare + { + public int Id { get; set; } + + [Required] + public int WorkId { get; set; } + + [Required] + public int SpareId { get; set; } + + [Required] + public int Count { get; set; } + + public virtual Work Work { get; set; } = new(); + + public virtual Spare Spare { get; set; } = new(); + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs new file mode 100644 index 0000000..5c7e0f7 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using ServiceStationDatabaseImplement.Models; + +namespace ServiceStationDatabaseImplement +{ + public class ServiceStationDatabase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QVK6NSA\SQLEXPRESS03;Initial Catalog=ServiceStation;Integrated Security=True;TrustServerCertificate=True"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Cars { set; get; } + public virtual DbSet CarSpares { set; get; } + public virtual DbSet Employers { set; get; } + public virtual DbSet Maintenances { set; get; } + public virtual DbSet MaintenanceCars { set; get; } + public virtual DbSet Services { set; get; } + public virtual DbSet Spares { set; get; } + public virtual DbSet Storekeepers { set; get; } + public virtual DbSet Works { set; get; } + public virtual DbSet WorkDurations { set; get; } + public virtual DbSet WorkMaintences { set; get; } + public virtual DbSet WorkSpares { set; get; } + + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabaseImplement.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabaseImplement.csproj new file mode 100644 index 0000000..c63e473 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabaseImplement.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.Designer.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.Designer.cs new file mode 100644 index 0000000..b504d77 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.Designer.cs @@ -0,0 +1,46 @@ +namespace ServiceStation +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + SuspendLayout(); + // + // Form1 + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Name = "Form1"; + Text = "Form1"; + Load += Form1_Load; + ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.cs new file mode 100644 index 0000000..d35c982 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.cs @@ -0,0 +1,15 @@ +namespace ServiceStation +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.resx b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Form1.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Program.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Program.cs new file mode 100644 index 0000000..e6c2280 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/Program.cs @@ -0,0 +1,40 @@ +using ServiceStation; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + +namespace ServiceStationView +{ + internal static class Program + { + private static ServiceProvider? _serviceProvider; + + public static ServiceProvider? ServiceProvider => _serviceProvider; + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font; + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + + services.AddTransient(); + } + } +} \ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/ServiceStationView.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/ServiceStationView.csproj new file mode 100644 index 0000000..d547e97 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationView/ServiceStationView.csproj @@ -0,0 +1,26 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + \ No newline at end of file