From 8ad8b44a2364dad7bf22cc7de567982f5fbd5fb2 Mon Sep 17 00:00:00 2001 From: Arklightning Date: Sat, 8 Apr 2023 19:57:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BD=D0=B0=D0=B1=D1=80=D0=BE=D1=81=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bank/Bank.sln | 49 ++ .../BankBuisinessLogics.csproj | 27 + .../BuisinessLogics/ClercLogic.cs | 171 ++++++ .../BuisinessLogics/ConferenceBookingLogic.cs | 121 ++++ .../BuisinessLogics/ConferenceLogic.cs | 120 ++++ .../BuisinessLogics/DinnerLogic.cs | 130 ++++ .../BuisinessLogics/HeadwaiterLogic.cs | 176 ++++++ .../BuisinessLogics/MealPlanLogic.cs | 135 +++++ .../BuisinessLogics/MemberLogic.cs | 125 ++++ .../BuisinessLogics/ReportLogicHeadwaiter.cs | 118 ++++ .../BuisinessLogics/ReportLogicOrganiser.cs | 124 ++++ .../BuisinessLogics/RoomLogic.cs | 136 +++++ .../OfficePackage/AbstractSaveToExcelClerc.cs | 75 +++ .../AbstractSaveToExcelHeadwaiter.cs | 80 +++ .../OfficePackage/AbstractSaveToPdfClerc.cs | 53 ++ .../AbstractSaveToPdfHeadwaiter.cs | 58 ++ .../OfficePackage/AbstractSaveToWordClerc.cs | 57 ++ .../AbstractSaveToWordHeadwaiter.cs | 62 ++ .../HelperEnums/ExcelStyleInfoType.cs | 9 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 13 + .../HelperModels/ExcelInfoClerc.cs | 15 + .../HelperModels/ExcelInfoHeadwaiter.cs | 20 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../HelperModels/PdfInfoClerc.cs | 13 + .../HelperModels/PdfInfoHeadwaiter.cs | 18 + .../HelperModels/PdfParagraph.cs | 11 + .../HelperModels/PdfRowParameters.cs | 11 + .../HelperModels/WordInfoClerc.cs | 12 + .../HelperModels/WordInfoHeadwaiter.cs | 16 + .../HelperModels/WordParagraph.cs | 8 + .../HelperModels/WordTextProperties.cs | 11 + .../Implements/SaveToExcelClerc.cs | 329 ++++++++++ .../Implements/SaveToExcelHeadwaiter.cs | 333 ++++++++++ .../Implements/SaveToPdfClerc.cs | 98 +++ .../Implements/SaveToPdfHeadwaiter.cs | 103 ++++ .../Implements/SaveToWordClerc.cs | 123 ++++ .../Implements/SaveToWordHeadwaiter.cs | 128 ++++ Bank/BankContracts/BankContracts.csproj | 17 + .../BindingModels/ClercBindingModel.cs | 19 + .../BindingModels/ConferenceBindingModel.cs | 16 + .../ConferenceBookingBindingModel.cs | 14 + .../BindingModels/DinnerBindingModel.cs | 15 + .../BindingModels/HeadwaiterBindingModel.cs | 19 + .../BindingModels/MealPlanBindingModel.cs | 16 + .../BindingModels/MemberBindingModel.cs | 15 + .../BindingModels/ReportBindingModel.cs | 10 + .../ReportHeadwaiterBindingModel.cs.cs | 16 + .../BindingModels/RoomBindingModel.cs | 20 + .../BusinessLogicsContracts/IClercLogic.cs | 15 + .../IConferenceBookingLogic.cs | 15 + .../IConferenceLogic.cs | 15 + .../BusinessLogicsContracts/IDinnerLogic.cs | 16 + .../IHeadwaiterLogic.cs | 15 + .../BusinessLogicsContracts/IMealPlanLogic.cs | 15 + .../BusinessLogicsContracts/IMemberLogic.cs | 15 + .../IReportHeadwaiterLogic.cs | 19 + .../IReportOrganiserLogic.cs | 14 + .../BusinessLogicsContracts/IRoomLogic.cs | 15 + .../SearchModels/ClercSearchModel.cs | 10 + .../ConferenceBookingSearchModel.cs | 11 + .../SearchModels/ConferenceSearchModel.cs | 11 + .../SearchModels/DinnerSearchModel.cs | 9 + .../SearchModels/HeadwaiterSearchModel.cs | 13 + .../SearchModels/MealPlanSearchModel.cs | 8 + .../SearchModels/MemberSearchModel.cs | 8 + .../SearchModels/RoomSearchModel.cs | 9 + .../StoragesContracts/IClercStorage.cs | 21 + .../IConferenceBookingStorage.cs | 21 + .../StoragesContracts/IConferenceStorage.cs | 21 + .../StoragesContracts/IDinnerStorage.cs | 21 + .../StoragesContracts/IHeadwaiterStorage.cs | 21 + .../StoragesContracts/IMealPlanStorage.cs | 21 + .../StoragesContracts/IMemberStorage.cs | 21 + .../StoragesContracts/IRoomStorage.cs | 21 + .../ViewModels/ClercViewModel.cs | 25 + .../ViewModels/ConferenceBookingViewModel.cs | 19 + .../ViewModels/ConferenceViewModel.cs | 19 + .../ViewModels/DinnerViewModel.cs | 19 + .../ViewModels/HeadwaiterViewModel.cs | 31 + .../ViewModels/MealPlanViewModel.cs | 20 + .../ViewModels/MemberViewModel.cs | 18 + .../ReportConferenceBindingRoomsViewModel.cs | 17 + .../ReportMealPlanDinnerViewModel.cs | 15 + .../ReportMemberConferenceViewModel.cs | 8 + .../ViewModels/ReportMembersViewModel.cs | 12 + .../BankContracts/ViewModels/RoomViewModel.cs | 26 + Bank/BankDataBaseImplement/BankDataBase.cs | 31 + .../BankDataBaseImplement.csproj | 22 + .../Implemets/ConferenceBookingStorage.cs | 164 +++++ .../Implemets/ConferenceStorage.cs | 159 +++++ .../Implemets/DinnerStorage.cs | 120 ++++ .../Implemets/HeadwaiterStorage.cs | 127 ++++ .../Implemets/MealPlanStorage.cs | 113 ++++ .../Implemets/MemberStorage.cs | 118 ++++ .../Implemets/OrganiserStorage.cs | 122 ++++ .../Implemets/RoomStorage.cs | 118 ++++ .../20230405210621_InitialCreate.Designer.cs | 569 ++++++++++++++++++ .../20230405210621_InitialCreate.cs | 415 +++++++++++++ .../Migrations/HotelDataBaseModelSnapshot.cs | 566 +++++++++++++++++ Bank/BankDataBaseImplement/Models/Clerc.cs | 81 +++ .../Models/Conference.cs | 93 +++ .../Models/ConferenceBooking.cs | 87 +++ .../Models/ConferenceBookingDinner.cs | 21 + .../Models/ConferenceMember.cs | 18 + Bank/BankDataBaseImplement/Models/Dinner.cs | 70 +++ .../Models/Headwaiter.cs | 93 +++ Bank/BankDataBaseImplement/Models/MealPlan.cs | 94 +++ .../Models/MealPlanMember.cs | 18 + Bank/BankDataBaseImplement/Models/Member.cs | 66 ++ Bank/BankDataBaseImplement/Models/Room.cs | 100 +++ .../Models/RoomDinner.cs | 21 + Bank/BankDataModels/BankDataModels.csproj | 13 + Bank/BankDataModels/DataModels/IClercModel.cs | 11 + .../DataModels/IConferenceBookingModel.cs | 9 + .../DataModels/IConferenceModel.cs | 10 + .../BankDataModels/DataModels/IDinnerModel.cs | 9 + .../DataModels/IHeadwaiterModel.cs | 12 + .../DataModels/IMealPlanModel.cs | 10 + .../BankDataModels/DataModels/IMemberModel.cs | 9 + Bank/BankDataModels/DataModels/IRoomModel.cs | 13 + Bank/BankDataModels/lId.cs | 7 + Bank/BankView/App.config | 14 + Bank/BankView/BankView.csproj | 125 ++++ Bank/BankView/Form1.Designer.cs | 40 ++ Bank/BankView/Form1.cs | 20 + Bank/BankView/Program.cs | 22 + Bank/BankView/Properties/AssemblyInfo.cs | 36 ++ .../BankView/Properties/Resources.Designer.cs | 71 +++ Bank/BankView/Properties/Resources.resx | 117 ++++ Bank/BankView/Properties/Settings.Designer.cs | 30 + Bank/BankView/Properties/Settings.settings | 7 + Bank/BankView/packages.config | 17 + 134 files changed, 7929 insertions(+) create mode 100644 Bank/Bank.sln create mode 100644 Bank/BankBuisinessLogics/BankBuisinessLogics.csproj create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/ConferenceBookingLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs create mode 100644 Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfHeadwaiter.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordClerc.cs create mode 100644 Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordHeadwaiter.cs create mode 100644 Bank/BankContracts/BankContracts.csproj create mode 100644 Bank/BankContracts/BindingModels/ClercBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/ConferenceBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/ConferenceBookingBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/DinnerBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/MealPlanBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/MemberBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/ReportBindingModel.cs create mode 100644 Bank/BankContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs create mode 100644 Bank/BankContracts/BindingModels/RoomBindingModel.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IConferenceLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IHeadwaiterLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IReportOrganiserLogic.cs create mode 100644 Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs create mode 100644 Bank/BankContracts/SearchModels/ClercSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/ConferenceBookingSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/ConferenceSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/DinnerSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/MealPlanSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/MemberSearchModel.cs create mode 100644 Bank/BankContracts/SearchModels/RoomSearchModel.cs create mode 100644 Bank/BankContracts/StoragesContracts/IClercStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IConferenceBookingStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IConferenceStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IDinnerStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IMemberStorage.cs create mode 100644 Bank/BankContracts/StoragesContracts/IRoomStorage.cs create mode 100644 Bank/BankContracts/ViewModels/ClercViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ConferenceViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/DinnerViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/MealPlanViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/MemberViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ReportMealPlanDinnerViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ReportMemberConferenceViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ReportMembersViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/RoomViewModel.cs create mode 100644 Bank/BankDataBaseImplement/BankDataBase.cs create mode 100644 Bank/BankDataBaseImplement/BankDataBaseImplement.csproj create mode 100644 Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/MemberStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs create mode 100644 Bank/BankDataBaseImplement/Implemets/RoomStorage.cs create mode 100644 Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs create mode 100644 Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.cs create mode 100644 Bank/BankDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs create mode 100644 Bank/BankDataBaseImplement/Models/Clerc.cs create mode 100644 Bank/BankDataBaseImplement/Models/Conference.cs create mode 100644 Bank/BankDataBaseImplement/Models/ConferenceBooking.cs create mode 100644 Bank/BankDataBaseImplement/Models/ConferenceBookingDinner.cs create mode 100644 Bank/BankDataBaseImplement/Models/ConferenceMember.cs create mode 100644 Bank/BankDataBaseImplement/Models/Dinner.cs create mode 100644 Bank/BankDataBaseImplement/Models/Headwaiter.cs create mode 100644 Bank/BankDataBaseImplement/Models/MealPlan.cs create mode 100644 Bank/BankDataBaseImplement/Models/MealPlanMember.cs create mode 100644 Bank/BankDataBaseImplement/Models/Member.cs create mode 100644 Bank/BankDataBaseImplement/Models/Room.cs create mode 100644 Bank/BankDataBaseImplement/Models/RoomDinner.cs create mode 100644 Bank/BankDataModels/BankDataModels.csproj create mode 100644 Bank/BankDataModels/DataModels/IClercModel.cs create mode 100644 Bank/BankDataModels/DataModels/IConferenceBookingModel.cs create mode 100644 Bank/BankDataModels/DataModels/IConferenceModel.cs create mode 100644 Bank/BankDataModels/DataModels/IDinnerModel.cs create mode 100644 Bank/BankDataModels/DataModels/IHeadwaiterModel.cs create mode 100644 Bank/BankDataModels/DataModels/IMealPlanModel.cs create mode 100644 Bank/BankDataModels/DataModels/IMemberModel.cs create mode 100644 Bank/BankDataModels/DataModels/IRoomModel.cs create mode 100644 Bank/BankDataModels/lId.cs create mode 100644 Bank/BankView/App.config create mode 100644 Bank/BankView/BankView.csproj create mode 100644 Bank/BankView/Form1.Designer.cs create mode 100644 Bank/BankView/Form1.cs create mode 100644 Bank/BankView/Program.cs create mode 100644 Bank/BankView/Properties/AssemblyInfo.cs create mode 100644 Bank/BankView/Properties/Resources.Designer.cs create mode 100644 Bank/BankView/Properties/Resources.resx create mode 100644 Bank/BankView/Properties/Settings.Designer.cs create mode 100644 Bank/BankView/Properties/Settings.settings create mode 100644 Bank/BankView/packages.config diff --git a/Bank/Bank.sln b/Bank/Bank.sln new file mode 100644 index 0000000..1684d86 --- /dev/null +++ b/Bank/Bank.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankView", "BankView\BankView.csproj", "{2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankBuisinessLogics", "BankBuisinessLogics\BankBuisinessLogics.csproj", "{B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataBaseImplement", "BankDataBaseImplement\BankDataBaseImplement.csproj", "{6F86B4CB-FBAD-4E00-B285-D082393A3157}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankDataModels", "BankDataModels\BankDataModels.csproj", "{697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankContracts", "BankContracts\BankContracts.csproj", "{4B7AB326-2F82-45E3-8478-3EB0B398161A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E8E7B5D-D712-4E0B-8E35-42B3D5F30210}.Release|Any CPU.Build.0 = Release|Any CPU + {B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8420CD0-5AC2-4A71-ADCB-1CA64BACE577}.Release|Any CPU.Build.0 = Release|Any CPU + {6F86B4CB-FBAD-4E00-B285-D082393A3157}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F86B4CB-FBAD-4E00-B285-D082393A3157}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F86B4CB-FBAD-4E00-B285-D082393A3157}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F86B4CB-FBAD-4E00-B285-D082393A3157}.Release|Any CPU.Build.0 = Release|Any CPU + {697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {697C1BAA-82B1-4EB5-BAB9-D53C5771A8E9}.Release|Any CPU.Build.0 = Release|Any CPU + {4B7AB326-2F82-45E3-8478-3EB0B398161A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B7AB326-2F82-45E3-8478-3EB0B398161A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B7AB326-2F82-45E3-8478-3EB0B398161A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B7AB326-2F82-45E3-8478-3EB0B398161A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D4FA3705-E6CF-4A2E-B038-370AB28E4470} + EndGlobalSection +EndGlobal diff --git a/Bank/BankBuisinessLogics/BankBuisinessLogics.csproj b/Bank/BankBuisinessLogics/BankBuisinessLogics.csproj new file mode 100644 index 0000000..31a0f71 --- /dev/null +++ b/Bank/BankBuisinessLogics/BankBuisinessLogics.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs new file mode 100644 index 0000000..3913cae --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs @@ -0,0 +1,171 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BankBusinessLogic.BusinessLogics +{ + public class ClercLogic : IClercLogic + { + private readonly int _loginMaxLength = 50; + private readonly int _passwordMaxLength = 50; + private readonly int _passwordMinLength = 10; + + private readonly ILogger _logger; + private readonly IClercStorage _ClercStorage; + + public ClercLogic(ILogger logger, IClercStorage clercStorage) + { + _logger = logger; + _clercStorage = clercStorage; + } + + public bool Create(ClercBindingModel model) + { + CheckModel(model); + + if (_clercStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + + return false; + } + + return true; + } + + public bool Delete(ClercBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id: {Id}", model.Id); + + if (_clercStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + + return false; + } + + return true; + } + + public ClercViewModel? ReadElement(ClercSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}.", model.ClercFIO, model.ClercLogin, model.Id); + + var element = _clercStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + + return element; + } + + public List? ReadList(ClercSearchModel? model) + { + _logger.LogInformation("ReadList. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}.", model?.ClercFIO, model?.ClercLogin, model?.Id); + + var list = model == null ? _clercStorage.GetFullList() : _clercStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + + return list; + } + + public bool Update(ClercBindingModel model) + { + CheckModel(model); + + if (_clercStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(ClercBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.ClercFIO)) + { + throw new ArgumentNullException("Нет ФИО организатора", nameof(model.ClercFIO)); + } + + if (string.IsNullOrEmpty(model.ClercLogin)) + { + throw new ArgumentNullException("Нет логина организатора", nameof(model.ClercLogin)); + } + + if (model.ClercLogin.Length>_loginMaxLength) + { + throw new ArgumentNullException("Логин слишком длинный", nameof(model.ClercLogin)); + } + + if (string.IsNullOrEmpty(model.ClercNumber)) + { + throw new ArgumentNullException("Нет номера телефона организатора", nameof(model.ClercNumber)); + } + + if (string.IsNullOrEmpty(model.ClercEmail)) + { + throw new ArgumentNullException("Нет почты организатора", nameof(model.ClercEmail)); + } + + if (string.IsNullOrEmpty(model.ClercPassword)) + { + throw new ArgumentNullException("Нет пароля организатора", nameof(model.ClercPassword)); + } + + if (model.ClercPassword.Length < _passwordMinLength) + { + throw new ArgumentNullException("Пароль слишком короткий", nameof(model.ClercPassword)); + } + + if (model.ClercPassword.Length > _passwordMaxLength) + { + throw new ArgumentNullException("Пароль слишком длинный", nameof(model.ClercPassword)); + } + + _logger.LogInformation("Clerc. ClercFIO: {ClercFIO}. ClercLogin: {ClercLogin}. Id: {Id}", model.ClercFIO, model.ClercLogin, model.Id); + + var element = _clercStorage.GetElement(new ClercSearchModel + { + ClercLogin = model.ClercLogin + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Организатор с таким логином уже есть"); + } + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceBookingLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceBookingLogic.cs new file mode 100644 index 0000000..9e1ee9b --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceBookingLogic.cs @@ -0,0 +1,121 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogics +{ + public class ConferenceBookingLogic : IConferenceBookingLogic + { + private readonly ILogger _logger; + private readonly IConferenceBookingStorage _conferenceBookingStorage; + + public ConferenceBookingLogic(ILogger logger, IConferenceBookingStorage conferenceBookingStorage) + { + _logger = logger; + _conferenceBookingStorage = conferenceBookingStorage; + } + public bool Create(ConferenceBookingBindingModel model) + { + CheckModel(model); + + if (_conferenceBookingStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(ConferenceBookingBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_conferenceBookingStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. Id:{Id}", model.Id); + + var element = _conferenceBookingStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(ConferenceBookingSearchModel? model) + { + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + + var list = model == null ? _conferenceBookingStorage.GetFullList() : _conferenceBookingStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(ConferenceBookingBindingModel model) + { + CheckModel(model); + + if (_conferenceBookingStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + private void CheckModel(ConferenceBookingBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + _logger.LogInformation("ConferenceBooking. Id: { Id}", model.Id); + + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs new file mode 100644 index 0000000..49d7698 --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ConferenceLogic.cs @@ -0,0 +1,120 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BankBusinessLogic.BusinessLogics +{ + public class ConferenceLogic : IConferenceLogic + { + private readonly ILogger _logger; + private readonly IConferenceStorage _conferenceStorage; + + public ConferenceLogic(ILogger logger, IConferenceStorage conferenceStorage) + { + _logger = logger; + _conferenceStorage = conferenceStorage; + } + public bool Create(ConferenceBindingModel model) + { + CheckModel(model); + + if (_conferenceStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(ConferenceBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_conferenceStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public ConferenceViewModel? ReadElement(ConferenceSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. ConferenceName:{ConferenceName}.Id:{Id}", model.ConferenceName, model.Id); + + var element = _conferenceStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(ConferenceSearchModel? model) + { + _logger.LogInformation("ReadList. ConferenceName:{ConferenceName}.Id:{ Id}", model?.ConferenceName, model?.Id); + + var list = model == null ? _conferenceStorage.GetFullList() : _conferenceStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(ConferenceBindingModel model) + { + CheckModel(model); + + if (_conferenceStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + private void CheckModel(ConferenceBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.ConferenceName)) + { + throw new ArgumentNullException("Нет названия конференции", nameof(model.ConferenceName)); + } + + _logger.LogInformation("Conference. ConferenceName:{ConferenceName}.StartDate:{ StartDate}. Id: { Id}", model.ConferenceName, model.StartDate, model.Id); + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs new file mode 100644 index 0000000..eb947e1 --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/DinnerLogic.cs @@ -0,0 +1,130 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogics +{ + public class DinnerLogic : IDinnerLogic + { + private readonly ILogger _logger; + private readonly IDinnerStorage _dinnerStorage; + + public DinnerLogic(ILogger logger, IDinnerStorage dinnerStorage) + { + _logger = logger; + _dinnerStorage = dinnerStorage; + } + + public bool Create(DinnerBindingModel model) + { + CheckModel(model); + + if (_dinnerStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(DinnerBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_dinnerStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public DinnerViewModel? ReadElement(DinnerSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. DinnerName:{DinnerName}.Id:{Id}", model.DinnerName, model.Id); + + var element = _dinnerStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(DinnerSearchModel? model) + { + _logger.LogInformation("ReadList. DinnerName:{DinnerName}.Id:{ Id}", model?.DinnerName, model?.Id); + + var list = model == null ? _dinnerStorage.GetFullList() : _dinnerStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(DinnerBindingModel model) + { + CheckModel(model); + + if (_dinnerStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + private void CheckModel(DinnerBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.DinnerName)) + { + throw new ArgumentNullException("Нет имени обеда", nameof(model.DinnerName)); + } + + if (model.DinnerPrice < 0) + { + throw new ArgumentNullException("Стоимость обеда не может быть меньше 0", nameof(model.DinnerPrice)); + } + + _logger.LogInformation("Dinner. DinnerName:{DinnerName}.DinnerPrice:{ DinnerPrice}. Id: { Id}", model.DinnerName, model.DinnerPrice, model.Id); + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs new file mode 100644 index 0000000..83761ec --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/HeadwaiterLogic.cs @@ -0,0 +1,176 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogics +{ + public class HeadwaiterLogic : IHeadwaiterLogic + { + private readonly int _loginMaxLength = 50; + private readonly int _passwordMaxLength = 50; + private readonly int _passwordMinLength = 10; + + private readonly ILogger _logger; + private readonly IHeadwaiterStorage _headwaiterStorage; + + public HeadwaiterLogic(ILogger logger, IHeadwaiterStorage headwaiterStorage) + { + _logger = logger; + _headwaiterStorage = headwaiterStorage; + } + + public bool Create(HeadwaiterBindingModel model) + { + CheckModel(model); + + if (_headwaiterStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + + return false; + } + + return true; + } + + public bool Delete(HeadwaiterBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id: {Id}", model.Id); + + if (_headwaiterStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + + return false; + } + + return true; + } + + public HeadwaiterViewModel? ReadElement(HeadwaiterSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id); + + var element = _headwaiterStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + + return element; + } + + public List? ReadList(HeadwaiterSearchModel? model) + { + _logger.LogInformation("ReadList. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model?.HeadwaiterFIO, model?.HeadwaiterLogin, model?.Id); + + var list = model == null ? _headwaiterStorage.GetFullList() : _headwaiterStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + + return list; + } + + public bool Update(HeadwaiterBindingModel model) + { + CheckModel(model); + + if (_headwaiterStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(HeadwaiterBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.HeadwaiterFIO)) + { + throw new ArgumentNullException("Нет ФИО метродотеля", nameof(model.HeadwaiterFIO)); + } + + if (string.IsNullOrEmpty(model.HeadwaiterLogin)) + { + throw new ArgumentNullException("Нет логина метродотеля", nameof(model.HeadwaiterLogin)); + } + + if (model.HeadwaiterLogin.Length > _loginMaxLength) + { + throw new ArgumentNullException("Логин слишком длинный", nameof(model.HeadwaiterLogin)); + } + + if (string.IsNullOrEmpty(model.HeadwaiterNumber)) + { + throw new ArgumentNullException("Нет номера телефона метродотеля", nameof(model.HeadwaiterNumber)); + } + + if (string.IsNullOrEmpty(model.HeadwaiterEmail)) + { + throw new ArgumentNullException("Нет почты метродотеля", nameof(model.HeadwaiterEmail)); + } + + if (string.IsNullOrEmpty(model.HeadwaiterPassword)) + { + throw new ArgumentNullException("Нет пароля метродотеля", nameof(model.HeadwaiterPassword)); + } + + if (model.HeadwaiterPassword.Length < _passwordMinLength) + { + throw new ArgumentNullException("Пароль слишком короткий", nameof(model.HeadwaiterPassword)); + } + + if (model.HeadwaiterPassword.Length > _passwordMaxLength) + { + throw new ArgumentNullException("Пароль слишком длинный", nameof(model.HeadwaiterPassword)); + } + + _logger.LogInformation("Headwaiter. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id); + + var element = _headwaiterStorage.GetElement(new HeadwaiterSearchModel + { + HeadwaiterLogin = model.HeadwaiterLogin + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("метродотель с таким логином уже есть"); + } + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs new file mode 100644 index 0000000..f4bc432 --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/MealPlanLogic.cs @@ -0,0 +1,135 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BankBusinessLogic.BusinessLogics +{ + public class MealPlanLogic : IMealPlanLogic + { + private readonly ILogger _logger; + private readonly IMealPlanStorage _mealPlanStorage; + + public MealPlanLogic(ILogger logger, IMealPlanStorage mealPlanStorage) + { + _logger = logger; + _mealPlanStorage = mealPlanStorage; + } + public bool Create(MealPlanBindingModel model) + { + CheckModel(model); + + if (_mealPlanStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(MealPlanBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_mealPlanStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public MealPlanViewModel? ReadElement(MealPlanSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.MealPlanName, model.Id); + + var element = _mealPlanStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(MealPlanSearchModel? model) + { + _logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.MealPlanName, model?.Id); + + var list = model == null ? _mealPlanStorage.GetFullList() : _mealPlanStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(MealPlanBindingModel model) + { + CheckModel(model); + + if (_mealPlanStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + private void CheckModel(MealPlanBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.MealPlanName)) + { + throw new ArgumentNullException("Нет названия плана питания", nameof(model.MealPlanName)); + } + + if (model.MealPlanPrice<0) + { + throw new ArgumentNullException("Стоимость плана питания не может быть меньше 0", nameof(model.MealPlanPrice)); + } + + _logger.LogInformation("MealPlan. MealPlanName:{MealPlanName}.MealPlanPrice:{ MealPlanPrice}. Id: { Id}", model.MealPlanName, model.MealPlanPrice, model.Id); + + var element = _mealPlanStorage.GetElement(new MealPlanSearchModel + { + MealPlanName = model.MealPlanName + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("План питания с таким названием уже есть"); + } + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs new file mode 100644 index 0000000..a433b70 --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/MemberLogic.cs @@ -0,0 +1,125 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BankBusinessLogic.BusinessLogics +{ + public class MemberLogic : IMemberLogic + { + private readonly ILogger _logger; + private readonly IMemberStorage _memberStorage; + + public MemberLogic(ILogger logger, IMemberStorage memberStorage) + { + _logger = logger; + _memberStorage = memberStorage; + } + + public bool Create(MemberBindingModel model) + { + CheckModel(model); + + if (_memberStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(MemberBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_memberStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public MemberViewModel? ReadElement(MemberSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. MemberFIO:{MemberFIO}.Id:{Id}", model.MemberFIO, model.Id); + + var element = _memberStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(MemberSearchModel? model) + { + _logger.LogInformation("ReadList. MemberFIO:{MemberFIO}.Id:{ Id}", model?.MemberFIO, model?.Id); + + var list = model == null ? _memberStorage.GetFullList() : _memberStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(MemberBindingModel model) + { + CheckModel(model); + + if (_memberStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + private void CheckModel(MemberBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.MemberFIO)) + { + throw new ArgumentNullException("Нет ФИО участника", nameof(model.MemberFIO)); + } + + if (string.IsNullOrEmpty(model.Citizenship)) + { + throw new ArgumentNullException("Не указано гражданство участника", nameof(model.Citizenship)); + } + + _logger.LogInformation("Member. MemberFIO:{MemberFIO}.Citizenship:{ Citizenship}. Id: { Id}", model.MemberFIO, model.Citizenship, model.Id); + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicHeadwaiter.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicHeadwaiter.cs new file mode 100644 index 0000000..63dd1cc --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicHeadwaiter.cs @@ -0,0 +1,118 @@ +using BankBusinessLogic.OfficePackage.HelperModels; +using BankBusinessLogic.OfficePackage; +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogics +{ + public class ReportLogicHeadwaiter : IReportHeadwaiterLogic + { + private readonly IRoomStorage _roomStorage; + private readonly IDinnerStorage _dinnerStorage; + private readonly IMealPlanStorage _mealPlansStorage; + private readonly IConferenceBookingStorage _conferenceBookingStorage; + private readonly AbstractSaveToExcelHeadwaiter _saveToExcel; + private readonly AbstractSaveToWordHeadwaitre _saveToWord; + private readonly AbstractSaveToPdfHeadwaiter _saveToPdf; + public ReportLogicHeadwaiter(IRoomStorage roomStorage, IDinnerStorage dinnerStorage, IMealPlanStorage mealPlansStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf) + { + _roomStorage = roomStorage; + _dinnerStorage = dinnerStorage; + _mealPlansStorage = mealPlansStorage; + _conferenceBookingStorage = conferenceBookingStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + public List GetMealPlanDinner() + { + var mealPlans = _mealPlansStorage.GetFullList(); + var dinners = _dinnerStorage.GetFullList(); + var list = new List(); + foreach (var dinner in dinners) + { + var record = new ReportMealPlanDinnerViewModel + { + DinnerName = dinner.DinnerName, + MealPlans = new List>() + }; + foreach (var mealPlan in mealPlans) + { + if (mealPlan.MealPlanDinners.ContainsKey(dinner.Id)) + { + record.MealPlans.Add(new Tuple(mealPlans.MealPlanName, mealPlans.StartDate)); + } + } + list.Add(record); + } + return list; + } + + public List GetConferenceBindingRooms(ReportHeadwaiterBindingModel model) + { + var listAll = new List(); + + var listConferenceBinding = _conferenceBookingStorage.GetFilteredList(new ConferenceBookingSearchModel + { + HeadwaiterId = model.HeadwaiterId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + + var listRooms = _roomStorage.GetFilteredList(new RoomSearchModel()); + + foreach (var room in listRooms) + { + listAll.Add(new ReportConferenceBindingRoomsViewModel + { + RoomName = room.RoomName, + RoomPrice = room.RoomPrice, + RoomFrame = room.RoomFrame + }); + + } + + return listAll; + } + + public void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfoHeadwaiter + { + FileName = model.FileName, + Title = "Список изделий", + MealPlanDinner = GetMealPlanDinner() + }); + } + + public void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model) + { + _saveToWord.CreateDoc(new WordInfoHeadwaiter + { + FileName = model.FileName, + Title = "Список участников", + MealPlanDinner = GetMealPlanDinner() + }); + } + + public void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfoHeadwaiter + { + FileName = model.FileName, + Title = "Список участников", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + ConferenceBindingRooms = GetConferenceBindingRooms(model) + }); + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs new file mode 100644 index 0000000..201679b --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ReportLogicOrganiser.cs @@ -0,0 +1,124 @@ +using DocumentFormat.OpenXml.Bibliography; +using BankBusinessLogic.OfficePackage; +using BankBusinessLogic.OfficePackage.HelperModels; +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using System.Reflection; + +namespace BankBusinessLogic.BusinessLogics +{ + public class ReportLogicOrganiser : IReportOrganiserLogic + { + private readonly IMealPlanStorage _mealPlanStorage; + private readonly IMemberStorage _memberStorage; + private readonly IConferenceStorage _conferenceStorage; + private readonly AbstractSaveToExcelOrganiser _saveToExcel; + private readonly AbstractSaveToWordClerc _saveToWord; + private readonly AbstractSaveToPdfClerc _saveToPdf; + public ReportLogicOrganiser(IMealPlanStorage mealPlanStorage, IMemberStorage memberStorage, IConferenceStorage conferenceStorage, AbstractSaveToExcelOrganiser saveToExcel, AbstractSaveToWordClerc saveToWord, AbstractSaveToPdfClerc saveToPdf) + { + _mealPlanStorage = mealPlanStorage; + _memberStorage = memberStorage; + _conferenceStorage = conferenceStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + public List GetMemberConference() + { + var conferences = _conferenceStorage.GetFullList(); + var members = _memberStorage.GetFullList(); + var list = new List(); + foreach (var member in members) + { + var record = new ReportMemberConferenceViewModel + { + MemberFIO = member.MemberFIO, + Conferences = new List>() + }; + foreach (var conference in conferences) + { + if (conference.ConferenceMembers.ContainsKey(member.Id)) + { + record.Conferences.Add(new Tuple(conference.ConferenceName, conference.StartDate)); + } + } + list.Add(record); + } + return list; + } + + public List GetMembers(ReportBindingModel model) + { + var listAll = new List(); + + var listСonferences = _conferenceStorage.GetFilteredList(new ConferenceSearchModel + { + OrganiserId = model.OrganiserId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + + foreach (var conference in listСonferences) + { + foreach (var c in conference.ConferenceMembers) + { + listAll.Add(new ReportMembersViewModel + { + StartDate = conference.StartDate, + ConferenceName = conference.ConferenceName, + MemberFIO=c.Value.MemberFIO + }); + } + } + var listMealPlans = _mealPlanStorage.GetFilteredList(new MealPlanSearchModel()); + + foreach (var mealPlan in listMealPlans) + { + listAll.Add(new ReportMembersViewModel + { + MealPlanName = mealPlan.MealPlanName, + MealPlanPrice = mealPlan.MealPlanPrice + }); + + } + + return listAll; + } + + public void SaveMemberConferenceToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfoOrganiser + { + FileName = model.FileName, + Title = "Список изделий", + MemberConferences = GetMemberConference() + }); + } + + public void SaveMemberConferenceToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfoClerc + { + FileName = model.FileName, + Title = "Список участников", + MemberConferences = GetMemberConference() + }) ; + } + + public void SaveMembersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfoClerc + { + FileName = model.FileName, + Title = "Список участников", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Members = GetMembers(model) + }); + } + } +} diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs new file mode 100644 index 0000000..656d6f7 --- /dev/null +++ b/Bank/BankBuisinessLogics/BuisinessLogics/RoomLogic.cs @@ -0,0 +1,136 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogics +{ + public class RoomLogic : IRoomLogic + { + private readonly ILogger _logger; + private readonly IRoomStorage _roomStorage; + + public RoomLogic(ILogger logger, IRoomStorage roomStorage) + { + _logger = logger; + _roomStorage = roomStorage; + } + public bool Create(RoomBindingModel model) + { + CheckModel(model); + + if (_roomStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public bool Delete(RoomBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_roomStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + public RoomViewModel? ReadElement(RoomSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. RoomName:{RoomName}.Id:{Id}", model.RoomName, model.Id); + + var element = _roomStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public List? ReadList(RoomSearchModel? model) + { + _logger.LogInformation("ReadList. RoomName:{RoomName}.Id:{ Id}", model?.RoomName, model?.Id); + + var list = model == null ? _roomStorage.GetFullList() : _roomStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public bool Update(RoomBindingModel model) + { + CheckModel(model); + + if (_roomStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + private void CheckModel(RoomBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + + if (string.IsNullOrEmpty(model.RoomName)) + { + throw new ArgumentNullException("Нет названия комнате", nameof(model.RoomName)); + } + + + if (string.IsNullOrEmpty(model.RoomFrame)) + { + throw new ArgumentNullException("Нет названия корпусу", nameof(model.RoomFrame)); + } + + if (model.RoomPrice < 0) + { + throw new ArgumentNullException("Стоимость комнаты не может быть меньше 0", nameof(model.RoomPrice)); + } + + _logger.LogInformation("Room. RoomName:{RoomName}.RoomFrame:{ RoomFrame}.RoomPrice:{ RoomPrice}. Id: { Id}", model.RoomName, model.RoomFrame, model.RoomPrice, model.Id); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelClerc.cs new file mode 100644 index 0000000..60d4705 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelClerc.cs @@ -0,0 +1,75 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcelClerc + { + public void CreateReport(ExcelInfoClerc info) + { + CreateExcel(info); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title, + StyleInfo = ExcelStyleInfoType.Title + }); + + MergeCells(new ExcelMergeParameters + { + CellFromName = "A1", + CellToName = "C1" + }); + + uint rowIndex = 2; + + foreach (var mc in info.MemberConferences) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = mc.MemberFIO, + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; + + foreach (var conference in mc.Conferences) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = conference.Item1, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = conference.Item2.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + rowIndex++; + } + + rowIndex++; + } + + SaveExcel(info); + } + + protected abstract void CreateExcel(ExcelInfoClerc info); + + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + + protected abstract void MergeCells(ExcelMergeParameters excelParams); + + protected abstract void SaveExcel(ExcelInfoClerc info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelHeadwaiter.cs new file mode 100644 index 0000000..d210a4a --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToExcelHeadwaiter.cs @@ -0,0 +1,80 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcelHeadwaiter + { + public void CreateReport(ExcelInfoHeadwaiter info) + { + CreateExcel(info); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title, + StyleInfo = ExcelStyleInfoType.Title + }); + + MergeCells(new ExcelMergeParameters + { + CellFromName = "A1", + CellToName = "C1" + }); + + uint rowIndex = 2; + + foreach (var mc in info.MealPlanDinner) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = mc.DinnerName, + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; + + foreach (var mealPlan in mc.MealPlans) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = mealPlan.Item1, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mealPlan.Item2.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + rowIndex++; + } + + rowIndex++; + } + + SaveExcel(info); + } + + protected abstract void CreateExcel(ExcelInfoHeadwaiter info); + + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + + protected abstract void MergeCells(ExcelMergeParameters excelParams); + + protected abstract void SaveExcel(ExcelInfoHeadwaiter info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfClerc.cs new file mode 100644 index 0000000..01d0490 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfClerc.cs @@ -0,0 +1,53 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdfClerc + { + public void CreateDoc(PdfInfoClerc info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateParagraph(new PdfParagraph + { + Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "ФИО участника", "Название конференции", "Дата начала конференции", "Название плана питания", "Стоимость плана питания" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var member in info.Members) + { + CreateRow(new PdfRowParameters + { + Texts = new List { member.Id.ToString(), member.ConferenceName, member.StartDate.ToShortDateString(), member.MealPlanName, member.MealPlanPrice.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.Members.Sum(x => x.MealPlanPrice)}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + SavePdf(info); + } + protected abstract void CreatePdf(PdfInfoClerc info); + protected abstract void CreateParagraph(PdfParagraph paragraph); + protected abstract void CreateTable(List columns); + protected abstract void CreateRow(PdfRowParameters rowParameters); + protected abstract void SavePdf(PdfInfoClerc info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfHeadwaiter.cs new file mode 100644 index 0000000..ea50c57 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToPdfHeadwaiter.cs @@ -0,0 +1,58 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdfHeadwaiter + { + public void CreateDoc(PdfInfoHeadwaiter info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateParagraph(new PdfParagraph + { + Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Название команты", "Корпус комнтаы", "Цена комнаты" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var conferenceBindingRooms in info.ConferenceBindingRooms) + { + CreateRow(new PdfRowParameters + { + Texts = new List { conferenceBindingRooms.Id.ToString(), conferenceBindingRooms.RoomName, conferenceBindingRooms.RoomFrame, conferenceBindingRooms.RoomPrice.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.ConferenceBindingRooms.Sum(x => x.RoomPrice)}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + SavePdf(info); + } + protected abstract void CreatePdf(PdfInfoHeadwaiter info); + protected abstract void CreateParagraph(PdfParagraph paragraph); + protected abstract void CreateTable(List columns); + protected abstract void CreateRow(PdfRowParameters rowParameters); + protected abstract void SavePdf(PdfInfoHeadwaiter info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordClerc.cs new file mode 100644 index 0000000..5d44bab --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordClerc.cs @@ -0,0 +1,57 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToWordClerc + { + public void CreateDoc(WordInfoClerc info) + { + CreateWord(info); + + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Center + } + }); + + foreach (var mc in info.MemberConferences) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (mc.MemberFIO+" - ", new WordTextProperties { Size = "24", Bold=true})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + + foreach (var conference in mc.Conferences) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (conference.Item1 + " - ", new WordTextProperties { Size = "20", Bold=false}), + (conference.Item2.ToShortDateString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + } + SaveWord(info); + } + + protected abstract void CreateWord(WordInfoClerc info); + protected abstract void CreateParagraph(WordParagraph paragraph); + protected abstract void SaveWord(WordInfoClerc info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordHeadwaiter.cs new file mode 100644 index 0000000..934c6c4 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/AbstractSaveToWordHeadwaiter.cs @@ -0,0 +1,62 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToWordHeadwaitre + { + public void CreateDoc(WordInfoHeadwaiter info) + { + CreateWord(info); + + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Center + } + }); + + foreach (var mc in info.MealPlanDinner) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (mc.DinnerName+" - ", new WordTextProperties { Size = "24", Bold=true})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + + foreach (var mealPlan in mc.MealPlans) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (mealPlan.Item1 + " - ", new WordTextProperties { Size = "20", Bold=false}), + (mealPlan.Item2.ToShortDateString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + } + SaveWord(info); + } + + protected abstract void CreateWord(WordInfoHeadwaiter info); + protected abstract void CreateParagraph(WordParagraph paragraph); + protected abstract void SaveWord(WordInfoHeadwaiter info); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/ExcelStyleInfoType.cs new file mode 100644 index 0000000..330ec6f --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -0,0 +1,9 @@ +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + public enum ExcelStyleInfoType + { + Title, + Text, + TextWithBroder + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..1fd8a2f --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -0,0 +1,9 @@ +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + public enum PdfParagraphAlignmentType + { + Center, + Left, + Rigth + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/WordJustificationType.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/WordJustificationType.cs new file mode 100644 index 0000000..b8828ae --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperEnums/WordJustificationType.cs @@ -0,0 +1,8 @@ +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + public enum WordJustificationType + { + Center, + Both + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelCellParameters.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelCellParameters.cs new file mode 100644 index 0000000..bad7072 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -0,0 +1,13 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelCellParameters + { + public string ColumnName { get; set; } = string.Empty; + public uint RowIndex { get; set; } + public string Text { get; set; } = string.Empty; + public string CellReference => $"{ColumnName}{RowIndex}"; + public ExcelStyleInfoType StyleInfo { get; set; } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoClerc.cs new file mode 100644 index 0000000..934cffe --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoClerc.cs @@ -0,0 +1,15 @@ +using BankContracts.ViewModels; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfoClerc + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List MemberConferences + { + get; + set; + } = new(); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoHeadwaiter.cs new file mode 100644 index 0000000..0f06dda --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelInfoHeadwaiter.cs @@ -0,0 +1,20 @@ +using BankContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfoHeadwaiter + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List MealPlanDinner + { + get; + set; + } = new(); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelMergeParameters.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelMergeParameters.cs new file mode 100644 index 0000000..b0e67fb --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -0,0 +1,9 @@ +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelMergeParameters + { + public string CellFromName { get; set; } = string.Empty; + public string CellToName { get; set; } = string.Empty; + public string Merge => $"{CellFromName}:{CellToName}"; + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoClerc.cs new file mode 100644 index 0000000..d684c69 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoClerc.cs @@ -0,0 +1,13 @@ +using BankContracts.ViewModels; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfoClerc + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } + public List Members { get; set; } = new(); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoHeadwaiter.cs new file mode 100644 index 0000000..76e989f --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfInfoHeadwaiter.cs @@ -0,0 +1,18 @@ +using BankContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfoHeadwaiter + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } + public List ConferenceBindingRooms { get; set; } = new(); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfParagraph.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..208ddc3 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,11 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class PdfParagraph + { + public string Text { get; set; } = string.Empty; + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfRowParameters.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..86658a7 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,11 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class PdfRowParameters + { + public List Texts { get; set; } = new(); + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoClerc.cs new file mode 100644 index 0000000..e2feaaa --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoClerc.cs @@ -0,0 +1,12 @@ +using BankContracts.ViewModels; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfoClerc + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List MemberConferences { get; set; } = new(); + + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoHeadwaiter.cs new file mode 100644 index 0000000..7c6db7e --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordInfoHeadwaiter.cs @@ -0,0 +1,16 @@ +using BankContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfoHeadwaiter + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List MealPlanDinner { get; set; } = new(); + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordParagraph.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordParagraph.cs new file mode 100644 index 0000000..c8926b6 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordParagraph.cs @@ -0,0 +1,8 @@ +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class WordParagraph + { + public List<(string, WordTextProperties)> Texts { get; set; } = new(); + public WordTextProperties? TextProperties { get; set; } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordTextProperties.cs b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordTextProperties.cs new file mode 100644 index 0000000..24ce964 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/HelperModels/WordTextProperties.cs @@ -0,0 +1,11 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class WordTextProperties + { + public string Size { get; set; } = string.Empty; + public bool Bold { get; set; } + public WordJustificationType JustificationType { get; set; } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelClerc.cs new file mode 100644 index 0000000..dd543cf --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelClerc.cs @@ -0,0 +1,329 @@ +using BankBusinessLogic.OfficePackage.HelperModels; +using BankBusinessLogic.OfficePackage.HelperEnums; +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Office2013.Excel; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + public class SaveToExcelClerc : AbstractSaveToExcelClerc + { + + private SpreadsheetDocument? _spreadsheetDocument; + private SharedStringTablePart? _shareStringPart; + private Worksheet? _worksheet; + + private static void CreateStyles(WorkbookPart workbookpart) + { + var sp = workbookpart.AddNewPart(); + sp.Stylesheet = new Stylesheet(); + + var fonts = new Fonts() { Count = 2U, KnownFonts = true }; + + var fontUsual = new Font(); + fontUsual.Append(new FontSize() { Val = 12D }); + fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontUsual.Append(new FontName() { Val = "Times New Roman" }); + fontUsual.Append(new FontFamilyNumbering() { Val = 2 }); + fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + var fontTitle = new Font(); + fontTitle.Append(new Bold()); + fontTitle.Append(new FontSize() { Val = 14D }); + fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontTitle.Append(new FontName() { Val = "Times New Roman" }); + fontTitle.Append(new FontFamilyNumbering() { Val = 2 }); + fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + fonts.Append(fontUsual); + fonts.Append(fontTitle); + + var fills = new Fills() { Count = 2U }; + + var fill1 = new Fill(); + fill1.Append(new PatternFill() { PatternType = PatternValues.None }); + + var fill2 = new Fill(); + fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 }); + + fills.Append(fill1); + fills.Append(fill2); + + var borders = new Borders() { Count = 2U }; + + var borderNoBorder = new Border(); + borderNoBorder.Append(new LeftBorder()); + borderNoBorder.Append(new RightBorder()); + borderNoBorder.Append(new TopBorder()); + borderNoBorder.Append(new BottomBorder()); + borderNoBorder.Append(new DiagonalBorder()); + + var borderThin = new Border(); + + var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin }; + leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin }; + rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var topBorder = new TopBorder() { Style = BorderStyleValues.Thin }; + topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin }; + bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + borderThin.Append(leftBorder); + borderThin.Append(rightBorder); + borderThin.Append(topBorder); + borderThin.Append(bottomBorder); + borderThin.Append(new DiagonalBorder()); + + borders.Append(borderNoBorder); + borders.Append(borderThin); + + var cellStyleFormats = new CellStyleFormats() + { + Count = 1U + }; + var cellFormatStyle = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 0U + }; + + cellStyleFormats.Append(cellFormatStyle); + + var cellFormats = new CellFormats() + { + Count = 3U + }; + var cellFormatFont = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 0U, + FormatId = 0U, + ApplyFont = true + }; + var cellFormatFontAndBorder = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 1U, + FormatId = 0U, + ApplyFont = true, + ApplyBorder = true + }; + var cellFormatTitle = new CellFormat() + { + NumberFormatId = 0U, + FontId = 1U, + FillId = 0U, + BorderId = 0U, + FormatId = 0U, + Alignment = new Alignment() + { + Vertical = VerticalAlignmentValues.Center, + WrapText = true, + Horizontal = HorizontalAlignmentValues.Center + }, + ApplyFont = true + }; + cellFormats.Append(cellFormatFont); + cellFormats.Append(cellFormatFontAndBorder); + cellFormats.Append(cellFormatTitle); + var cellStyles = new CellStyles() { Count = 1U }; + cellStyles.Append(new CellStyle() + { + Name = "Normal", + FormatId = 0U, + BuiltinId = 0U + }); + var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() + { + Count = 0U + }; + + var tableStyles = new TableStyles() + { + Count = 0U, + DefaultTableStyle = "TableStyleMedium2", + DefaultPivotStyle = "PivotStyleLight16" + }; + var stylesheetExtensionList = new StylesheetExtensionList(); + var stylesheetExtension1 = new StylesheetExtension() + { + Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" + }; + stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); + stylesheetExtension1.Append(new SlicerStyles() + { + DefaultSlicerStyle = "SlicerStyleLight1" + }); + var stylesheetExtension2 = new StylesheetExtension() + { + Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" + }; + stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); + stylesheetExtension2.Append(new TimelineStyles() + { + DefaultTimelineStyle = "TimeSlicerStyleLight1" + }); + + stylesheetExtensionList.Append(stylesheetExtension1); + stylesheetExtensionList.Append(stylesheetExtension2); + + sp.Stylesheet.Append(fonts); + sp.Stylesheet.Append(fills); + sp.Stylesheet.Append(borders); + sp.Stylesheet.Append(cellStyleFormats); + sp.Stylesheet.Append(cellFormats); + sp.Stylesheet.Append(cellStyles); + sp.Stylesheet.Append(differentialFormats); + sp.Stylesheet.Append(tableStyles); + sp.Stylesheet.Append(stylesheetExtensionList); + } + + private static uint GetStyleValue(ExcelStyleInfoType styleInfo) + { + return styleInfo switch + { + ExcelStyleInfoType.Title => 2U, + ExcelStyleInfoType.TextWithBroder => 1U, + ExcelStyleInfoType.Text => 0U, + _ => 0U, + }; + } + + protected override void CreateExcel(ExcelInfoClerc info) + { + _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook); + var workbookpart = _spreadsheetDocument.AddWorkbookPart(); + workbookpart.Workbook = new Workbook(); + CreateStyles(workbookpart); + _shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType().First() : _spreadsheetDocument.WorkbookPart.AddNewPart(); + + if (_shareStringPart.SharedStringTable == null) + { + _shareStringPart.SharedStringTable = new SharedStringTable(); + } + + var worksheetPart = workbookpart.AddNewPart(); + worksheetPart.Worksheet = new Worksheet(new SheetData()); + + var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + var sheet = new Sheet() + { + Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), + SheetId = 1, + Name = "Лист" + }; + sheets.Append(sheet); + _worksheet = worksheetPart.Worksheet; + } + + protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) + { + if (_worksheet == null || _shareStringPart == null) + { + return; + } + + var sheetData = _worksheet.GetFirstChild(); + + if (sheetData == null) + { + return; + } + + Row row; + + if (sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).Any()) + { + row = sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).First(); + } + else + { + row = new Row() { RowIndex = excelParams.RowIndex }; + sheetData.Append(row); + } + + Cell cell; + + if (row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).Any()) + { + cell = row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).First(); + } + else + { + Cell? refCell = null; + foreach (Cell rowCell in row.Elements()) + { + if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0) + { + refCell = rowCell; + break; + } + } + var newCell = new Cell() + { + CellReference = excelParams.CellReference + }; + row.InsertBefore(newCell, refCell); + cell = newCell; + } + + _shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text))); + _shareStringPart.SharedStringTable.Save(); + cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements().Count() - 1).ToString()); + cell.DataType = new EnumValue(CellValues.SharedString); + cell.StyleIndex = GetStyleValue(excelParams.StyleInfo); + } + + protected override void MergeCells(ExcelMergeParameters excelParams) + { + if (_worksheet == null) + { + return; + } + MergeCells mergeCells; + if (_worksheet.Elements().Any()) + { + mergeCells = _worksheet.Elements().First(); + } + else + { + mergeCells = new MergeCells(); + if (_worksheet.Elements().Any()) + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + else + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + } + var mergeCell = new MergeCell() + { + Reference = new StringValue(excelParams.Merge) + }; + mergeCells.Append(mergeCell); + } + + protected override void SaveExcel(ExcelInfoClerc info) + { + if (_spreadsheetDocument == null) + { + return; + } + _spreadsheetDocument.WorkbookPart!.Workbook.Save(); + _spreadsheetDocument.Close(); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelHeadwaiter.cs new file mode 100644 index 0000000..86a6f6c --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToExcelHeadwaiter.cs @@ -0,0 +1,333 @@ +using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Office2013.Excel; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; +using DocumentFormat.OpenXml; +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + public class SaveToExcelHeadwaiter : AbstractSaveToExcelHeadwaiter + { + private SpreadsheetDocument? _spreadsheetDocument; + private SharedStringTablePart? _shareStringPart; + private Worksheet? _worksheet; + + private static void CreateStyles(WorkbookPart workbookpart) + { + var sp = workbookpart.AddNewPart(); + sp.Stylesheet = new Stylesheet(); + + var fonts = new Fonts() { Count = 2U, KnownFonts = true }; + + var fontUsual = new Font(); + fontUsual.Append(new FontSize() { Val = 12D }); + fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontUsual.Append(new FontName() { Val = "Times New Roman" }); + fontUsual.Append(new FontFamilyNumbering() { Val = 2 }); + fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + var fontTitle = new Font(); + fontTitle.Append(new Bold()); + fontTitle.Append(new FontSize() { Val = 14D }); + fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontTitle.Append(new FontName() { Val = "Times New Roman" }); + fontTitle.Append(new FontFamilyNumbering() { Val = 2 }); + fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + fonts.Append(fontUsual); + fonts.Append(fontTitle); + + var fills = new Fills() { Count = 2U }; + + var fill1 = new Fill(); + fill1.Append(new PatternFill() { PatternType = PatternValues.None }); + + var fill2 = new Fill(); + fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 }); + + fills.Append(fill1); + fills.Append(fill2); + + var borders = new Borders() { Count = 2U }; + + var borderNoBorder = new Border(); + borderNoBorder.Append(new LeftBorder()); + borderNoBorder.Append(new RightBorder()); + borderNoBorder.Append(new TopBorder()); + borderNoBorder.Append(new BottomBorder()); + borderNoBorder.Append(new DiagonalBorder()); + + var borderThin = new Border(); + + var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin }; + leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin }; + rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var topBorder = new TopBorder() { Style = BorderStyleValues.Thin }; + topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin }; + bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); + + borderThin.Append(leftBorder); + borderThin.Append(rightBorder); + borderThin.Append(topBorder); + borderThin.Append(bottomBorder); + borderThin.Append(new DiagonalBorder()); + + borders.Append(borderNoBorder); + borders.Append(borderThin); + + var cellStyleFormats = new CellStyleFormats() + { + Count = 1U + }; + var cellFormatStyle = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 0U + }; + + cellStyleFormats.Append(cellFormatStyle); + + var cellFormats = new CellFormats() + { + Count = 3U + }; + var cellFormatFont = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 0U, + FormatId = 0U, + ApplyFont = true + }; + var cellFormatFontAndBorder = new CellFormat() + { + NumberFormatId = 0U, + FontId = 0U, + FillId = 0U, + BorderId = 1U, + FormatId = 0U, + ApplyFont = true, + ApplyBorder = true + }; + var cellFormatTitle = new CellFormat() + { + NumberFormatId = 0U, + FontId = 1U, + FillId = 0U, + BorderId = 0U, + FormatId = 0U, + Alignment = new Alignment() + { + Vertical = VerticalAlignmentValues.Center, + WrapText = true, + Horizontal = HorizontalAlignmentValues.Center + }, + ApplyFont = true + }; + cellFormats.Append(cellFormatFont); + cellFormats.Append(cellFormatFontAndBorder); + cellFormats.Append(cellFormatTitle); + var cellStyles = new CellStyles() { Count = 1U }; + cellStyles.Append(new CellStyle() + { + Name = "Normal", + FormatId = 0U, + BuiltinId = 0U + }); + var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() + { + Count = 0U + }; + + var tableStyles = new TableStyles() + { + Count = 0U, + DefaultTableStyle = "TableStyleMedium2", + DefaultPivotStyle = "PivotStyleLight16" + }; + var stylesheetExtensionList = new StylesheetExtensionList(); + var stylesheetExtension1 = new StylesheetExtension() + { + Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" + }; + stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); + stylesheetExtension1.Append(new SlicerStyles() + { + DefaultSlicerStyle = "SlicerStyleLight1" + }); + var stylesheetExtension2 = new StylesheetExtension() + { + Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" + }; + stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); + stylesheetExtension2.Append(new TimelineStyles() + { + DefaultTimelineStyle = "TimeSlicerStyleLight1" + }); + + stylesheetExtensionList.Append(stylesheetExtension1); + stylesheetExtensionList.Append(stylesheetExtension2); + + sp.Stylesheet.Append(fonts); + sp.Stylesheet.Append(fills); + sp.Stylesheet.Append(borders); + sp.Stylesheet.Append(cellStyleFormats); + sp.Stylesheet.Append(cellFormats); + sp.Stylesheet.Append(cellStyles); + sp.Stylesheet.Append(differentialFormats); + sp.Stylesheet.Append(tableStyles); + sp.Stylesheet.Append(stylesheetExtensionList); + } + + private static uint GetStyleValue(ExcelStyleInfoType styleInfo) + { + return styleInfo switch + { + ExcelStyleInfoType.Title => 2U, + ExcelStyleInfoType.TextWithBroder => 1U, + ExcelStyleInfoType.Text => 0U, + _ => 0U, + }; + } + + protected override void CreateExcel(ExcelInfoHeadwaiter info) + { + _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook); + var workbookpart = _spreadsheetDocument.AddWorkbookPart(); + workbookpart.Workbook = new Workbook(); + CreateStyles(workbookpart); + _shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType().First() : _spreadsheetDocument.WorkbookPart.AddNewPart(); + + if (_shareStringPart.SharedStringTable == null) + { + _shareStringPart.SharedStringTable = new SharedStringTable(); + } + + var worksheetPart = workbookpart.AddNewPart(); + worksheetPart.Worksheet = new Worksheet(new SheetData()); + + var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + var sheet = new Sheet() + { + Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), + SheetId = 1, + Name = "Лист" + }; + sheets.Append(sheet); + _worksheet = worksheetPart.Worksheet; + } + + protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) + { + if (_worksheet == null || _shareStringPart == null) + { + return; + } + + var sheetData = _worksheet.GetFirstChild(); + + if (sheetData == null) + { + return; + } + + Row row; + + if (sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).Any()) + { + row = sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).First(); + } + else + { + row = new Row() { RowIndex = excelParams.RowIndex }; + sheetData.Append(row); + } + + Cell cell; + + if (row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).Any()) + { + cell = row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).First(); + } + else + { + Cell? refCell = null; + foreach (Cell rowCell in row.Elements()) + { + if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0) + { + refCell = rowCell; + break; + } + } + var newCell = new Cell() + { + CellReference = excelParams.CellReference + }; + row.InsertBefore(newCell, refCell); + cell = newCell; + } + + _shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text))); + _shareStringPart.SharedStringTable.Save(); + cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements().Count() - 1).ToString()); + cell.DataType = new EnumValue(CellValues.SharedString); + cell.StyleIndex = GetStyleValue(excelParams.StyleInfo); + } + + protected override void MergeCells(ExcelMergeParameters excelParams) + { + if (_worksheet == null) + { + return; + } + MergeCells mergeCells; + if (_worksheet.Elements().Any()) + { + mergeCells = _worksheet.Elements().First(); + } + else + { + mergeCells = new MergeCells(); + if (_worksheet.Elements().Any()) + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + else + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + } + var mergeCell = new MergeCell() + { + Reference = new StringValue(excelParams.Merge) + }; + mergeCells.Append(mergeCell); + } + + protected override void SaveExcel(ExcelInfoHeadwaiter info) + { + if (_spreadsheetDocument == null) + { + return; + } + _spreadsheetDocument.WorkbookPart!.Workbook.Save(); + _spreadsheetDocument.Close(); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfClerc.cs new file mode 100644 index 0000000..29c79c1 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfClerc.cs @@ -0,0 +1,98 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using MigraDoc.DocumentObjectModel; +using MigraDoc.DocumentObjectModel.Tables; +using MigraDoc.Rendering; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + public class SaveToPdfClerc : AbstractSaveToPdfClerc + { + private Document? _document; + private Section? _section; + private Table? _table; + private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type) + { + return type switch + { + PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, + PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, + PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right, + _ => ParagraphAlignment.Justify, + }; + } + private static void DefineStyles(Document document) + { + var style = document.Styles["Normal"]; + style.Font.Name = "Times New Roman"; + style.Font.Size = 14; + style = document.Styles.AddStyle("NormalTitle", "Normal"); + style.Font.Bold = true; + } + protected override void CreateParagraph(PdfParagraph pdfParagraph) + { + if (_section == null) + { + return; + } + var paragraph = _section.AddParagraph(pdfParagraph.Text); + paragraph.Format.SpaceAfter = "1cm"; + paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment); + paragraph.Style = pdfParagraph.Style; + } + + protected override void CreatePdf(PdfInfoClerc info) + { + _document = new Document(); + DefineStyles(_document); + _section = _document.AddSection(); + } + + protected override void CreateRow(PdfRowParameters rowParameters) + { + if (_table == null) + { + return; + } + var row = _table.AddRow(); + for (int i = 0; i < rowParameters.Texts.Count; ++i) + { + row.Cells[i].AddParagraph(rowParameters.Texts[i]); + if (!string.IsNullOrEmpty(rowParameters.Style)) + { + row.Cells[i].Style = rowParameters.Style; + } + Unit borderWidth = 0.5; + row.Cells[i].Borders.Left.Width = borderWidth; + row.Cells[i].Borders.Right.Width = borderWidth; + row.Cells[i].Borders.Top.Width = borderWidth; + row.Cells[i].Borders.Bottom.Width = borderWidth; + row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment); + row.Cells[i].VerticalAlignment = VerticalAlignment.Center; + } + } + + protected override void CreateTable(List columns) + { + if (_document == null) + { + return; + } + _table = _document.LastSection.AddTable(); + foreach (var elem in columns) + { + _table.AddColumn(elem); + } + } + + protected override void SavePdf(PdfInfoClerc info) + { + var renderer = new PdfDocumentRenderer(true) + { + Document = _document + }; + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfHeadwaiter.cs new file mode 100644 index 0000000..a45d02b --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToPdfHeadwaiter.cs @@ -0,0 +1,103 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using MigraDoc.DocumentObjectModel; +using MigraDoc.Rendering; +using MigraDoc.DocumentObjectModel.Tables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + internal class SaveToPdfHeadwaiter : AbstractSaveToPdfHeadwaiter + { + private Document? _document; + private Section? _section; + private Table? _table; + private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type) + { + return type switch + { + PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, + PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, + PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right, + _ => ParagraphAlignment.Justify, + }; + } + private static void DefineStyles(Document document) + { + var style = document.Styles["Normal"]; + style.Font.Name = "Times New Roman"; + style.Font.Size = 14; + style = document.Styles.AddStyle("NormalTitle", "Normal"); + style.Font.Bold = true; + } + protected override void CreateParagraph(PdfParagraph pdfParagraph) + { + if (_section == null) + { + return; + } + var paragraph = _section.AddParagraph(pdfParagraph.Text); + paragraph.Format.SpaceAfter = "1cm"; + paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment); + paragraph.Style = pdfParagraph.Style; + } + + protected override void CreatePdf(PdfInfoHeadwaiter info) + { + _document = new Document(); + DefineStyles(_document); + _section = _document.AddSection(); + } + + protected override void CreateRow(PdfRowParameters rowParameters) + { + if (_table == null) + { + return; + } + var row = _table.AddRow(); + for (int i = 0; i < rowParameters.Texts.Count; ++i) + { + row.Cells[i].AddParagraph(rowParameters.Texts[i]); + if (!string.IsNullOrEmpty(rowParameters.Style)) + { + row.Cells[i].Style = rowParameters.Style; + } + Unit borderWidth = 0.5; + row.Cells[i].Borders.Left.Width = borderWidth; + row.Cells[i].Borders.Right.Width = borderWidth; + row.Cells[i].Borders.Top.Width = borderWidth; + row.Cells[i].Borders.Bottom.Width = borderWidth; + row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment); + row.Cells[i].VerticalAlignment = VerticalAlignment.Center; + } + } + + protected override void CreateTable(List columns) + { + if (_document == null) + { + return; + } + _table = _document.LastSection.AddTable(); + foreach (var elem in columns) + { + _table.AddColumn(elem); + } + } + + protected override void SavePdf(PdfInfoHeadwaiter info) + { + var renderer = new PdfDocumentRenderer(true) + { + Document = _document + }; + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordClerc.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordClerc.cs new file mode 100644 index 0000000..66efada --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordClerc.cs @@ -0,0 +1,123 @@ +using BankBusinessLogic.OfficePackage.HelperModels; +using BankBusinessLogic.OfficePackage.HelperEnums; +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + public class SaveToWordClerc : AbstractSaveToWordClerc + { + private WordprocessingDocument? _wordDocument; + private Body? _docBody; + private static JustificationValues GetJustificationValues(WordJustificationType type) + { + return type switch + { + WordJustificationType.Both => JustificationValues.Both, + WordJustificationType.Center => JustificationValues.Center, + _ => JustificationValues.Left, + }; + } + + private static SectionProperties CreateSectionProperties() + { + var properties = new SectionProperties(); + var pageSize = new PageSize + { + Orient = PageOrientationValues.Portrait + }; + properties.AppendChild(pageSize); + return properties; + } + + private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties) + { + if (paragraphProperties == null) + { + return null; + } + + var properties = new ParagraphProperties(); + + properties.AppendChild(new Justification() + { + Val = GetJustificationValues(paragraphProperties.JustificationType) + }); + + properties.AppendChild(new SpacingBetweenLines + { + LineRule = LineSpacingRuleValues.Auto + }); + + properties.AppendChild(new Indentation()); + var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); + + if (!string.IsNullOrEmpty(paragraphProperties.Size)) + { + paragraphMarkRunProperties.AppendChild(new FontSize + { + Val = paragraphProperties.Size + }); + } + + properties.AppendChild(paragraphMarkRunProperties); + + return properties; + } + protected override void CreateParagraph(WordParagraph paragraph) + { + if (_docBody == null || paragraph == null) + { + return; + } + + var docParagraph = new Paragraph(); + + docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties)); + + foreach (var run in paragraph.Texts) + { + var docRun = new Run(); + var properties = new RunProperties(); + properties.AppendChild(new FontSize { Val = run.Item2.Size }); + + if (run.Item2.Bold) + { + properties.AppendChild(new Bold()); + } + + docRun.AppendChild(properties); + + docRun.AppendChild(new Text + { + Text = run.Item1, + Space = SpaceProcessingModeValues.Preserve + }); + + docParagraph.AppendChild(docRun); + } + _docBody.AppendChild(docParagraph); + } + + protected override void CreateWord(WordInfoClerc info) + { + _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); + MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); + mainPart.Document = new Document(); + _docBody = mainPart.Document.AppendChild(new Body()); + } + + protected override void SaveWord(WordInfoClerc info) + { + if (_docBody == null || _wordDocument == null) + { + return; + } + + _docBody.AppendChild(CreateSectionProperties()); + _wordDocument.MainDocumentPart!.Document.Save(); + _wordDocument.Close(); + } + } +} diff --git a/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordHeadwaiter.cs b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordHeadwaiter.cs new file mode 100644 index 0000000..eba98f8 --- /dev/null +++ b/Bank/BankBuisinessLogics/OfficePackage/Implements/SaveToWordHeadwaiter.cs @@ -0,0 +1,128 @@ +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using DocumentFormat.OpenXml; +using BankBusinessLogic.OfficePackage.HelperEnums; +using BankBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.Implements +{ + public class SaveToWordHeadwaiter : AbstractSaveToWordHeadwaitre + { + private WordprocessingDocument? _wordDocument; + private Body? _docBody; + private static JustificationValues GetJustificationValues(WordJustificationType type) + { + return type switch + { + WordJustificationType.Both => JustificationValues.Both, + WordJustificationType.Center => JustificationValues.Center, + _ => JustificationValues.Left, + }; + } + + private static SectionProperties CreateSectionProperties() + { + var properties = new SectionProperties(); + var pageSize = new PageSize + { + Orient = PageOrientationValues.Portrait + }; + properties.AppendChild(pageSize); + return properties; + } + + private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties) + { + if (paragraphProperties == null) + { + return null; + } + + var properties = new ParagraphProperties(); + + properties.AppendChild(new Justification() + { + Val = GetJustificationValues(paragraphProperties.JustificationType) + }); + + properties.AppendChild(new SpacingBetweenLines + { + LineRule = LineSpacingRuleValues.Auto + }); + + properties.AppendChild(new Indentation()); + var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); + + if (!string.IsNullOrEmpty(paragraphProperties.Size)) + { + paragraphMarkRunProperties.AppendChild(new FontSize + { + Val = paragraphProperties.Size + }); + } + + properties.AppendChild(paragraphMarkRunProperties); + + return properties; + } + protected override void CreateParagraph(WordParagraph paragraph) + { + if (_docBody == null || paragraph == null) + { + return; + } + + var docParagraph = new Paragraph(); + + docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties)); + + foreach (var run in paragraph.Texts) + { + var docRun = new Run(); + var properties = new RunProperties(); + properties.AppendChild(new FontSize { Val = run.Item2.Size }); + + if (run.Item2.Bold) + { + properties.AppendChild(new Bold()); + } + + docRun.AppendChild(properties); + + docRun.AppendChild(new Text + { + Text = run.Item1, + Space = SpaceProcessingModeValues.Preserve + }); + + docParagraph.AppendChild(docRun); + } + _docBody.AppendChild(docParagraph); + } + + protected override void CreateWord(WordInfoHeadwaiter info) + { + _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); + MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); + mainPart.Document = new Document(); + _docBody = mainPart.Document.AppendChild(new Body()); + } + + protected override void SaveWord(WordInfoHeadwaiter info) + { + if (_docBody == null || _wordDocument == null) + { + return; + } + + _docBody.AppendChild(CreateSectionProperties()); + _wordDocument.MainDocumentPart!.Document.Save(); + _wordDocument.Close(); + } + } +} \ No newline at end of file diff --git a/Bank/BankContracts/BankContracts.csproj b/Bank/BankContracts/BankContracts.csproj new file mode 100644 index 0000000..7b8dd2d --- /dev/null +++ b/Bank/BankContracts/BankContracts.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/Bank/BankContracts/BindingModels/ClercBindingModel.cs b/Bank/BankContracts/BindingModels/ClercBindingModel.cs new file mode 100644 index 0000000..a3844c1 --- /dev/null +++ b/Bank/BankContracts/BindingModels/ClercBindingModel.cs @@ -0,0 +1,19 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class ClercBindingModel : IClercModel + { + public string OrganiserFIO { get; set; } = string.Empty; + + public string OrganiserPassword { get; set; } = string.Empty; + + public string OrganiserLogin { get; set; } = string.Empty; + + public string OrganiserEmail { get; set; } = string.Empty; + + public string OrganiserNumber { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/ConferenceBindingModel.cs b/Bank/BankContracts/BindingModels/ConferenceBindingModel.cs new file mode 100644 index 0000000..e4e3426 --- /dev/null +++ b/Bank/BankContracts/BindingModels/ConferenceBindingModel.cs @@ -0,0 +1,16 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class ConferenceBindingModel : IConferenceModel + { + public string ConferenceName { get; set; } = string.Empty; + + public DateTime StartDate { get; set; } = DateTime.Now; + + public int Id { get; set; } + + public int OrganiserId { get; set; } + public Dictionary ConferenceMembers { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/ConferenceBookingBindingModel.cs b/Bank/BankContracts/BindingModels/ConferenceBookingBindingModel.cs new file mode 100644 index 0000000..9478e6e --- /dev/null +++ b/Bank/BankContracts/BindingModels/ConferenceBookingBindingModel.cs @@ -0,0 +1,14 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class ConferenceBookingBindingModel : IConferenceBookingModel + { + public int HeadwaiterId { get; set; } + + public int ConferenceId { get; set; } + + public int Id { get; set; } + public Dictionary ConferenceBookingDinners { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/DinnerBindingModel.cs b/Bank/BankContracts/BindingModels/DinnerBindingModel.cs new file mode 100644 index 0000000..37dc2cf --- /dev/null +++ b/Bank/BankContracts/BindingModels/DinnerBindingModel.cs @@ -0,0 +1,15 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class DinnerBindingModel : IDinnerModel + { + public string DinnerName { get; set; } = string.Empty; + + public double DinnerPrice { get; set; } + + public int HeadwaiterId { get; set; } + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs b/Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs new file mode 100644 index 0000000..d471551 --- /dev/null +++ b/Bank/BankContracts/BindingModels/HeadwaiterBindingModel.cs @@ -0,0 +1,19 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class HeadwaiterBindingModel : IHeadwaiterModel + { + public string HeadwaiterFIO { get; set; } = string.Empty; + + public string HeadwaiterPassword { get; set; } = string.Empty; + + public string HeadwaiterLogin { get; set; } = string.Empty; + + public string HeadwaiterEmail { get; set; } = string.Empty; + + public string HeadwaiterNumber { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/MealPlanBindingModel.cs b/Bank/BankContracts/BindingModels/MealPlanBindingModel.cs new file mode 100644 index 0000000..72161f5 --- /dev/null +++ b/Bank/BankContracts/BindingModels/MealPlanBindingModel.cs @@ -0,0 +1,16 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class MealPlanBindingModel : IMealPlanModel + { + public string MealPlanName { get; set; } = string.Empty; + + public double MealPlanPrice { get; set; } + + public int OrganiserId { get; set; } + + public int Id { get; set; } + public Dictionary MealPlanMembers { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/MemberBindingModel.cs b/Bank/BankContracts/BindingModels/MemberBindingModel.cs new file mode 100644 index 0000000..2f06b21 --- /dev/null +++ b/Bank/BankContracts/BindingModels/MemberBindingModel.cs @@ -0,0 +1,15 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class MemberBindingModel : IMemberModel + { + public string MemberFIO { get; set; } = string.Empty; + + public string Citizenship { get; set; } = string.Empty; + + public int OrganiserId { get; set; } + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/ReportBindingModel.cs b/Bank/BankContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..5575ff8 --- /dev/null +++ b/Bank/BankContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,10 @@ +namespace BankContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + public int OrganiserId { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs b/Bank/BankContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs new file mode 100644 index 0000000..f0afd5f --- /dev/null +++ b/Bank/BankContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BindingModels +{ + public class ReportHeadwaiterBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + public int HeadwaiterId { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/RoomBindingModel.cs b/Bank/BankContracts/BindingModels/RoomBindingModel.cs new file mode 100644 index 0000000..38a3d85 --- /dev/null +++ b/Bank/BankContracts/BindingModels/RoomBindingModel.cs @@ -0,0 +1,20 @@ +using BankDataModels.Models; + +namespace BankContracts.BindingModels +{ + public class RoomBindingModel : IRoomModel + { + public string RoomName { get; set; } = string.Empty; + + public string RoomFrame { get; set; } = string.Empty; + + public double RoomPrice { get; set; } + + public int HeadwaiterId { get; set; } + + public int MealPlanId { get; set; } + + public int Id { get; set; } + public Dictionary RoomDinners { get; set; } + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs new file mode 100644 index 0000000..21bd5ad --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IClercLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IClercLogic + { + List? ReadList(ClercSearchModel? model); + ClercViewModel? ReadElement(ClercSearchModel model); + bool Create(ClercBindingModel model); + bool Update(ClercBindingModel model); + bool Delete(ClercBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs new file mode 100644 index 0000000..7cb8ae7 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IConferenceBookingLogic + { + List? ReadList(ConferenceBookingSearchModel? model); + ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model); + bool Create(ConferenceBookingBindingModel model); + bool Update(ConferenceBookingBindingModel model); + bool Delete(ConferenceBookingBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IConferenceLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IConferenceLogic.cs new file mode 100644 index 0000000..0f863fd --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IConferenceLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IConferenceLogic + { + List? ReadList(ConferenceSearchModel? model); + ConferenceViewModel? ReadElement(ConferenceSearchModel model); + bool Create(ConferenceBindingModel model); + bool Update(ConferenceBindingModel model); + bool Delete(ConferenceBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs new file mode 100644 index 0000000..5f4660e --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IDinnerLogic.cs @@ -0,0 +1,16 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IDinnerLogic + { + List? ReadList(DinnerSearchModel? model); + DinnerViewModel? ReadElement(DinnerSearchModel model); + bool Create(DinnerBindingModel model); + bool Update(DinnerBindingModel model); + bool Delete(DinnerBindingModel model); + + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IHeadwaiterLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IHeadwaiterLogic.cs new file mode 100644 index 0000000..7894325 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IHeadwaiterLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IHeadwaiterLogic + { + List? ReadList(HeadwaiterSearchModel? model); + HeadwaiterViewModel? ReadElement(HeadwaiterSearchModel model); + bool Create(HeadwaiterBindingModel model); + bool Update(HeadwaiterBindingModel model); + bool Delete(HeadwaiterBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs new file mode 100644 index 0000000..f4fc0d8 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IMealPlanLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IMealPlanLogic + { + List? ReadList(MealPlanSearchModel? model); + MealPlanViewModel? ReadElement(MealPlanSearchModel model); + bool Create(MealPlanBindingModel model); + bool Update(MealPlanBindingModel model); + bool Delete(MealPlanBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs new file mode 100644 index 0000000..eb693be --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IMemberLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IMemberLogic + { + List? ReadList(MemberSearchModel? model); + MemberViewModel? ReadElement(MemberSearchModel model); + bool Create(MemberBindingModel model); + bool Update(MemberBindingModel model); + bool Delete(MemberBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs new file mode 100644 index 0000000..4e6f206 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs @@ -0,0 +1,19 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IReportHeadwaiterLogic + { + List GetMealPlanDinner(); + List GetConferenceBindingRooms(ReportHeadwaiterBindingModel model); + void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model); + void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model); + void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IReportOrganiserLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IReportOrganiserLogic.cs new file mode 100644 index 0000000..99c7672 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IReportOrganiserLogic.cs @@ -0,0 +1,14 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IReportOrganiserLogic + { + List GetMemberConference(); + List GetMembers(ReportBindingModel model); + void SaveMemberConferenceToWordFile(ReportBindingModel model); + void SaveMemberConferenceToExcelFile(ReportBindingModel model); + void SaveMembersToPdfFile(ReportBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs new file mode 100644 index 0000000..89cd4b2 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/IRoomLogic.cs @@ -0,0 +1,15 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.BusinessLogicsContracts +{ + public interface IRoomLogic + { + List? ReadList(RoomSearchModel? model); + RoomViewModel? ReadElement(RoomSearchModel model); + bool Create(RoomBindingModel model); + bool Update(RoomBindingModel model); + bool Delete(RoomBindingModel model); + } +} diff --git a/Bank/BankContracts/SearchModels/ClercSearchModel.cs b/Bank/BankContracts/SearchModels/ClercSearchModel.cs new file mode 100644 index 0000000..aaf951d --- /dev/null +++ b/Bank/BankContracts/SearchModels/ClercSearchModel.cs @@ -0,0 +1,10 @@ +namespace BankContracts.SearchModels +{ + public class ClercSearchModel + { + public int? Id { get; set; } + public string? OrganiserFIO { get; set; } + public string? OrganiserLogin { get; set; } + public string? OrganiserPassword { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/ConferenceBookingSearchModel.cs b/Bank/BankContracts/SearchModels/ConferenceBookingSearchModel.cs new file mode 100644 index 0000000..6232a2e --- /dev/null +++ b/Bank/BankContracts/SearchModels/ConferenceBookingSearchModel.cs @@ -0,0 +1,11 @@ + +namespace BankContracts.SearchModels +{ + public class ConferenceBookingSearchModel + { + public int? Id { get; set; } + public int? HeadwaiterId { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/ConferenceSearchModel.cs b/Bank/BankContracts/SearchModels/ConferenceSearchModel.cs new file mode 100644 index 0000000..cd96e91 --- /dev/null +++ b/Bank/BankContracts/SearchModels/ConferenceSearchModel.cs @@ -0,0 +1,11 @@ +namespace BankContracts.SearchModels +{ + public class ConferenceSearchModel + { + public int? Id { get; set; } + public string? ConferenceName { get; set; } + public int? OrganiserId { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/DinnerSearchModel.cs b/Bank/BankContracts/SearchModels/DinnerSearchModel.cs new file mode 100644 index 0000000..76fa3ba --- /dev/null +++ b/Bank/BankContracts/SearchModels/DinnerSearchModel.cs @@ -0,0 +1,9 @@ + +namespace BankContracts.SearchModels +{ + public class DinnerSearchModel + { + public string? DinnerName { get; set; } + public int? Id { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs b/Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs new file mode 100644 index 0000000..0407f79 --- /dev/null +++ b/Bank/BankContracts/SearchModels/HeadwaiterSearchModel.cs @@ -0,0 +1,13 @@ + +namespace BankContracts.SearchModels +{ + public class HeadwaiterSearchModel + { + public string? HeadwaiterFIO { get; set; } + + public string? HeadwaiterPassword { get; set; } + + public string? HeadwaiterLogin { get; set; } + public int? Id { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/MealPlanSearchModel.cs b/Bank/BankContracts/SearchModels/MealPlanSearchModel.cs new file mode 100644 index 0000000..65b6953 --- /dev/null +++ b/Bank/BankContracts/SearchModels/MealPlanSearchModel.cs @@ -0,0 +1,8 @@ +namespace BankContracts.SearchModels +{ + public class MealPlanSearchModel + { + public int? Id { get; set; } + public string? MealPlanName { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/MemberSearchModel.cs b/Bank/BankContracts/SearchModels/MemberSearchModel.cs new file mode 100644 index 0000000..5103952 --- /dev/null +++ b/Bank/BankContracts/SearchModels/MemberSearchModel.cs @@ -0,0 +1,8 @@ +namespace BankContracts.SearchModels +{ + public class MemberSearchModel + { + public int? Id { get; set; } + public string? MemberFIO { get; set; } + } +} diff --git a/Bank/BankContracts/SearchModels/RoomSearchModel.cs b/Bank/BankContracts/SearchModels/RoomSearchModel.cs new file mode 100644 index 0000000..8ac78f6 --- /dev/null +++ b/Bank/BankContracts/SearchModels/RoomSearchModel.cs @@ -0,0 +1,9 @@ + +namespace BankContracts.SearchModels +{ + public class RoomSearchModel + { + public string? RoomName { get; set; } + public int? Id { get; set; } + } +} diff --git a/Bank/BankContracts/StoragesContracts/IClercStorage.cs b/Bank/BankContracts/StoragesContracts/IClercStorage.cs new file mode 100644 index 0000000..dd06aad --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IClercStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IClercStorage + { + List GetFullList(); + + List GetFilteredList(ClercSearchModel model); + + ClercViewModel? GetElement(ClercSearchModel model); + + ClercViewModel? Insert(ClercBindingModel model); + + ClercViewModel? Update(ClercBindingModel model); + + ClercViewModel? Delete(ClercBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IConferenceBookingStorage.cs b/Bank/BankContracts/StoragesContracts/IConferenceBookingStorage.cs new file mode 100644 index 0000000..626c485 --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IConferenceBookingStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IConferenceBookingStorage + { + List GetFullList(); + + List GetFilteredList(ConferenceBookingSearchModel model); + + ConferenceBookingViewModel? GetElement(ConferenceBookingSearchModel model); + + ConferenceBookingViewModel? Insert(ConferenceBookingBindingModel model); + + ConferenceBookingViewModel? Update(ConferenceBookingBindingModel model); + + ConferenceBookingViewModel? Delete(ConferenceBookingBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IConferenceStorage.cs b/Bank/BankContracts/StoragesContracts/IConferenceStorage.cs new file mode 100644 index 0000000..93fc09a --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IConferenceStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IConferenceStorage + { + List GetFullList(); + + List GetFilteredList(ConferenceSearchModel model); + + ConferenceViewModel? GetElement(ConferenceSearchModel model); + + ConferenceViewModel? Insert(ConferenceBindingModel model); + + ConferenceViewModel? Update(ConferenceBindingModel model); + + ConferenceViewModel? Delete(ConferenceBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IDinnerStorage.cs b/Bank/BankContracts/StoragesContracts/IDinnerStorage.cs new file mode 100644 index 0000000..96b6ae2 --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IDinnerStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IDinnerStorage + { + List GetFullList(); + + List GetFilteredList(DinnerSearchModel model); + + DinnerViewModel? GetElement(DinnerSearchModel model); + + DinnerViewModel? Insert(DinnerBindingModel model); + + DinnerViewModel? Update(DinnerBindingModel model); + + DinnerViewModel? Delete(DinnerBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs b/Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs new file mode 100644 index 0000000..06f96a0 --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IHeadwaiterStorage + { + List GetFullList(); + + List GetFilteredList(HeadwaiterSearchModel model); + + HeadwaiterViewModel? GetElement(HeadwaiterSearchModel model); + + HeadwaiterViewModel? Insert(HeadwaiterBindingModel model); + + HeadwaiterViewModel? Update(HeadwaiterBindingModel model); + + HeadwaiterViewModel? Delete(HeadwaiterBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs b/Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs new file mode 100644 index 0000000..1af739b --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IMealPlanStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IMealPlanStorage + { + List GetFullList(); + + List GetFilteredList(MealPlanSearchModel model); + + MealPlanViewModel? GetElement(MealPlanSearchModel model); + + MealPlanViewModel? Insert(MealPlanBindingModel model); + + MealPlanViewModel? Update(MealPlanBindingModel model); + + MealPlanViewModel? Delete(MealPlanBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IMemberStorage.cs b/Bank/BankContracts/StoragesContracts/IMemberStorage.cs new file mode 100644 index 0000000..ce3f6ae --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IMemberStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IMemberStorage + { + List GetFullList(); + + List GetFilteredList(MemberSearchModel model); + + MemberViewModel? GetElement(MemberSearchModel model); + + MemberViewModel? Insert(MemberBindingModel model); + + MemberViewModel? Update(MemberBindingModel model); + + MemberViewModel? Delete(MemberBindingModel model); + } +} diff --git a/Bank/BankContracts/StoragesContracts/IRoomStorage.cs b/Bank/BankContracts/StoragesContracts/IRoomStorage.cs new file mode 100644 index 0000000..953c584 --- /dev/null +++ b/Bank/BankContracts/StoragesContracts/IRoomStorage.cs @@ -0,0 +1,21 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.ViewModels; + +namespace BankContracts.StoragesContracts +{ + public interface IRoomStorage + { + List GetFullList(); + + List GetFilteredList(RoomSearchModel model); + + RoomViewModel? GetElement(RoomSearchModel model); + + RoomViewModel? Insert(RoomBindingModel model); + + RoomViewModel? Update(RoomBindingModel model); + + RoomViewModel? Delete(RoomBindingModel model); + } +} diff --git a/Bank/BankContracts/ViewModels/ClercViewModel.cs b/Bank/BankContracts/ViewModels/ClercViewModel.cs new file mode 100644 index 0000000..3401ab5 --- /dev/null +++ b/Bank/BankContracts/ViewModels/ClercViewModel.cs @@ -0,0 +1,25 @@ +using BankDataModels.Models; +using System.ComponentModel; + +namespace BankContracts.ViewModels +{ + public class ClercViewModel : IClercModel + { + [DisplayName("ФИО организатора")] + public string OrganiserFIO { get; set; } = string.Empty; + + [DisplayName("Пароль организатора")] + public string OrganiserPassword { get; set; } = string.Empty; + + [DisplayName("Логин организатора")] + public string OrganiserLogin { get; set; } = string.Empty; + + [DisplayName("Эл. почта организатора")] + public string OrganiserEmail { get; set; } = string.Empty; + + [DisplayName("Номер телефона организатора")] + public string OrganiserNumber { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs b/Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs new file mode 100644 index 0000000..d052c8c --- /dev/null +++ b/Bank/BankContracts/ViewModels/ConferenceBookingViewModel.cs @@ -0,0 +1,19 @@ +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class ConferenceBookingViewModel : IConferenceBookingModel + { + public int HeadwaiterId { get; set; } + + public int ConferenceId { get; set; } + + public int Id { get; set; } + public Dictionary ConferenceBookingDinners { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/ConferenceViewModel.cs b/Bank/BankContracts/ViewModels/ConferenceViewModel.cs new file mode 100644 index 0000000..264cc3a --- /dev/null +++ b/Bank/BankContracts/ViewModels/ConferenceViewModel.cs @@ -0,0 +1,19 @@ +using BankDataModels.Models; +using System.ComponentModel; + +namespace BankContracts.ViewModels +{ + public class ConferenceViewModel : IConferenceModel + { + [DisplayName("Название конференции")] + public string ConferenceName { get; set; } = string.Empty; + + [DisplayName("Дата начала конференции")] + public DateTime StartDate { get; set; } + + public int OrganiserId { get; set; } + + public int Id { get; set; } + public Dictionary ConferenceMembers { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/DinnerViewModel.cs b/Bank/BankContracts/ViewModels/DinnerViewModel.cs new file mode 100644 index 0000000..876f6fd --- /dev/null +++ b/Bank/BankContracts/ViewModels/DinnerViewModel.cs @@ -0,0 +1,19 @@ +using BankDataModels.Models; +using System.ComponentModel; + + +namespace BankContracts.ViewModels +{ + public class DinnerViewModel : IDinnerModel + { + public int Id { get; set; } + public int HeadwaiterId { get; set; } + + [DisplayName("Название обеда")] + public string DinnerName { get; set; } = string.Empty; + + [DisplayName("Цена обеда")] + public double DinnerPrice { get; set; } + } +} + diff --git a/Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs b/Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs new file mode 100644 index 0000000..2db62e4 --- /dev/null +++ b/Bank/BankContracts/ViewModels/HeadwaiterViewModel.cs @@ -0,0 +1,31 @@ +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class HeadwaiterViewModel : IHeadwaiterModel + { + public int Id { get; set; } + + [DisplayName("ФИО метрдотеля")] + public string HeadwaiterFIO { get; set; } = string.Empty; + + [DisplayName("Пароль метрдотеля")] + public string HeadwaiterPassword { get; set; } = string.Empty; + + [DisplayName("Логин метрдотеля")] + public string HeadwaiterLogin { get; set; } = string.Empty; + + [DisplayName("Mail метрдотеля")] + public string HeadwaiterEmail { get; set; } = string.Empty; + + [DisplayName("Телефон метрдотеля")] + public string HeadwaiterNumber { get; set; } = string.Empty; + + } +} diff --git a/Bank/BankContracts/ViewModels/MealPlanViewModel.cs b/Bank/BankContracts/ViewModels/MealPlanViewModel.cs new file mode 100644 index 0000000..ba17d58 --- /dev/null +++ b/Bank/BankContracts/ViewModels/MealPlanViewModel.cs @@ -0,0 +1,20 @@ +using BankDataModels.Models; +using System.ComponentModel; + +namespace BankContracts.ViewModels +{ + public class MealPlanViewModel : IMealPlanModel + { + [DisplayName("Название плана питания")] + public string MealPlanName { get; set; } = string.Empty; + + [DisplayName("Цена плана питания")] + public double MealPlanPrice { get; set; } + + public int OrganiserId { get; set; } + + public int Id { get; set; } + + public Dictionary MealPlanMembers { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/MemberViewModel.cs b/Bank/BankContracts/ViewModels/MemberViewModel.cs new file mode 100644 index 0000000..36595fb --- /dev/null +++ b/Bank/BankContracts/ViewModels/MemberViewModel.cs @@ -0,0 +1,18 @@ +using BankDataModels.Models; +using System.ComponentModel; + +namespace BankContracts.ViewModels +{ + public class MemberViewModel : IMemberModel + { + [DisplayName("ФИО участника")] + public string MemberFIO { get; set; } = string.Empty; + + [DisplayName("Гражданство")] + public string Citizenship { get; set; } = string.Empty; + + public int OrganiserId { get; set; } + + public int Id { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs b/Bank/BankContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs new file mode 100644 index 0000000..117f6db --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class ReportConferenceBindingRoomsViewModel + { + public int Id { get; set; } + public string RoomName { get; set; } = string.Empty; + public double RoomPrice { get; set; } + public string RoomFrame { get; set; } = string.Empty; + + } +} diff --git a/Bank/BankContracts/ViewModels/ReportMealPlanDinnerViewModel.cs b/Bank/BankContracts/ViewModels/ReportMealPlanDinnerViewModel.cs new file mode 100644 index 0000000..251e1cc --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportMealPlanDinnerViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class ReportMealPlanDinnerViewModel + { + public string DinnerName { get; set; } = string.Empty; + public List> MealPlans { get; set; } = new(); + + } +} diff --git a/Bank/BankContracts/ViewModels/ReportMemberConferenceViewModel.cs b/Bank/BankContracts/ViewModels/ReportMemberConferenceViewModel.cs new file mode 100644 index 0000000..cc2a310 --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportMemberConferenceViewModel.cs @@ -0,0 +1,8 @@ +namespace BankContracts.ViewModels +{ + public class ReportMemberConferenceViewModel + { + public string MemberFIO { get; set; } = string.Empty; + public List> Conferences { get; set; } = new(); + } +} diff --git a/Bank/BankContracts/ViewModels/ReportMembersViewModel.cs b/Bank/BankContracts/ViewModels/ReportMembersViewModel.cs new file mode 100644 index 0000000..be95d23 --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportMembersViewModel.cs @@ -0,0 +1,12 @@ +namespace BankContracts.ViewModels +{ + public class ReportMembersViewModel + { + public int Id { get; set; } + public DateTime StartDate { get; set; } + public string MemberFIO { get; set; } = string.Empty; + public string ConferenceName { get; set; } = string.Empty; + public string MealPlanName { get; set; } = string.Empty; + public double MealPlanPrice { get; set; } + } +} diff --git a/Bank/BankContracts/ViewModels/RoomViewModel.cs b/Bank/BankContracts/ViewModels/RoomViewModel.cs new file mode 100644 index 0000000..6fe010f --- /dev/null +++ b/Bank/BankContracts/ViewModels/RoomViewModel.cs @@ -0,0 +1,26 @@ + +using BankDataModels.Models; +using System.ComponentModel; + +namespace BankContracts.ViewModels +{ + public class RoomViewModel : IRoomModel + { + public int HeadwaiterId { get; set; } + + public int MealPlanId { get; set; } + + public int Id { get; set; } + + [DisplayName("Название комнаты")] + public string RoomName { get; set; } = string.Empty; + + [DisplayName("Корпус комнаты")] + public string RoomFrame { get; set; } = string.Empty; + + [DisplayName("Стоимость комнаты")] + public double RoomPrice { get; set; } + public Dictionary RoomDinners { get; set; } + + } +} diff --git a/Bank/BankDataBaseImplement/BankDataBase.cs b/Bank/BankDataBaseImplement/BankDataBase.cs new file mode 100644 index 0000000..8b3307b --- /dev/null +++ b/Bank/BankDataBaseImplement/BankDataBase.cs @@ -0,0 +1,31 @@ +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; + +namespace BankDataBaseImplement +{ + public class BankDataBase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-VG5USAH\SQLEXPRESS;Initial Catalog=HotelDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Conferences { set; get; } + public virtual DbSet Rooms { set; get; } + public virtual DbSet MealPlans { set; get; } + public virtual DbSet ConferenceBookings { set; get; } + public virtual DbSet Members { set; get; } + public virtual DbSet Dinners { set; get; } + public virtual DbSet Organisers { set; get; } + public virtual DbSet Headwaiters { set; get; } + public virtual DbSet ConferenceMembers { set; get; } + public virtual DbSet RoomDinners { set; get; } + public virtual DbSet MealPlanMembers { set; get; } + public virtual DbSet ConferenceBookingDinners { set; get; } + + } +} \ No newline at end of file diff --git a/Bank/BankDataBaseImplement/BankDataBaseImplement.csproj b/Bank/BankDataBaseImplement/BankDataBaseImplement.csproj new file mode 100644 index 0000000..d398a1a --- /dev/null +++ b/Bank/BankDataBaseImplement/BankDataBaseImplement.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs b/Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs new file mode 100644 index 0000000..d631e26 --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/ConferenceBookingStorage.cs @@ -0,0 +1,164 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Implemets +{ + public class ConferenceBookingStorage : IConferenceBookingStorage + { + public ConferenceBookingViewModel? Delete(ConferenceBookingBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.ConferenceBookings + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.ConferenceBookings.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public ConferenceBookingViewModel? GetElement(ConferenceBookingSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(ConferenceBookingSearchModel model) + { + if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.HeadwaiterId.HasValue) + { + return new(); + } + using var context = new BankDataBase(); + + if (model.DateFrom.HasValue) + { + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .Where(x => x.Conference.StartDate >= model.DateFrom && x.Conference.StartDate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + else if (model.HeadwaiterId.HasValue) + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .Where(x => x.HeadwaiterId == model.HeadwaiterId) + .Select(x => x.GetViewModel) + .ToList(); + + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ConferenceBookingViewModel? Insert(ConferenceBookingBindingModel model) + { + using var context = new BankDataBase(); + var newConferenceBooking = ConferenceBooking.Create(context, model); + + if (newConferenceBooking == null) + { + return null; + } + + context.ConferenceBookings.Add(newConferenceBooking); + context.SaveChanges(); + + return context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .FirstOrDefault(x => x.Id == newConferenceBooking.Id) + ?.GetViewModel; + } + + + public ConferenceBookingViewModel? Update(ConferenceBookingBindingModel model) + { + using var context = new BankDataBase(); + + var conferenceBooking = context.ConferenceBookings + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.Conference) + .Include(x => x.Headwaiter) + .FirstOrDefault(x => x.Id == model.Id); + + if (conferenceBooking == null) + { + return null; + } + + conferenceBooking.Update(model); + context.SaveChanges(); + + return conferenceBooking.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs b/Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs new file mode 100644 index 0000000..ba0330c --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/ConferenceStorage.cs @@ -0,0 +1,159 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace BankDataBaseImplement.Implemets +{ + public class ConferenceStorage : IConferenceStorage + { + public ConferenceViewModel? Delete(ConferenceBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Conferences + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Conferences.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public ConferenceViewModel? GetElement(ConferenceSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(ConferenceSearchModel model) + { + if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.OrganiserId.HasValue) + { + return new(); + } + using var context = new BankDataBase(); + + if (model.DateFrom.HasValue) + { + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .Where(x => x.StartDate >= model.DateFrom && x.StartDate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + else if (model.OrganiserId.HasValue) + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .Where(x => x.OrganiserId == model.OrganiserId) + .Select(x => x.GetViewModel) + .ToList(); + + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ConferenceViewModel? Insert(ConferenceBindingModel model) + { + using var context = new BankDataBase(); + var newConference = Conference.Create(context,model); + + if (newConference == null) + { + return null; + } + + context.Conferences.Add(newConference); + context.SaveChanges(); + + return context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .FirstOrDefault(x => x.Id == newConference.Id) + ?.GetViewModel; + } + + + public ConferenceViewModel? Update(ConferenceBindingModel model) + { + using var context = new BankDataBase(); + + var conference = context.Conferences + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.ConferenceBookings) + .Include(x => x.Organiser) + .FirstOrDefault(x => x.Id == model.Id); + + if (conference == null) + { + return null; + } + + conference.Update(model); + context.SaveChanges(); + + return conference.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs b/Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs new file mode 100644 index 0000000..4d32514 --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/DinnerStorage.cs @@ -0,0 +1,120 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Implemets +{ + public class DinnerStorage : IDinnerStorage + { + public DinnerViewModel? Delete(DinnerBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Dinners.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Dinners.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public DinnerViewModel? GetElement(DinnerSearchModel model) + { + if (string.IsNullOrEmpty(model.DinnerName) && !model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.Dinners + .Include(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.DinnerName) && x.DinnerName == model.DinnerName) || (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(DinnerSearchModel model) + { + if (string.IsNullOrEmpty(model.DinnerName)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.Dinners + .Include(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .Where(x => x.DinnerName.Contains(model.DinnerName)) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.Dinners + .Include(x => x.RoomDinners) + .ThenInclude(x => x.Room) + .Include(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public DinnerViewModel? Insert(DinnerBindingModel model) + { + using var context = new BankDataBase(); + + var newDinner = Dinner.Create(model); + + if (newDinner == null) + { + return null; + } + + context.Dinners.Add(newDinner); + context.SaveChanges(); + + return newDinner.GetViewModel; + } + + public DinnerViewModel? Update(DinnerBindingModel model) + { + using var context = new BankDataBase(); + + var dinner = context.Dinners.FirstOrDefault(x => x.Id == model.Id); + + if (dinner == null) + { + return null; + } + + dinner.Update(model); + context.SaveChanges(); + + return dinner.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs b/Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs new file mode 100644 index 0000000..a7bc27d --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/HeadwaiterStorage.cs @@ -0,0 +1,127 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Implemets +{ + public class HeadwaiterStorage : IHeadwaiterStorage + { + public HeadwaiterViewModel? Delete(HeadwaiterBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Headwaiters.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Headwaiters.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public HeadwaiterViewModel? GetElement(HeadwaiterSearchModel model) + { + using var context = new BankDataBase(); + + if (model.Id.HasValue) + return context.Headwaiters + .Include(x => x.ConferenceBookings) + .Include(x => x.Dinners) + .Include(x => x.Rooms) + .FirstOrDefault(x => x.Id == model.Id)? + .GetViewModel; + + if (!string.IsNullOrEmpty(model.HeadwaiterLogin) && !string.IsNullOrEmpty(model.HeadwaiterPassword)) + return context.Headwaiters + .Include(x => x.ConferenceBookings) + .Include(x => x.Dinners) + .Include(x => x.Rooms) + .FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin) && x.HeadwaiterPassword.Equals(model.HeadwaiterPassword))? + .GetViewModel; + + if (!string.IsNullOrEmpty(model.HeadwaiterLogin)) + return context.Headwaiters + .Include(x => x.ConferenceBookings) + .Include(x => x.Dinners) + .Include(x => x.Rooms) + .FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin))? + .GetViewModel; + + return null; + } + + public List GetFilteredList(HeadwaiterSearchModel model) + { + if (string.IsNullOrEmpty(model.HeadwaiterFIO)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.Headwaiters + .Include(x => x.ConferenceBookings) + .Include(x => x.Dinners) + .Include(x => x.Rooms) + .Where(x => x.HeadwaiterLogin.Contains(model.HeadwaiterLogin) && x.HeadwaiterPassword == model.HeadwaiterPassword) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.Headwaiters + .Select(x => x.GetViewModel) + .ToList(); + } + + public HeadwaiterViewModel? Insert(HeadwaiterBindingModel model) + { + var newHeadwaiter = Headwaiter.Create(model); + + if (newHeadwaiter == null) + { + return null; + } + + using var context = new BankDataBase(); + + context.Headwaiters.Add(newHeadwaiter); + context.SaveChanges(); + + return newHeadwaiter.GetViewModel; + } + + public HeadwaiterViewModel? Update(HeadwaiterBindingModel model) + { + using var context = new BankDataBase(); + + var headwaiter = context.Headwaiters + .FirstOrDefault(x => x.Id == model.Id); + + if (headwaiter == null) + { + return null; + } + + headwaiter.Update(model); + context.SaveChanges(); + + return headwaiter.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs b/Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs new file mode 100644 index 0000000..517f383 --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/MealPlanStorage.cs @@ -0,0 +1,113 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace BankDataBaseImplement.Implemets +{ + public class MealPlanStorage : IMealPlanStorage + { + public MealPlanViewModel? Delete(MealPlanBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.MealPlans + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.MealPlans.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public MealPlanViewModel? GetElement(MealPlanSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.MealPlans + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.Rooms) + .Include(x => x.Organiser) + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(MealPlanSearchModel model) + { + if (string.IsNullOrEmpty(model.MealPlanName)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.MealPlans + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.Rooms) + .Include(x => x.Organiser) + .Where(x => x.MealPlanName.Contains(model.MealPlanName)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + return context.MealPlans + .Include(x => x.Members) + .ThenInclude(x => x.Member) + .ThenInclude(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.Rooms) + .Include(x => x.Organiser) + .Select(x => x.GetViewModel) + .ToList(); + } + + public MealPlanViewModel? Insert(MealPlanBindingModel model) + { + using var context = new BankDataBase(); + var newMealPlan = MealPlan.Create(context,model); + + if (newMealPlan == null) + { + return null; + } + + context.MealPlans.Add(newMealPlan); + context.SaveChanges(); + return newMealPlan.GetViewModel; + } + + public MealPlanViewModel? Update(MealPlanBindingModel model) + { + using var context = new BankDataBase(); + var mealPlan = context.MealPlans.FirstOrDefault(x => x.Id == model.Id); + if (mealPlan == null) + { + return null; + } + mealPlan.Update(model); + context.SaveChanges(); + return mealPlan.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/MemberStorage.cs b/Bank/BankDataBaseImplement/Implemets/MemberStorage.cs new file mode 100644 index 0000000..d0f15e7 --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/MemberStorage.cs @@ -0,0 +1,118 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace BankDataBaseImplement.Implemets +{ + public class MemberStorage : IMemberStorage + { + public MemberViewModel? Delete(MemberBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Members.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Members.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public MemberViewModel? GetElement(MemberSearchModel model) + { + if (string.IsNullOrEmpty(model.MemberFIO) && !model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.Members + .Include(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.Organiser) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.MemberFIO) && x.MemberFIO == model.MemberFIO) || (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(MemberSearchModel model) + { + if (string.IsNullOrEmpty(model.MemberFIO)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.Members + .Include(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.Organiser) + .Where(x => x.MemberFIO.Contains(model.MemberFIO)) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.Members + .Include(x => x.ConferenceMember) + .ThenInclude(x => x.Conference) + .Include(x => x.MealPlanMember) + .ThenInclude(x => x.MealPlan) + .Include(x => x.Organiser) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public MemberViewModel? Insert(MemberBindingModel model) + { + using var context = new BankDataBase(); + + var newMember = Member.Create(model); + + if (newMember == null) + { + return null; + } + + context.Members.Add(newMember); + context.SaveChanges(); + + return newMember.GetViewModel; + } + + public MemberViewModel? Update(MemberBindingModel model) + { + using var context = new BankDataBase(); + + var member = context.Members.FirstOrDefault(x => x.Id == model.Id); + + if (member == null) + { + return null; + } + + member.Update(model); + context.SaveChanges(); + + return member.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs b/Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs new file mode 100644 index 0000000..43443f0 --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/OrganiserStorage.cs @@ -0,0 +1,122 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace BankDataBaseImplement.Implemets +{ + public class OrganiserStorage : IClercStorage + { + public ClercViewModel? Delete(ClercBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Organisers.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Organisers.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public ClercViewModel? GetElement(ClercSearchModel model) + { + using var context = new BankDataBase(); + + if (model.Id.HasValue) + return context.Organisers + .Include(x => x.MealPlans) + .Include(x => x.Members) + .Include(x => x.Conferences) + .FirstOrDefault(x => x.Id == model.Id)? + .GetViewModel; + + if (!string.IsNullOrEmpty(model.OrganiserLogin) && !string.IsNullOrEmpty(model.OrganiserPassword)) + return context.Organisers + .Include(x => x.MealPlans) + .Include(x => x.Members) + .Include(x => x.Conferences) + .FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin) && x.OrganiserPassword.Equals(model.OrganiserPassword))? + .GetViewModel; + + if (!string.IsNullOrEmpty(model.OrganiserLogin)) + return context.Organisers + .Include(x => x.MealPlans) + .Include(x => x.Members) + .Include(x => x.Conferences) + .FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin))? + .GetViewModel; + + return null; + } + + public List GetFilteredList(ClercSearchModel model) + { + if (string.IsNullOrEmpty(model.OrganiserFIO)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.Organisers + .Include(x => x.MealPlans) + .Include(x => x.Members) + .Include(x => x.Conferences) + .Where(x => x.OrganiserLogin.Contains(model.OrganiserLogin) && x.OrganiserPassword == model.OrganiserPassword) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + + return context.Organisers + .Select(x => x.GetViewModel) + .ToList(); + } + + public ClercViewModel? Insert(ClercBindingModel model) + { + var newOrganiser = Clerc.Create(model); + + if (newOrganiser == null) + { + return null; + } + + using var context = new BankDataBase(); + + context.Organisers.Add(newOrganiser); + context.SaveChanges(); + + return newOrganiser.GetViewModel; + } + + public ClercViewModel? Update(ClercBindingModel model) + { + using var context = new BankDataBase(); + + var organiser = context.Organisers + .FirstOrDefault(x => x.Id == model.Id); + + if (organiser == null) + { + return null; + } + + organiser.Update(model); + context.SaveChanges(); + + return organiser.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Implemets/RoomStorage.cs b/Bank/BankDataBaseImplement/Implemets/RoomStorage.cs new file mode 100644 index 0000000..5c645df --- /dev/null +++ b/Bank/BankDataBaseImplement/Implemets/RoomStorage.cs @@ -0,0 +1,118 @@ +using BankContracts.BindingModels; +using BankContracts.SearchModels; +using BankContracts.StoragesContracts; +using BankContracts.ViewModels; +using BankDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Implemets +{ + public class RoomStorage : IRoomStorage + { + public RoomViewModel? Delete(RoomBindingModel model) + { + using var context = new BankDataBase(); + + var element = context.Rooms + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Rooms.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public RoomViewModel? GetElement(RoomSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + using var context = new BankDataBase(); + + return context.Rooms + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .Include(x => x.MealPlan) + .Include(x => x.Headwaiter) + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; + } + + public List GetFilteredList(RoomSearchModel model) + { + if (string.IsNullOrEmpty(model.RoomName)) + { + return new(); + } + + using var context = new BankDataBase(); + + return context.Rooms + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .Include(x => x.MealPlan) + .Include(x => x.Headwaiter) + .Where(x => x.RoomName.Contains(model.RoomName)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new BankDataBase(); + return context.Rooms + .Include(x => x.Dinners) + .ThenInclude(x => x.Dinner) + .ThenInclude(x => x.ConferenceBookingDinners) + .ThenInclude(x => x.ConferenceBooking) + .Include(x => x.MealPlan) + .Include(x => x.Headwaiter) + .Select(x => x.GetViewModel) + .ToList(); + } + + public RoomViewModel? Insert(RoomBindingModel model) + { + using var context = new BankDataBase(); + var newRoom = Room.Create(context, model); + + if (newRoom == null) + { + return null; + } + + context.Rooms.Add(newRoom); + context.SaveChanges(); + return newRoom.GetViewModel; + } + + public RoomViewModel? Update(RoomBindingModel model) + { + using var context = new BankDataBase(); + var room = context.Rooms.FirstOrDefault(x => x.Id == model.Id); + if (room == null) + { + return null; + } + room.Update(model); + context.SaveChanges(); + return room.GetViewModel; + } + } +} diff --git a/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs b/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs new file mode 100644 index 0000000..f7d7eae --- /dev/null +++ b/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.Designer.cs @@ -0,0 +1,569 @@ +// +using System; +using HotelDataBaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace HotelDataBaseImplement.Migrations +{ + [DbContext(typeof(HotelDataBase))] + [Migration("20230405210621_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("Conferences"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceId") + .HasColumnType("int"); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceId"); + + b.HasIndex("HeadwaiterId"); + + b.ToTable("ConferenceBookings"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceBookingId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DinnerId") + .HasColumnType("int"); + + b.Property("DinnercId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceBookingId"); + + b.HasIndex("DinnercId"); + + b.ToTable("ConferenceBookingDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceId") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceId"); + + b.HasIndex("MemberId"); + + b.ToTable("ConferenceMembers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DinnerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DinnetPrice") + .HasColumnType("float"); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("HeadwaiterId"); + + b.ToTable("Dinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HeadwaiterEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterLogin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterPassword") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Headwaiters"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MealPlanName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MealPlanPrice") + .HasColumnType("float"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("MealPlans"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MealPlanId") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MealPlanId"); + + b.HasIndex("MemberId"); + + b.ToTable("MealPlanMembers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Citizenship") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MemberFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("OrganiserEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserLogin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserPassword") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Organisers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.Property("MealPlanId") + .HasColumnType("int"); + + b.Property("RoomFrame") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoomName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoomPrice") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("HeadwaiterId"); + + b.HasIndex("MealPlanId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DinnerId") + .HasColumnType("int"); + + b.Property("RoomId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DinnerId"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("Conferences") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference") + .WithMany("ConferenceBookings") + .HasForeignKey("ConferenceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter") + .WithMany("ConferenceBookings") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Conference"); + + b.Navigation("Headwaiter"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking") + .WithMany("Dinners") + .HasForeignKey("ConferenceBookingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner") + .WithMany("ConferenceBookingDinners") + .HasForeignKey("DinnercId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ConferenceBooking"); + + b.Navigation("Dinner"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b => + { + b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference") + .WithMany("Members") + .HasForeignKey("ConferenceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Member", "Member") + .WithMany("ConferenceMember") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Conference"); + + b.Navigation("Member"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiters") + .WithMany("Dinners") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Headwaiters"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("MealPlans") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b => + { + b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan") + .WithMany("Members") + .HasForeignKey("MealPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Member", "Member") + .WithMany("MealPlanMember") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MealPlan"); + + b.Navigation("Member"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("Members") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter") + .WithMany("Rooms") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan") + .WithMany("Rooms") + .HasForeignKey("MealPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Headwaiter"); + + b.Navigation("MealPlan"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner") + .WithMany("RoomDinners") + .HasForeignKey("DinnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Room", "Room") + .WithMany("Dinners") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Dinner"); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.Navigation("ConferenceBookings"); + + b.Navigation("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.Navigation("Dinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.Navigation("ConferenceBookingDinners"); + + b.Navigation("RoomDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b => + { + b.Navigation("ConferenceBookings"); + + b.Navigation("Dinners"); + + b.Navigation("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.Navigation("Members"); + + b.Navigation("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.Navigation("ConferenceMember"); + + b.Navigation("MealPlanMember"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b => + { + b.Navigation("Conferences"); + + b.Navigation("MealPlans"); + + b.Navigation("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.Navigation("Dinners"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.cs b/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.cs new file mode 100644 index 0000000..7661ac1 --- /dev/null +++ b/Bank/BankDataBaseImplement/Migrations/20230405210621_InitialCreate.cs @@ -0,0 +1,415 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BankDataBaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Headwaiters", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HeadwaiterFIO = table.Column(type: "nvarchar(max)", nullable: false), + HeadwaiterEmail = table.Column(type: "nvarchar(max)", nullable: false), + HeadwaiterPassword = table.Column(type: "nvarchar(max)", nullable: false), + HeadwaiterLogin = table.Column(type: "nvarchar(max)", nullable: false), + HeadwaiterNumber = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Headwaiters", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Organisers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrganiserFIO = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserPassword = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserLogin = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserEmail = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserNumber = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Organisers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Dinners", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HeadwaiterId = table.Column(type: "int", nullable: false), + DinnerName = table.Column(type: "nvarchar(max)", nullable: false), + DinnetPrice = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Dinners", x => x.Id); + table.ForeignKey( + name: "FK_Dinners_Headwaiters_HeadwaiterId", + column: x => x.HeadwaiterId, + principalTable: "Headwaiters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Conferences", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConferenceName = table.Column(type: "nvarchar(max)", nullable: false), + StartDate = table.Column(type: "datetime2", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Conferences", x => x.Id); + table.ForeignKey( + name: "FK_Conferences_Organisers_OrganiserId", + column: x => x.OrganiserId, + principalTable: "Organisers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MealPlans", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MealPlanName = table.Column(type: "nvarchar(max)", nullable: false), + MealPlanPrice = table.Column(type: "float", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MealPlans", x => x.Id); + table.ForeignKey( + name: "FK_MealPlans_Organisers_OrganiserId", + column: x => x.OrganiserId, + principalTable: "Organisers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Members", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MemberFIO = table.Column(type: "nvarchar(max)", nullable: false), + Citizenship = table.Column(type: "nvarchar(max)", nullable: false), + OrganiserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Members", x => x.Id); + table.ForeignKey( + name: "FK_Members_Organisers_OrganiserId", + column: x => x.OrganiserId, + principalTable: "Organisers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ConferenceBookings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HeadwaiterId = table.Column(type: "int", nullable: false), + ConferenceId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ConferenceBookings", x => x.Id); + table.ForeignKey( + name: "FK_ConferenceBookings_Conferences_ConferenceId", + column: x => x.ConferenceId, + principalTable: "Conferences", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ConferenceBookings_Headwaiters_HeadwaiterId", + column: x => x.HeadwaiterId, + principalTable: "Headwaiters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Rooms", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoomName = table.Column(type: "nvarchar(max)", nullable: false), + RoomFrame = table.Column(type: "nvarchar(max)", nullable: false), + RoomPrice = table.Column(type: "float", nullable: false), + HeadwaiterId = table.Column(type: "int", nullable: false), + MealPlanId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Rooms", x => x.Id); + table.ForeignKey( + name: "FK_Rooms_Headwaiters_HeadwaiterId", + column: x => x.HeadwaiterId, + principalTable: "Headwaiters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Rooms_MealPlans_MealPlanId", + column: x => x.MealPlanId, + principalTable: "MealPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ConferenceMembers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MemberId = table.Column(type: "int", nullable: false), + ConferenceId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ConferenceMembers", x => x.Id); + table.ForeignKey( + name: "FK_ConferenceMembers_Conferences_ConferenceId", + column: x => x.ConferenceId, + principalTable: "Conferences", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ConferenceMembers_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "MealPlanMembers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MemberId = table.Column(type: "int", nullable: false), + MealPlanId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MealPlanMembers", x => x.Id); + table.ForeignKey( + name: "FK_MealPlanMembers_MealPlans_MealPlanId", + column: x => x.MealPlanId, + principalTable: "MealPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MealPlanMembers_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "ConferenceBookingDinners", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConferenceBookingId = table.Column(type: "int", nullable: false), + DinnerId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false), + DinnercId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id); + table.ForeignKey( + name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId", + column: x => x.ConferenceBookingId, + principalTable: "ConferenceBookings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ConferenceBookingDinners_Dinners_DinnercId", + column: x => x.DinnercId, + principalTable: "Dinners", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "RoomDinners", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoomId = table.Column(type: "int", nullable: false), + DinnerId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoomDinners", x => x.Id); + table.ForeignKey( + name: "FK_RoomDinners_Dinners_DinnerId", + column: x => x.DinnerId, + principalTable: "Dinners", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoomDinners_Rooms_RoomId", + column: x => x.RoomId, + principalTable: "Rooms", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceBookingDinners_ConferenceBookingId", + table: "ConferenceBookingDinners", + column: "ConferenceBookingId"); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceBookingDinners_DinnercId", + table: "ConferenceBookingDinners", + column: "DinnercId"); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceBookings_ConferenceId", + table: "ConferenceBookings", + column: "ConferenceId"); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceBookings_HeadwaiterId", + table: "ConferenceBookings", + column: "HeadwaiterId"); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceMembers_ConferenceId", + table: "ConferenceMembers", + column: "ConferenceId"); + + migrationBuilder.CreateIndex( + name: "IX_ConferenceMembers_MemberId", + table: "ConferenceMembers", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_Conferences_OrganiserId", + table: "Conferences", + column: "OrganiserId"); + + migrationBuilder.CreateIndex( + name: "IX_Dinners_HeadwaiterId", + table: "Dinners", + column: "HeadwaiterId"); + + migrationBuilder.CreateIndex( + name: "IX_MealPlanMembers_MealPlanId", + table: "MealPlanMembers", + column: "MealPlanId"); + + migrationBuilder.CreateIndex( + name: "IX_MealPlanMembers_MemberId", + table: "MealPlanMembers", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_MealPlans_OrganiserId", + table: "MealPlans", + column: "OrganiserId"); + + migrationBuilder.CreateIndex( + name: "IX_Members_OrganiserId", + table: "Members", + column: "OrganiserId"); + + migrationBuilder.CreateIndex( + name: "IX_RoomDinners_DinnerId", + table: "RoomDinners", + column: "DinnerId"); + + migrationBuilder.CreateIndex( + name: "IX_RoomDinners_RoomId", + table: "RoomDinners", + column: "RoomId"); + + migrationBuilder.CreateIndex( + name: "IX_Rooms_HeadwaiterId", + table: "Rooms", + column: "HeadwaiterId"); + + migrationBuilder.CreateIndex( + name: "IX_Rooms_MealPlanId", + table: "Rooms", + column: "MealPlanId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ConferenceBookingDinners"); + + migrationBuilder.DropTable( + name: "ConferenceMembers"); + + migrationBuilder.DropTable( + name: "MealPlanMembers"); + + migrationBuilder.DropTable( + name: "RoomDinners"); + + migrationBuilder.DropTable( + name: "ConferenceBookings"); + + migrationBuilder.DropTable( + name: "Members"); + + migrationBuilder.DropTable( + name: "Dinners"); + + migrationBuilder.DropTable( + name: "Rooms"); + + migrationBuilder.DropTable( + name: "Conferences"); + + migrationBuilder.DropTable( + name: "Headwaiters"); + + migrationBuilder.DropTable( + name: "MealPlans"); + + migrationBuilder.DropTable( + name: "Organisers"); + } + } +} diff --git a/Bank/BankDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs b/Bank/BankDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs new file mode 100644 index 0000000..d7be949 --- /dev/null +++ b/Bank/BankDataBaseImplement/Migrations/HotelDataBaseModelSnapshot.cs @@ -0,0 +1,566 @@ +// +using System; +using BankDataBaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BankDataBaseImplement.Migrations +{ + [DbContext(typeof(BankDataBase))] + partial class HotelDataBaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("Conferences"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceId") + .HasColumnType("int"); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceId"); + + b.HasIndex("HeadwaiterId"); + + b.ToTable("ConferenceBookings"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceBookingId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DinnerId") + .HasColumnType("int"); + + b.Property("DinnercId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceBookingId"); + + b.HasIndex("DinnercId"); + + b.ToTable("ConferenceBookingDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConferenceId") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConferenceId"); + + b.HasIndex("MemberId"); + + b.ToTable("ConferenceMembers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DinnerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DinnetPrice") + .HasColumnType("float"); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("HeadwaiterId"); + + b.ToTable("Dinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HeadwaiterEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterLogin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HeadwaiterPassword") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Headwaiters"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MealPlanName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MealPlanPrice") + .HasColumnType("float"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("MealPlans"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MealPlanId") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MealPlanId"); + + b.HasIndex("MemberId"); + + b.ToTable("MealPlanMembers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Citizenship") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MemberFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrganiserId"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("OrganiserEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserLogin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganiserPassword") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Organisers"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HeadwaiterId") + .HasColumnType("int"); + + b.Property("MealPlanId") + .HasColumnType("int"); + + b.Property("RoomFrame") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoomName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoomPrice") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("HeadwaiterId"); + + b.HasIndex("MealPlanId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DinnerId") + .HasColumnType("int"); + + b.Property("RoomId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DinnerId"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("Conferences") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference") + .WithMany("ConferenceBookings") + .HasForeignKey("ConferenceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter") + .WithMany("ConferenceBookings") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Conference"); + + b.Navigation("Headwaiter"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking") + .WithMany("Dinners") + .HasForeignKey("ConferenceBookingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner") + .WithMany("ConferenceBookingDinners") + .HasForeignKey("DinnercId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ConferenceBooking"); + + b.Navigation("Dinner"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b => + { + b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference") + .WithMany("Members") + .HasForeignKey("ConferenceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Member", "Member") + .WithMany("ConferenceMember") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Conference"); + + b.Navigation("Member"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiters") + .WithMany("Dinners") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Headwaiters"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("MealPlans") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b => + { + b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan") + .WithMany("Members") + .HasForeignKey("MealPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Member", "Member") + .WithMany("MealPlanMember") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MealPlan"); + + b.Navigation("Member"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser") + .WithMany("Members") + .HasForeignKey("OrganiserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organiser"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter") + .WithMany("Rooms") + .HasForeignKey("HeadwaiterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan") + .WithMany("Rooms") + .HasForeignKey("MealPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Headwaiter"); + + b.Navigation("MealPlan"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b => + { + b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner") + .WithMany("RoomDinners") + .HasForeignKey("DinnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HotelDataBaseImplement.Models.Room", "Room") + .WithMany("Dinners") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Dinner"); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b => + { + b.Navigation("ConferenceBookings"); + + b.Navigation("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b => + { + b.Navigation("Dinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b => + { + b.Navigation("ConferenceBookingDinners"); + + b.Navigation("RoomDinners"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b => + { + b.Navigation("ConferenceBookings"); + + b.Navigation("Dinners"); + + b.Navigation("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b => + { + b.Navigation("Members"); + + b.Navigation("Rooms"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b => + { + b.Navigation("ConferenceMember"); + + b.Navigation("MealPlanMember"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b => + { + b.Navigation("Conferences"); + + b.Navigation("MealPlans"); + + b.Navigation("Members"); + }); + + modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b => + { + b.Navigation("Dinners"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Bank/BankDataBaseImplement/Models/Clerc.cs b/Bank/BankDataBaseImplement/Models/Clerc.cs new file mode 100644 index 0000000..9c751f3 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Clerc.cs @@ -0,0 +1,81 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BankDataBaseImplement.Models +{ + public class Clerc : IClercModel + { + [Required] + public string OrganiserFIO { get; set; } = string.Empty; + [Required] + public string OrganiserPassword { get; set; } = string.Empty; + [Required] + public string OrganiserLogin { get; set; } = string.Empty; + [Required] + public string OrganiserEmail { get; set; } = string.Empty; + [Required] + public string OrganiserNumber { get; set; } = string.Empty; + + public int Id { get; private set; } + + [ForeignKey("OrganiserId")] + public virtual List Conferences { get; set; } = new(); + [ForeignKey("OrganiserId")] + public virtual List MealPlans { get; set; } = new(); + [ForeignKey("OrganiserId")] + public virtual List Members { get; set; } = new(); + + public static Clerc? Create(ClercBindingModel model) + { + if (model == null) + { + return null; + } + return new Clerc() + { + Id = model.Id, + OrganiserFIO = model.OrganiserFIO, + OrganiserEmail = model.OrganiserEmail, + OrganiserPassword = model.OrganiserPassword, + OrganiserLogin = model.OrganiserLogin, + OrganiserNumber = model.OrganiserNumber + }; + } + public static Clerc Create(ClercViewModel model) + { + return new Clerc + { + Id = model.Id, + OrganiserFIO = model.OrganiserFIO, + OrganiserEmail = model.OrganiserEmail, + OrganiserPassword = model.OrganiserPassword, + OrganiserLogin= model.OrganiserLogin, + OrganiserNumber= model.OrganiserNumber + }; + } + public void Update(ClercBindingModel model) + { + if (model == null) + { + return; + } + OrganiserFIO = model.OrganiserFIO; + OrganiserEmail = model.OrganiserEmail; + OrganiserPassword = model.OrganiserPassword; + OrganiserLogin = model.OrganiserLogin; + OrganiserNumber = model.OrganiserNumber; + } + public ClercViewModel GetViewModel => new() + { + Id = Id, + OrganiserFIO = OrganiserFIO, + OrganiserEmail = OrganiserEmail, + OrganiserPassword = OrganiserPassword, + OrganiserNumber = OrganiserNumber, + OrganiserLogin = OrganiserLogin + }; + } +} diff --git a/Bank/BankDataBaseImplement/Models/Conference.cs b/Bank/BankDataBaseImplement/Models/Conference.cs new file mode 100644 index 0000000..8acd28a --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Conference.cs @@ -0,0 +1,93 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BankDataBaseImplement.Models +{ + public class Conference : IConferenceModel + { + [Required] + public string ConferenceName { get; set; } = string.Empty; + [Required] + public DateTime StartDate { get; set; } = DateTime.Now; + + public int OrganiserId { get; private set; } + + public int Id { get; private set; } + + public virtual Clerc Organiser { get; set; } + + [ForeignKey("ConferenceId")] + public virtual List ConferenceBookings { get; set; } + + [ForeignKey("ConferenceId")] + public virtual List Members { get; set; } + + private Dictionary _conferenceMembers = null; + public Dictionary ConferenceMembers + { + get + { + if (_conferenceMembers == null) + { + _conferenceMembers = Members.ToDictionary(recPC => recPC.MemberId, recPC => (recPC.Member as IMemberModel)); + } + return _conferenceMembers; + } + } + + public static Conference Create(BankDataBase context, ConferenceBindingModel model) + { + return new Conference() + { + Id = model.Id, + ConferenceName = model.ConferenceName, + StartDate = model.StartDate, + Members = model.ConferenceMembers.Select(x => new ConferenceMember + { + Member = context.Members.First(y => y.Id == x.Key), + }).ToList() + }; + } + + public void Update(ConferenceBindingModel model) + { + ConferenceName = model.ConferenceName; + StartDate = model.StartDate; + } + + public ConferenceViewModel GetViewModel => new() + { + Id = Id, + ConferenceName = ConferenceName, + StartDate = StartDate, + ConferenceMembers = ConferenceMembers + }; + + public void UpdateMembers(BankDataBase context, ConferenceBindingModel model) + { + var conferenceMembers = context.ConferenceMembers.Where(rec => rec.ConferenceId == model.Id).ToList(); + + if (conferenceMembers != null) + { + context.ConferenceMembers.RemoveRange(conferenceMembers.Where(rec => !model.ConferenceMembers.ContainsKey(rec.MemberId))); + context.SaveChanges(); + } + + var conference = context.Conferences.First(x => x.Id == Id); + + foreach (var cm in model.ConferenceMembers) + { + context.ConferenceMembers.Add(new ConferenceMember + { + Conference = conference, + Member = context.Members.First(x => x.Id == cm.Key) + }); + context.SaveChanges(); + } + _conferenceMembers = null; + } + } +} diff --git a/Bank/BankDataBaseImplement/Models/ConferenceBooking.cs b/Bank/BankDataBaseImplement/Models/ConferenceBooking.cs new file mode 100644 index 0000000..c8f7680 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/ConferenceBooking.cs @@ -0,0 +1,87 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class ConferenceBooking : IConferenceBookingModel + { + public int HeadwaiterId { get; private set; } + public int ConferenceId { get; private set; } + public int Id { get; private set; } + public virtual Headwaiter Headwaiter { get; set; } + public virtual Conference Conference { get; set; } + + [ForeignKey("ConferenceBookingId")] + public virtual List Dinners { get; set; } + + private Dictionary _conferenceBookingDinners = null; + + public Dictionary ConferenceBookingDinners + { + get + { + if (_conferenceBookingDinners == null) + { + _conferenceBookingDinners = Dinners.ToDictionary(recPC => recPC.DinnerId, recPC => (recPC.Dinner as IDinnerModel)); + } + return _conferenceBookingDinners; + } + } + public static ConferenceBooking Create(BankDataBase context, ConferenceBookingBindingModel model) + { + return new ConferenceBooking() + { + Id = model.Id, + Dinners = model.ConferenceBookingDinners.Select(x => new ConferenceBookingDinner + { + Dinner = context.Dinners.First(y => y.Id == x.Key), + }).ToList() + }; + } + + public void Update(ConferenceBookingBindingModel model) + { + + } + + public ConferenceBookingViewModel GetViewModel => new() + { + Id = Id, + ConferenceBookingDinners = ConferenceBookingDinners + }; + + public void UpdateDinners(BankDataBase context, ConferenceBookingBindingModel model) + { + var conferenceBookingDinners = context.ConferenceBookingDinners.Where(rec => rec.ConferenceBookingId == model.Id).ToList(); + + if (conferenceBookingDinners != null) + { + context.ConferenceBookingDinners.RemoveRange(conferenceBookingDinners.Where(rec => !model.ConferenceBookingDinners.ContainsKey(rec.DinnerId))); + context.SaveChanges(); + } + + var conferenceBooking = context.ConferenceBookings.First(x => x.Id == Id); + + foreach (var cm in model.ConferenceBookingDinners) + { + context.ConferenceBookingDinners.Add(new ConferenceBookingDinner + { + ConferenceBooking = conferenceBooking, + Dinner = context.Dinners.First(x => x.Id == cm.Key) + }); + context.SaveChanges(); + } + _conferenceBookingDinners = null; + } + } + +} + diff --git a/Bank/BankDataBaseImplement/Models/ConferenceBookingDinner.cs b/Bank/BankDataBaseImplement/Models/ConferenceBookingDinner.cs new file mode 100644 index 0000000..548fb62 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/ConferenceBookingDinner.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class ConferenceBookingDinner + { + public int Id { get; set; } + public int ConferenceBookingId { get; set; } + public int DinnerId { get; set; } + + [Required] + public int Count { get; set; } + public virtual ConferenceBooking ConferenceBooking { get; set; } + public virtual Dinner Dinner { get; set; } + } +} diff --git a/Bank/BankDataBaseImplement/Models/ConferenceMember.cs b/Bank/BankDataBaseImplement/Models/ConferenceMember.cs new file mode 100644 index 0000000..4c3018c --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/ConferenceMember.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; + +namespace BankDataBaseImplement.Models +{ + public class ConferenceMember + { + public int Id { get; set; } + + [Required] + public int MemberId { get; set; } + + [Required] + public int ConferenceId { get; set; } + + public virtual Conference Conference { get; set; } + public virtual Member Member { get; set; } + } +} diff --git a/Bank/BankDataBaseImplement/Models/Dinner.cs b/Bank/BankDataBaseImplement/Models/Dinner.cs new file mode 100644 index 0000000..1e3ebb9 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Dinner.cs @@ -0,0 +1,70 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class Dinner : IDinnerModel + { + public int Id { get; set; } + public int HeadwaiterId { get; set; } + + [Required] + public string DinnerName { get; set; } = string.Empty; + + [Required] + public double DinnerPrice { get; set; } + + public virtual Headwaiter Headwaiters { get; set; } + + [ForeignKey("DinnerId")] + public virtual List RoomDinners { get; set; } + + [ForeignKey("DinnercId")] + public virtual List ConferenceBookingDinners { get; set; } + public static Dinner? Create(DinnerBindingModel model) + { + if (model == null) + { + return null; + } + return new Dinner() + { + Id = model.Id, + DinnerName = model.DinnerName, + DinnerPrice = model.DinnerPrice + }; + } + public static Dinner Create(DinnerViewModel model) + { + return new Dinner + { + Id = model.Id, + DinnerName = model.DinnerName, + DinnerPrice = model.DinnerPrice + }; + } + public void Update(DinnerBindingModel model) + { + if (model == null) + { + return; + } + DinnerName = model.DinnerName; + DinnerPrice = model.DinnerPrice; + } + public DinnerViewModel GetViewModel => new() + { + Id = Id, + DinnerName = DinnerName, + DinnerPrice = DinnerPrice + }; + } +} diff --git a/Bank/BankDataBaseImplement/Models/Headwaiter.cs b/Bank/BankDataBaseImplement/Models/Headwaiter.cs new file mode 100644 index 0000000..3258f94 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Headwaiter.cs @@ -0,0 +1,93 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class Headwaiter : IHeadwaiterModel + { + public int Id { get; private set; } + + [Required] + public string HeadwaiterFIO { get; set; } = string.Empty; + + [Required] + public string HeadwaiterEmail { get; set; } = string.Empty; + + [Required] + public string HeadwaiterPassword { get; set; } = string.Empty; + + [Required] + public string HeadwaiterLogin { get; set; } = string.Empty; + + [Required] + public string HeadwaiterNumber { get; set; } = string.Empty; + + + [ForeignKey("HeadwaiterId")] + public virtual List Rooms { get; set; } = new(); + + [ForeignKey("HeadwaiterId")] + public virtual List Dinners { get; set; } = new(); + + [ForeignKey("HeadwaiterId")] + public virtual List ConferenceBookings { get; set; } = new(); + public static Headwaiter? Create(HeadwaiterBindingModel model) + { + if (model == null) + { + return null; + } + return new Headwaiter() + { + Id = model.Id, + HeadwaiterFIO = model.HeadwaiterFIO, + HeadwaiterEmail = model.HeadwaiterEmail, + HeadwaiterPassword = model.HeadwaiterPassword, + HeadwaiterLogin = model.HeadwaiterLogin, + HeadwaiterNumber = model.HeadwaiterNumber + }; + } + public static Headwaiter Create(HeadwaiterViewModel model) + { + return new Headwaiter + { + Id = model.Id, + HeadwaiterFIO = model.HeadwaiterFIO, + HeadwaiterEmail = model.HeadwaiterEmail, + HeadwaiterPassword = model.HeadwaiterPassword, + HeadwaiterLogin = model.HeadwaiterLogin, + HeadwaiterNumber = model.HeadwaiterNumber + }; + } + public void Update(HeadwaiterBindingModel model) + { + if (model == null) + { + return; + } + HeadwaiterFIO = model.HeadwaiterFIO; + HeadwaiterEmail = model.HeadwaiterEmail; + HeadwaiterPassword = model.HeadwaiterPassword; + HeadwaiterLogin = model.HeadwaiterLogin; + HeadwaiterNumber = model.HeadwaiterNumber; + } + public HeadwaiterViewModel GetViewModel => new() + { + Id = Id, + HeadwaiterFIO = HeadwaiterFIO, + HeadwaiterEmail = HeadwaiterEmail, + HeadwaiterPassword = HeadwaiterPassword, + HeadwaiterLogin = HeadwaiterLogin, + HeadwaiterNumber = HeadwaiterNumber + }; + + } +} diff --git a/Bank/BankDataBaseImplement/Models/MealPlan.cs b/Bank/BankDataBaseImplement/Models/MealPlan.cs new file mode 100644 index 0000000..3221c4c --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/MealPlan.cs @@ -0,0 +1,94 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BankDataBaseImplement.Models +{ + public class MealPlan : IMealPlanModel + { + [Required] + public string MealPlanName { get; set; } = string.Empty; + + [Required] + public double MealPlanPrice { get; set; } + + public int OrganiserId { get; private set; } + + public int Id { get; private set; } + + public virtual Clerc Organiser { get; set; } + + [ForeignKey("MealPlanId")] + public virtual List Rooms { get; set; } + + [ForeignKey("MealPlanId")] + public virtual List Members { get; set; } + + private Dictionary _mealPlanMembers = null; + + public Dictionary MealPlanMembers + { + get + { + if (_mealPlanMembers == null) + { + _mealPlanMembers = Members.ToDictionary(recPC => recPC.MemberId, recPC => (recPC.Member as IMemberModel)); + } + return _mealPlanMembers; + } + } + public static MealPlan Create(BankDataBase context, MealPlanBindingModel model) + { + return new MealPlan() + { + Id = model.Id, + MealPlanName = model.MealPlanName, + MealPlanPrice = model.MealPlanPrice, + Members = model.MealPlanMembers.Select(x => new MealPlanMember + { + Member = context.Members.First(y => y.Id == x.Key), + }).ToList() + }; + } + + public void Update(MealPlanBindingModel model) + { + MealPlanName = model.MealPlanName; + MealPlanPrice = model.MealPlanPrice; + } + + public MealPlanViewModel GetViewModel => new() + { + Id = Id, + MealPlanName = MealPlanName, + MealPlanPrice = MealPlanPrice, + MealPlanMembers = MealPlanMembers + }; + + public void UpdateMembers(BankDataBase context, MealPlanBindingModel model) + { + var mealPlanMembers = context.MealPlanMembers.Where(rec => rec.MealPlanId == model.Id).ToList(); + + if (mealPlanMembers != null) + { + context.MealPlanMembers.RemoveRange(mealPlanMembers.Where(rec => !model.MealPlanMembers.ContainsKey(rec.MemberId))); + context.SaveChanges(); + } + + var mealPlan = context.MealPlans.First(x => x.Id == Id); + + foreach (var cm in model.MealPlanMembers) + { + context.MealPlanMembers.Add(new MealPlanMember + { + MealPlan = mealPlan, + Member = context.Members.First(x => x.Id == cm.Key) + }); + context.SaveChanges(); + } + _mealPlanMembers = null; + } + } +} diff --git a/Bank/BankDataBaseImplement/Models/MealPlanMember.cs b/Bank/BankDataBaseImplement/Models/MealPlanMember.cs new file mode 100644 index 0000000..978036e --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/MealPlanMember.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; + +namespace BankDataBaseImplement.Models +{ + public class MealPlanMember + { + public int Id { get; set; } + + [Required] + public int MemberId { get; set; } + + [Required] + public int MealPlanId { get; set; } + + public virtual MealPlan MealPlan { get; set; } + public virtual Member Member { get; set; } + } +} diff --git a/Bank/BankDataBaseImplement/Models/Member.cs b/Bank/BankDataBaseImplement/Models/Member.cs new file mode 100644 index 0000000..13ce40c --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Member.cs @@ -0,0 +1,66 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BankDataBaseImplement.Models +{ + public class Member : IMemberModel + { + [Required] + public string MemberFIO { get; set; } = string.Empty; + + [Required] + public string Citizenship { get; set; } = string.Empty; + + public int OrganiserId { get; private set; } + + public int Id { get; private set; } + + public virtual Clerc Organiser { get; set; } + + [ForeignKey("MemberId")] + public virtual List MealPlanMember { get; set; } + + [ForeignKey("MemberId")] + public virtual List ConferenceMember { get; set; } + public static Member? Create(MemberBindingModel model) + { + if (model == null) + { + return null; + } + return new Member() + { + Id = model.Id, + MemberFIO = model.MemberFIO, + Citizenship = model.Citizenship + }; + } + public static Member Create(MemberViewModel model) + { + return new Member + { + Id = model.Id, + MemberFIO = model.MemberFIO, + Citizenship = model.Citizenship + }; + } + public void Update(MemberBindingModel model) + { + if (model == null) + { + return; + } + MemberFIO = model.MemberFIO; + Citizenship = model.Citizenship; + } + public MemberViewModel GetViewModel => new() + { + Id = Id, + MemberFIO = MemberFIO, + Citizenship = Citizenship + }; + } +} diff --git a/Bank/BankDataBaseImplement/Models/Room.cs b/Bank/BankDataBaseImplement/Models/Room.cs new file mode 100644 index 0000000..5ca8749 --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/Room.cs @@ -0,0 +1,100 @@ +using BankContracts.BindingModels; +using BankContracts.ViewModels; +using BankDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class Room : IRoomModel + { + [Required] + public string RoomName { get; set; } = string.Empty; + [Required] + public string RoomFrame { get; set; } = string.Empty; + [Required] + public double RoomPrice { get; set; } + public int HeadwaiterId { get; private set; } + public int MealPlanId { get; private set; } + public int Id { get; private set; } + + public virtual Headwaiter Headwaiter { get; set; } + public virtual MealPlan MealPlan { get; set; } + + [ForeignKey("RoomId")] + public virtual List Dinners { get; set; } + + private Dictionary _roomDinners = null; + public Dictionary RoomDinners + { + get + { + if (_roomDinners == null) + { + _roomDinners = Dinners.ToDictionary(recPC => recPC.DinnerId, recPC => (recPC.Dinner as IDinnerModel)); + } + return _roomDinners; + } + } + + public static Room Create(BankDataBase context, RoomBindingModel model) + { + return new Room() + { + Id = model.Id, + RoomName = model.RoomName, + RoomFrame = model.RoomFrame, + RoomPrice = model.RoomPrice, + Dinners = model.RoomDinners.Select(x => new RoomDinner + { + Dinner = context.Dinners.First(y => y.Id == x.Key), + }).ToList() + }; + } + + public void Update(RoomBindingModel model) + { + RoomName = model.RoomName; + RoomFrame = model.RoomFrame; + RoomPrice = model.RoomPrice; + } + + public RoomViewModel GetViewModel => new() + { + Id = Id, + RoomName = RoomName, + RoomFrame = RoomFrame, + RoomPrice = RoomPrice, + RoomDinners = RoomDinners + }; + + public void UpdateDinners(BankDataBase context, RoomBindingModel model) + { + var roomDinners = context.RoomDinners.Where(rec => rec.RoomId == model.Id).ToList(); + + if (roomDinners != null) + { + context.RoomDinners.RemoveRange(roomDinners.Where(rec => !model.RoomDinners.ContainsKey(rec.DinnerId))); + context.SaveChanges(); + } + + var room = context.Rooms.First(x => x.Id == Id); + + foreach (var cm in model.RoomDinners) + { + context.RoomDinners.Add(new RoomDinner + { + Room = room, + Dinner = context.Dinners.First(x => x.Id == cm.Key) + }); + context.SaveChanges(); + } + _roomDinners = null; + } + } +} diff --git a/Bank/BankDataBaseImplement/Models/RoomDinner.cs b/Bank/BankDataBaseImplement/Models/RoomDinner.cs new file mode 100644 index 0000000..f80598e --- /dev/null +++ b/Bank/BankDataBaseImplement/Models/RoomDinner.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataBaseImplement.Models +{ + public class RoomDinner + { + public int Id { get; set; } + public int RoomId { get; set; } + public int DinnerId { get; set; } + + [Required] + public int Count { get; set; } + public virtual Room Room { get; set; } + public virtual Dinner Dinner { get; set; } + } +} diff --git a/Bank/BankDataModels/BankDataModels.csproj b/Bank/BankDataModels/BankDataModels.csproj new file mode 100644 index 0000000..6ea4cf5 --- /dev/null +++ b/Bank/BankDataModels/BankDataModels.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Bank/BankDataModels/DataModels/IClercModel.cs b/Bank/BankDataModels/DataModels/IClercModel.cs new file mode 100644 index 0000000..f00dd23 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IClercModel.cs @@ -0,0 +1,11 @@ +namespace BankDataModels.Models +{ + public interface IClercModel : IId + { + string OrganiserFIO { get; } + string OrganiserPassword { get; } + string OrganiserLogin { get; } + string OrganiserEmail { get; } + string OrganiserNumber { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IConferenceBookingModel.cs b/Bank/BankDataModels/DataModels/IConferenceBookingModel.cs new file mode 100644 index 0000000..87c726b --- /dev/null +++ b/Bank/BankDataModels/DataModels/IConferenceBookingModel.cs @@ -0,0 +1,9 @@ +namespace BankDataModels.Models +{ + public interface IConferenceBookingModel : IId + { + int HeadwaiterId { get;} + int ConferenceId { get; } + public Dictionary ConferenceBookingDinners { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IConferenceModel.cs b/Bank/BankDataModels/DataModels/IConferenceModel.cs new file mode 100644 index 0000000..3842f20 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IConferenceModel.cs @@ -0,0 +1,10 @@ +namespace BankDataModels.Models +{ + public interface IConferenceModel : IId + { + string ConferenceName { get; } + DateTime StartDate { get; } + int OrganiserId { get; } + public Dictionary ConferenceMembers { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IDinnerModel.cs b/Bank/BankDataModels/DataModels/IDinnerModel.cs new file mode 100644 index 0000000..9046784 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IDinnerModel.cs @@ -0,0 +1,9 @@ +namespace BankDataModels.Models +{ + public interface IDinnerModel : IId + { + string DinnerName { get; } + double DinnerPrice { get; } + int HeadwaiterId { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IHeadwaiterModel.cs b/Bank/BankDataModels/DataModels/IHeadwaiterModel.cs new file mode 100644 index 0000000..7da425a --- /dev/null +++ b/Bank/BankDataModels/DataModels/IHeadwaiterModel.cs @@ -0,0 +1,12 @@ + +namespace BankDataModels.Models +{ + public interface IHeadwaiterModel : IId + { + string HeadwaiterFIO { get; } + string HeadwaiterPassword { get; } + string HeadwaiterLogin { get; } + string HeadwaiterEmail { get; } + string HeadwaiterNumber { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IMealPlanModel.cs b/Bank/BankDataModels/DataModels/IMealPlanModel.cs new file mode 100644 index 0000000..97b8258 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IMealPlanModel.cs @@ -0,0 +1,10 @@ +namespace BankDataModels.Models +{ + public interface IMealPlanModel : IId + { + string MealPlanName { get; } + double MealPlanPrice { get; } + int OrganiserId { get; } + public Dictionary MealPlanMembers { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IMemberModel.cs b/Bank/BankDataModels/DataModels/IMemberModel.cs new file mode 100644 index 0000000..a94eab5 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IMemberModel.cs @@ -0,0 +1,9 @@ +namespace BankDataModels.Models +{ + public interface IMemberModel : IId + { + string MemberFIO { get; } + string Citizenship { get; } + int OrganiserId { get; } + } +} diff --git a/Bank/BankDataModels/DataModels/IRoomModel.cs b/Bank/BankDataModels/DataModels/IRoomModel.cs new file mode 100644 index 0000000..d4f0816 --- /dev/null +++ b/Bank/BankDataModels/DataModels/IRoomModel.cs @@ -0,0 +1,13 @@ + +namespace BankDataModels.Models +{ + public interface IRoomModel : IId + { + string RoomName { get; } + string RoomFrame { get; } + double RoomPrice { get; } + int HeadwaiterId { get; } + int MealPlanId { get; } + public Dictionary RoomDinners { get; } + } +} diff --git a/Bank/BankDataModels/lId.cs b/Bank/BankDataModels/lId.cs new file mode 100644 index 0000000..059547b --- /dev/null +++ b/Bank/BankDataModels/lId.cs @@ -0,0 +1,7 @@ +namespace BankDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/Bank/BankView/App.config b/Bank/BankView/App.config new file mode 100644 index 0000000..7d84477 --- /dev/null +++ b/Bank/BankView/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Bank/BankView/BankView.csproj b/Bank/BankView/BankView.csproj new file mode 100644 index 0000000..0816a76 --- /dev/null +++ b/Bank/BankView/BankView.csproj @@ -0,0 +1,125 @@ + + + + + Debug + AnyCPU + {2E8E7B5D-D712-4E0B-8E35-42B3D5F30210} + WinExe + BankView + BankView + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.7.0.0\lib\net462\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.7.0.0\lib\net462\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.7.0.0\lib\net462\Microsoft.Extensions.Primitives.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + ..\packages\System.Diagnostics.DiagnosticSource.7.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/Bank/BankView/Form1.Designer.cs b/Bank/BankView/Form1.Designer.cs new file mode 100644 index 0000000..14ba74e --- /dev/null +++ b/Bank/BankView/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace BankView +{ + partial class Form1 + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/Bank/BankView/Form1.cs b/Bank/BankView/Form1.cs new file mode 100644 index 0000000..c3b7440 --- /dev/null +++ b/Bank/BankView/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BankView +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/Bank/BankView/Program.cs b/Bank/BankView/Program.cs new file mode 100644 index 0000000..d96cbd6 --- /dev/null +++ b/Bank/BankView/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BankView +{ + internal static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Bank/BankView/Properties/AssemblyInfo.cs b/Bank/BankView/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..aae00c5 --- /dev/null +++ b/Bank/BankView/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("BankView")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BankView")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("2e8e7b5d-d712-4e0b-8e35-42b3d5f30210")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Bank/BankView/Properties/Resources.Designer.cs b/Bank/BankView/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a492e9b --- /dev/null +++ b/Bank/BankView/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace BankView.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BankView.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Bank/BankView/Properties/Resources.resx b/Bank/BankView/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Bank/BankView/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Bank/BankView/Properties/Settings.Designer.cs b/Bank/BankView/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8dd09a6 --- /dev/null +++ b/Bank/BankView/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace BankView.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Bank/BankView/Properties/Settings.settings b/Bank/BankView/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Bank/BankView/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Bank/BankView/packages.config b/Bank/BankView/packages.config new file mode 100644 index 0000000..c3ac0c7 --- /dev/null +++ b/Bank/BankView/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file