From 267a137101d2a3b41e5b3d1f9a661ce79fc0a6e1 Mon Sep 17 00:00:00 2001 From: bocchanskyy Date: Tue, 27 Aug 2024 16:24:55 +0400 Subject: [PATCH] still got work to do --- .../BusinessLogic/CosmeticLogic.cs | 2 +- .../BusinessLogic/LaborCostLogic.cs | 2 +- .../BusinessLogic/MessageInfoLogic.cs | 90 +++++++ .../BusinessLogic/OrderLogic.cs | 2 +- .../BusinessLogic/ProcedureLogic.cs | 2 +- .../BusinessLogic/ReportLogic.cs | 106 ++++++++ .../BusinessLogic/ServiceLogic.cs | 2 +- .../BusinessLogic/StoreKeeperLogic.cs | 2 +- .../OfficePackage/AbstractSaveToExcel.cs | 6 +- .../OfficePackage/AbstractSaveToPdf.cs | 6 +- .../OfficePackage/AbstractSaveToWord.cs | 6 +- .../HelperEnums/ExcelStyleInfoType.cs | 2 +- .../HelperEnums/PdfParagraphAlignmentType.cs | 2 +- .../HelperEnums/WordJustificationType.cs | 2 +- .../HelperModels/ExcelCellParameters.cs | 4 +- .../OfficePackage/HelperModels/ExcelInfo.cs | 2 +- .../HelperModels/ExcelMergeParameters.cs | 2 +- .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../HelperModels/PdfParagraph.cs | 4 +- .../HelperModels/PdfRowParameters.cs | 4 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../HelperModels/WordParagraph.cs | 2 +- .../HelperModels/WordTextProperties.cs | 4 +- .../OfficePackage/Implements/SaveToExcel.cs | 6 +- .../OfficePackage/Implements/SaveToPdf.cs | 8 +- .../OfficePackage/Implements/SaveToWord.cs | 6 +- .../BindingModels/MessageInfoBindingModel.cs | 1 - .../BindingModels/ReportBindingModel.cs | 16 ++ .../BindingModels/ReportOrderBindingModel.cs | 17 ++ .../ReportServiceBindingModel.cs | 15 ++ .../IMessageInfoLogic.cs | 17 ++ .../BusinessLogicContracts/IReportLogic.cs | 6 +- .../SearchModels/MessageInfoSearchModel.cs | 14 + .../StoragesContracts/IMessageInfoStorage.cs | 19 ++ .../ViewModels/CosmeticViewModel.cs | 4 +- .../ViewModels/MessageInfoViewModel.cs | 30 +++ .../ReportCosmeticProceduresViewModel.cs | 15 ++ .../ViewModels/ReportOrdersViewModel.cs | 22 ++ .../ReportProcedureCosmeticsViewModel.cs | 16 ++ .../ViewModels/ReportServicesViewModel.cs | 20 ++ .../ViewModels/ServiceViewModel.cs | 4 +- .../Models/ICosmeticModel.cs | 1 + .../Models/IMessageInfoModel.cs | 17 ++ .../Models/IOrderModel.cs | 3 + .../Models/IProcedureModel.cs | 1 + .../Models/IServiceModel.cs | 2 + .../BeautyStudioDatabase.cs | 1 + .../Implements/MessageInfoStorage.cs | 58 ++++ .../Models/Cosmetic.cs | 7 +- .../Models/MessageInfo.cs | 65 +++++ .../Models/StoreKeeper.cs | 4 - .../BeautyStudioRestAPI.csproj | 1 - .../Controllers/CosmeticController.cs | 2 +- .../Controllers/LaborCostController.cs | 2 +- .../Controllers/OrderController.cs | 2 +- .../Controllers/ProcedureController.cs | 2 +- .../Controllers/ReportController.cs | 144 ++++------ .../Controllers/ServiceController.cs | 2 +- .../Controllers/StoreKeeperController.cs | 2 +- BeautyStudio/BeautyStudioRestAPI/Program.cs | 26 +- .../Properties/launchSettings.json | 2 +- .../BeautyStudioRestAPI/appsettings.json | 8 +- .../BeautyStudioRestAPI/log4net.config | 2 +- .../StoreKeeperWebApp/APIStoreKeeper.cs | 49 ++++ .../Controllers/HomeController.cs | 247 +++++++++++++++++- .../StoreKeeperWebApp.csproj | 6 + .../Views/Shared/UpdateLaborCosts.cshtml | 29 ++ .../Views/Shared/_Layout.cshtml | 8 +- .../StoreKeeperWebApp/appsettings.json | 8 +- 69 files changed, 1014 insertions(+), 181 deletions(-) create mode 100644 BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs create mode 100644 BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 BeautyStudio/BeautyStudioContracts/BindingModels/ReportBindingModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/BindingModels/ReportOrderBindingModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs create mode 100644 BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs create mode 100644 BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/ViewModels/ReportProcedureCosmeticsViewModel.cs create mode 100644 BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs create mode 100644 BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs create mode 100644 BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs create mode 100644 BeautyStudio/BeautyStudioDatabaseImplement/Models/MessageInfo.cs create mode 100644 BeautyStudio/StoreKeeperWebApp/APIStoreKeeper.cs create mode 100644 BeautyStudio/StoreKeeperWebApp/Views/Shared/UpdateLaborCosts.cshtml diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs index 644f0d5..d645c62 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class CosmeticLogic : ICosmeticLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs index b48eeb8..8ef8cec 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class LaborCostLogic : ILaborCostLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs new file mode 100644 index 0000000..9b76b52 --- /dev/null +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs @@ -0,0 +1,90 @@ +using Microsoft.Extensions.Logging; +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.StoragesContracts; +using BeautyStudioContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioBusinessLogic.BusinessLogic +{ + public class MessageInfoLogic : IMessageInfoLogic + { + private readonly ILogger _logger; + private readonly IMessageInfoStorage _messageInfoStorage; + private readonly IStoreKeeperStorage _staffmemberStorage; + public MessageInfoLogic(ILogger logger, IMessageInfoStorage messageInfoStorage, IStoreKeeperStorage staffmemberStorage) + { + _logger = logger; + _messageInfoStorage = messageInfoStorage; + _staffmemberStorage = staffmemberStorage; + } + public List? ReadList(MessageInfoSearchModel? model) + { + _logger.LogInformation("ReadList. MessageId:{MessageId}. StorekeeperId:{StorekeeperId}", model?.MessageId, model?.StorekeeperId); + var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool Create(MessageInfoBindingModel model) + { + CheckModel(model); + if (_messageInfoStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + private void CheckModel(MessageInfoBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.MessageId)) + { + throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId)); + } + if (string.IsNullOrEmpty(model.SenderName)) + { + throw new ArgumentNullException("Не указана почта", nameof(model.SenderName)); + } + if (string.IsNullOrEmpty(model.Subject)) + { + throw new ArgumentNullException("Не указана тема", nameof(model.Subject)); + } + if (string.IsNullOrEmpty(model.Body)) + { + throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject)); + } + + _logger.LogInformation("MessageInfo. MessageId:{MessageId}. SenderName:{SenderName}. Subject:{Subject}. Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body); + var element = _staffmemberStorage.GetElement(new StoreKeeperSearchModel + { + StoreKeeperEmail = model.SenderName + }); + if (element == null) + { + _logger.LogWarning("Не удалоссь найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName); + } + else + { + model.StorekeeperId = element.Id; + } + } + } +} diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs index e128177..a01f53c 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs @@ -11,7 +11,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class OrderLogic : IOrderLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs index fe5fdbd..a13d7dd 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class ProcedureLogic : IProcedureLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs new file mode 100644 index 0000000..dca40db --- /dev/null +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioContracts.StoragesContracts; +using BeautyStudioBusinessLogic.OfficePackage; +using BeautyStudioContracts.ViewModels; +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.SearchModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.Implements; + +namespace BeautyStudioBusinessLogic.BusinessLogic +{ + public class ReportLogic : IReportLogic + { + private readonly IServiceStorage _serviceStorage; + private readonly IProcedureStorage _procedureStorage; + private readonly ICosmeticStorage _cosmeticStorage; + + private readonly AbstractSaveToExcel _saveToExcel; + private readonly AbstractSaveToWord _saveToWord; + private readonly AbstractSaveToPdf _saveToPdf; + + public ReportLogic(IServiceStorage serviceStorage, IProcedureStorage procedureStorage, ICosmeticStorage cosmeticStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) + { + _serviceStorage = serviceStorage; + _procedureStorage = procedureStorage; + _cosmeticStorage = cosmeticStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + //Получение косметики по процедуре + public List GetCosmeticProcedures() + { + var cosmetics = _cosmeticStorage.GetFullList(); + var procedures = _procedureStorage.GetFullList(); + var list = new List(); + foreach (var cosmetic in cosmetics) + { + var record = new ReportCosmeticProceduresViewModel + { + CosmeticName = cosmetic.CosmeticName, + Procedures = new List(), + }; + foreach (var procedure in procedures) + { + if (cosmetic.CosmeticProcedure.ContainsKey(procedure.Id)) + { + record.Procedures.Add(new(procedure.ProcedureName)); + } + } + list.Add(record); + } + return list; + } + + public List GetServices(ReportServiceBindingModel model) + { + List r = _serviceStorage.GetFullList() + .Select(x => new ReportServicesViewModel + { + Id = x.Id, + ServiceName = x.ServiceName, + Cosmetics = x.ServiceCosmetic, + Procedures = x.ServiceProcedure, + ServicePrice = x.ServiceProcedure.Sum(kv => kv.Value.Item1.ProcedurePrice) + + x.ServiceCosmetic.Sum(kv => kv.Value.Item1.CosmeticPrice) + }).ToList(); + return r; + } + + public void SaveCosmeticProceduresToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список процедур по косметике", + CosmeticProcedures = GetCosmeticProcedures() + }); + } + public void SaveCosmeticProceduresToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Список процедур по косметике", + CosmeticProcedures = GetCosmeticProcedures() + }); + } + + public void SaveServicesToPdfFile(ReportServiceBindingModel model) + { + var report = new PdfInfo + { + FileName = model.FileName, + Title = "Список услуг", + Services = GetServices(model) + }; + _saveToPdf.CreateReport(report); + } + } +} diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs index 77bd596..fd580f3 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class ServiceLogic : IServiceLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs index 36fc316..185a276 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs @@ -5,7 +5,7 @@ using BeautyStudioContracts.StoragesContracts; using BeautyStudioContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace BeautyStudioBusinessLogic.BusinessLogics +namespace BeautyStudioBusinessLogic.BusinessLogic { public class StoreKeeperLogic : IStoreKeeperLogic { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 5634942..796beab 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -1,12 +1,12 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage +namespace BeautyStudioBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 923030a..668e6c3 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -1,5 +1,5 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using BeautyStudioContracts.ViewModels; using System; using System.Collections; @@ -8,7 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogics.OfficePackage +namespace BeautyStudioBusinessLogic.OfficePackage { /// /// Абстрактный класс для создания отчета Pdf diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 1fc5ab9..82bed17 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -1,12 +1,12 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage +namespace BeautyStudioBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index d166447..c757f28 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums +namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums { public enum ExcelStyleInfoType { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs index 3f20e9e..48b7a68 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums +namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums { public enum PdfParagraphAlignmentType { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs index b00b7c1..47a3019 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums +namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums { public enum WordJustificationType { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs index ed04d9c..f00d32a 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -1,11 +1,11 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class ExcelCellParameters { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index e35e616..e0c3255 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class ExcelInfo { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs index fc1b186..e6ecc66 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class ExcelMergeParameters { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index b8b005a..76dada7 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class PdfInfo { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs index 1352c22..944d937 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -1,11 +1,11 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class PdfParagraph { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs index 842e3c2..2c9a242 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -1,11 +1,11 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class PdfRowParameters { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index a32d8a1..4dce0ad 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class WordInfo { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs index 919437f..ddb5d6b 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class WordParagraph { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs index 0e271de..fc00f37 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -1,11 +1,11 @@ -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels +namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels { public class WordTextProperties { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index fd37aef..48d5210 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -3,15 +3,15 @@ using DocumentFormat.OpenXml.Office2013.Excel; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml; -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautyStudioBusinesLogic.OfficePackage.Implements +namespace BeautyStudioBusinessLogic.OfficePackage.Implements { public class SaveToExcel : AbstractSaveToExcel { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index a6ec4c3..99677c2 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -1,16 +1,16 @@ using MigraDoc.DocumentObjectModel; using MigraDoc.DocumentObjectModel.Tables; using MigraDoc.Rendering; -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using BeautyStudioBusinesLogics.OfficePackage; +using BeautyStudioBusinessLogic.OfficePackage; -namespace BeautyStudioBusinesLogic.OfficePackage.Implements +namespace BeautyStudioBusinessLogic.OfficePackage.Implements { public class SaveToPdf : AbstractSaveToPdf { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs index f172b5b..f9ea149 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -1,8 +1,8 @@ using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; -using BeautyStudioBusinesLogic.OfficePackage.HelperEnums; -using BeautyStudioBusinesLogic.OfficePackage.HelperModels; +using BeautyStudioBusinessLogic.OfficePackage.HelperEnums; +using BeautyStudioBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -13,7 +13,7 @@ using static System.Net.Mime.MediaTypeNames; using Document = DocumentFormat.OpenXml.Wordprocessing.Document; using Text = DocumentFormat.OpenXml.Wordprocessing.Text; -namespace BeautyStudioBusinesLogic.OfficePackage.Implements +namespace BeautyStudioBusinessLogic.OfficePackage.Implements { public class SaveToWord : AbstractSaveToWord { diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs index 999d6aa..5ded4b1 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs @@ -10,7 +10,6 @@ namespace BeautyStudioContracts.BindingModels public class MessageInfoBindingModel : IMessageInfoModel { public string MessageId { get; set; } = string.Empty; - public int? WorkerId { get; set; } public int? StorekeeperId { get; set; } public string SenderName { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty; diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ReportBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..2f37802 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BeautyStudioContracts.BindingModels; + +namespace BeautyStudioContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set;} + } +} diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ReportOrderBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportOrderBindingModel.cs new file mode 100644 index 0000000..c5bc4d1 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportOrderBindingModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.BindingModels +{ + public class ReportOrderBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } = DateTime.Now; + public DateTime? DateTo { get; set; } = DateTime.Now; + public int? WorkerId { get; set; } + public string? Email { get; set; } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs new file mode 100644 index 0000000..90c5eb8 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.BindingModels +{ + public class ReportServiceBindingModel + { + public string FileName { get; set; } = string.Empty; + public int? StorekeeperId { get; set; } + public string? Email { get; set; } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs new file mode 100644 index 0000000..bc16df2 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs @@ -0,0 +1,17 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.BusinessLogicContracts +{ + public interface IMessageInfoLogic + { + List? ReadList(MessageInfoSearchModel? model); + bool Create(MessageInfoBindingModel model); + } +} diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs index 27e76b9..0559561 100644 --- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs +++ b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs @@ -1,12 +1,12 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeautySalonContracts.BusinessLogicsContracts +namespace BeautyStudioContracts.BusinessLogicContracts { public interface IReportLogic { diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs new file mode 100644 index 0000000..50e0809 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.SearchModels +{ + public class MessageInfoSearchModel + { + public int? StorekeeperId { get; set; } + public string? MessageId { get; set; } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs new file mode 100644 index 0000000..16f7c57 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs @@ -0,0 +1,19 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.StoragesContracts +{ + public interface IMessageInfoStorage + { + List GetFullList(); + List GetFilteredList(MessageInfoSearchModel model); + MessageInfoViewModel? GetElement(MessageInfoSearchModel model); + MessageInfoViewModel? Insert(MessageInfoBindingModel model); + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs index 3035f35..80e55b2 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs @@ -22,7 +22,7 @@ namespace BeautyStudioContracts.ViewModels public int LaborCostId { get; set; } - public List ServiceCosmetic { get; set; } = new(); - public List CosmeticProcedure { get; set; } = new(); + //public List ServiceCosmetic { get; set; } = new(); + public Dictionary CosmeticProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs new file mode 100644 index 0000000..72a41a7 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs @@ -0,0 +1,30 @@ +using BeautyStudioDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class MessageInfoViewModel : IMessageInfoModel + { + public string MessageId { get; set; } = string.Empty; + + [DisplayName("Отправитель")] + public int? StorekeeperId { get; set; } + + [DisplayName("Получатель")] + public string SenderName { get; set; } = string.Empty; + + [DisplayName("Дата письма")] + public DateTime DateDelivery { get; set; } + + [DisplayName("Заголовок")] + public string Subject { get; set; } = string.Empty; + + [DisplayName("Текст")] + public string Body { get; set; } = string.Empty; + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs new file mode 100644 index 0000000..82eff51 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ReportCosmeticProceduresViewModel + { + public string CosmeticName { get; set; } = string.Empty; + public List Procedures { get; set; } = new(); + + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportOrdersViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportOrdersViewModel.cs new file mode 100644 index 0000000..47b050c --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportOrdersViewModel.cs @@ -0,0 +1,22 @@ +using BeautyStudioDataModels.Enums; +using BeautyStudioDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ReportOrdersViewModel + { + public int Id { get; set; } + public DateTime DateCreate { get; set; } + public double OrderAmount { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public Dictionary Cosmetics { get; set; } = new(); + public Dictionary Procedures { get; set; } = new(); + public Dictionary Services { get; set; } = new(); + } +} + diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportProcedureCosmeticsViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportProcedureCosmeticsViewModel.cs new file mode 100644 index 0000000..6e0c24a --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportProcedureCosmeticsViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ReportProcedureCosmeticsViewModel + { + public string ProcedureName { get; set; } = string.Empty; + public int TotalCount { get; set; } + public List<(string Cosmetic, int Count)> Cosmetics { get; set; } = new(); + + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs new file mode 100644 index 0000000..6f6e4e8 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs @@ -0,0 +1,20 @@ +using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ReportServicesViewModel + { + public int Id { get; set; } + public string ServiceName { get; set; } = string.Empty; + public Dictionary Cosmetics { get; set; } = new(); + public Dictionary Procedures { get; set; } = new(); + public double ServicePrice { get; set; } + } +} + diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs index 39b888b..d6fee74 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs @@ -20,8 +20,8 @@ namespace BeautyStudioContracts.ViewModels [DisplayName("Сотрудник")] public int StoreKeeperId { get; set; } - public List ServiceCosmetic { get; set; } = new(); - public List ServiceProcedure { get; set; } = new(); + public Dictionary ServiceCosmetic { get; set; } = new(); + public Dictionary ServiceProcedure { get; set; } = new(); public List OrderService { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs index c388005..81247a2 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs @@ -11,5 +11,6 @@ namespace BeautyStudioDataModels.Models string CosmeticName { get; } double CosmeticPrice { get; } int LaborCostId { get; } + Dictionary CosmeticProcedure { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs new file mode 100644 index 0000000..a3907e1 --- /dev/null +++ b/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioDataModels.Models +{ + public interface IMessageInfoModel + { + string MessageId { get; } + string SenderName { get; } + DateTime DateDelivery { get; } + string Subject { get; } + string Body { get; } + } +} diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs index cbd603a..84945ba 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs @@ -15,6 +15,9 @@ namespace BeautyStudioDataModels.Models OrderStatus Status { get; } int ServiceId { get; } int CosmeticId { get; } + Dictionary OrderCosmetic { get; } + Dictionary OrderProcedureCosmetic { get; } + Dictionary OrderService { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs index 74a7b49..c255acf 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs @@ -11,5 +11,6 @@ namespace BeautyStudioDataModels.Models string ProcedureName { get; } double ProcedureCost { get; } string ProcedureDescription { get; } + Dictionary ProcedureCosmetics { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs index a53dd68..4a5656a 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs @@ -12,5 +12,7 @@ namespace BeautyStudioDataModels.Models string ServiceName { get; } double ServicePrice { get; } int StoreKeeperId { get; set; } + Dictionary ServiceCosmetic { get; } + Dictionary ServiceProcedure { get; } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs index 07de06f..b9bd6b5 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs @@ -27,5 +27,6 @@ namespace BeautyStudioDatabaseImplement public virtual DbSet OrderProcedures { set; get; } public virtual DbSet CosmeticProcedures { set; get; } public virtual DbSet StoreKeepers { set; get; } + public virtual DbSet MessageInfos { set; get; } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs new file mode 100644 index 0000000..285a194 --- /dev/null +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs @@ -0,0 +1,58 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.StoragesContracts; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioDatabaseImplement.Implements +{ + public class MessageInfoStorage : IMessageInfoStorage + { + public List GetFullList() + { + using var context = new BeautyStudioDatabase(); + return context.MessageInfos.Select(x => x.GetViewModel).ToList(); + } + public List GetFilteredList(MessageInfoSearchModel model) + { + if (!model.StorekeeperId.HasValue) + { + return new List(); + } + + using var context = new BeautyStudioDatabase(); + + return context.MessageInfos + .Where(x => x.StorekeeperId == model.StorekeeperId && x.StorekeeperId == model.StorekeeperId) + .Select(x => x.GetViewModel) + .ToList(); + } + + public MessageInfoViewModel? GetElement(MessageInfoSearchModel model) + { + if (string.IsNullOrEmpty(model.MessageId)) + { + return new(); + } + using var context = new BeautyStudioDatabase(); + return context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel; + } + public MessageInfoViewModel? Insert(MessageInfoBindingModel model) + { + var newMessage = MessageInfo.Create(model); + if (newMessage == null) + { + return null; + } + using var context = new BeautyStudioDatabase(); + context.MessageInfos.Add(newMessage); + context.SaveChanges(); + return newMessage.GetViewModel; + } + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs index c953dfb..23e5dd0 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs @@ -28,9 +28,10 @@ namespace BeautyStudioDatabaseImplement.Models public int LaborCostId { get; set; } public virtual LaborCost LaborCost { get; set; } = new(); - // связь многие-ко-многим заказов и косметики - [ForeignKey("CosmeticId")] - public virtual List Orders { get; set; } = new(); + //// связь многие-ко-многим заказов и косметики + //[ForeignKey("CosmeticId")] + //public virtual List Orders { get; set; } = new(); + // связь многие-ко-многим косметики с процедурами [ForeignKey("CosmeticId")] public virtual List Procedures { get; set; } = new(); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/MessageInfo.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/MessageInfo.cs new file mode 100644 index 0000000..6951ef9 --- /dev/null +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/MessageInfo.cs @@ -0,0 +1,65 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.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 BeautyStudioDatabaseImplement.Models +{ + public class MessageInfo : IMessageInfoModel + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public string MessageId { get; set; } = string.Empty; + + public int? StorekeeperId { get; set; } + + public virtual StoreKeeper? Storekeeper { get; set; } + + [Required] + public string SenderName { get; set; } = string.Empty; + + [Required] + public DateTime DateDelivery { get; set; } + + [Required] + public string Subject { get; set; } = string.Empty; + + [Required] + public string Body { get; set; } = string.Empty; + + public static MessageInfo? Create(MessageInfoBindingModel? model) + { + if (model == null) + { + return null; + } + return new() + { + MessageId = model.MessageId, + StorekeeperId = model.StorekeeperId, + SenderName = model.SenderName, + DateDelivery = model.DateDelivery, + Subject = model.Subject, + Body = model.Body, + + }; + } + + + public MessageInfoViewModel GetViewModel => new() + { + MessageId = MessageId, + StorekeeperId = StorekeeperId, + SenderName = SenderName, + DateDelivery = DateDelivery, + Subject = Subject, + Body = Body + }; + } +} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/StoreKeeper.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/StoreKeeper.cs index 2098017..37af6c0 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/StoreKeeper.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/StoreKeeper.cs @@ -25,10 +25,6 @@ namespace BeautyStudioDatabaseImplement.Models [Required] public string StoreKeeperPhone { get; set; } = string.Empty; - //связь один-ко-многим кладовщика с косметикой - [ForeignKey("StoreKeeperId")] - public virtual List Cosmetics { get; set; } = new(); - public static StoreKeeper? Create(StoreKeeperBindingModel model) { diff --git a/BeautyStudio/BeautyStudioRestAPI/BeautyStudioRestAPI.csproj b/BeautyStudio/BeautyStudioRestAPI/BeautyStudioRestAPI.csproj index 03d3fe0..411b9ad 100644 --- a/BeautyStudio/BeautyStudioRestAPI/BeautyStudioRestAPI.csproj +++ b/BeautyStudio/BeautyStudioRestAPI/BeautyStudioRestAPI.csproj @@ -19,7 +19,6 @@ - diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/CosmeticController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/CosmeticController.cs index 1d62b95..febfa95 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/CosmeticController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/CosmeticController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeautyStudioRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/LaborCostController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/LaborCostController.cs index d93be1e..b1ab6b3 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/LaborCostController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/LaborCostController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeautyStudioRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/OrderController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/OrderController.cs index 98d1cfe..4507713 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/OrderController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/OrderController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeautyStudioRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/ProcedureController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/ProcedureController.cs index 894ddcb..8a3977b 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/ProcedureController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/ProcedureController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeutySalonClientApp.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs index 7a9762e..b7857e4 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs @@ -3,34 +3,32 @@ using BeautyStudioContracts.BindingModels; using BeautyStudioContracts.BusinessLogicContracts; using Microsoft.AspNetCore.Mvc; -namespace HotelRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class ReportController : Controller { private readonly ILogger _logger; - private readonly IReportStoreKeeperLogic _reportStoreKeeperLogic; - private readonly AbstractMailWorker _mailWorker; + private readonly IReportLogic _reportLogic; - public ReportController(ILogger logger, IReportStoreKeeperLogic reportStoreKeeperLogic, AbstractMailWorker mailWorker) + private readonly AbstractMailWorker _mailWorker; + public ReportController(ILogger logger, IReportLogic reportLogic, AbstractMailWorker abstractMailWorker) { _logger = logger; - _reportStoreKeeperLogic = reportStoreKeeperLogic; - _mailWorker = mailWorker; + _reportLogic = reportLogic; + _mailWorker = abstractMailWorker; } - [HttpPost] - public void CreateStoreKeeperReportToPdfFile(ReportStoreKeeperBindingModel model) + public void SaveServicesPdfFile(ReportBindingModel report) { try { - _reportStoreKeeperLogic.SaveClientsToPdfFile(new ReportStoreKeeperBindingModel + _reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel { - DateFrom = model.DateFrom, - DateTo = model.DateTo, - StoreKeeperId = model.StoreKeeperId, - FileName = "C:\\Reports\\pdffile.pdf", + DateFrom = report.DateFrom, + DateTo = report.DateTo, + FileName = "C:\\reports\\pdfservicesreport.pdf", }); } catch (Exception ex) @@ -39,13 +37,51 @@ namespace HotelRestApi.Controllers throw; } } - [HttpPost] - public void SendPdfToMail(MailSendInfoBindingModel model) + public void SaveCosmeticProceduresToWordFile(ReportBindingModel report) { try { - _mailWorker.MailSendAsync(model); + _reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel { FileName = "C:\\reports\\wordcosmeticproceduresreport.docx" }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + [HttpPost] + public void SaveCosmeticProceduresToExcelFile(ReportBindingModel report) + { + try + { + _reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel { FileName = "C:\\reports\\excelcosmeticproceduresreport.xlsx" }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + [HttpPost] + public void MailSend(ReportServiceBindingModel report) + { + try + { + _reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel + { + DateFrom = report.DateFrom, + DateTo = report.DateTo, + FileName = report.FileName, + StorekeeperId = report.StorekeeperId, + Email = report.Email, + }); + _mailWorker.MailSendAsync(new MailSendInfoBindingModel + { + MailAddress = report.Email!, + Subject = "Отчет по услугам", + Text = "Ваш отчет:" + }); } catch (Exception ex) { @@ -53,81 +89,5 @@ namespace HotelRestApi.Controllers throw; } } - - [HttpPost] - public void CreateStoreKeeperReportToWordFile(ReportStoreKeeperBindingModel model) - { - try - { - _reportStoreKeeperLogic.SaveClientHearingToWordFile(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - } - - [HttpPost] - public void CreateOrganiserReportToExcelFile(ReportStoreKeeperBindingModel model) - { - try - { - _reportStoreKeeperLogic.SaveClientHearingToExcelFile(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - } - - /*[HttpPost] - public void CreateHeadwaiterReportToWordFile(ReportHeadwaiterBindingModel model) - { - try - { - _reportHeadwaiterLogic.SaveLunchRoomToWordFile(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - } - - [HttpPost] - public void CreateHeadwaiterReportToExcelFile(ReportHeadwaiterBindingModel model) - { - try - { - _reportHeadwaiterLogic.SaveLunchRoomToExcelFile(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - } - - [HttpPost] - public void CreateHeadwaiterReportToPdfFile(ReportHeadwaiterBindingModel model) - { - try - { - _reportHeadwaiterLogic.SaveLunchesToPdfFile(new ReportHeadwaiterBindingModel - { - FileName = "C:\\Reports\\pdffile.pdf", - DateFrom = model.DateFrom, - DateTo = model.DateTo, - HeadwaiterId = model.HeadwaiterId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - }*/ } } diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/ServiceController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/ServiceController.cs index ce7fffb..177a631 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/ServiceController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/ServiceController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeautyStudioRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Controllers/StoreKeeperController.cs b/BeautyStudio/BeautyStudioRestAPI/Controllers/StoreKeeperController.cs index d5d98a9..55055d4 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Controllers/StoreKeeperController.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Controllers/StoreKeeperController.cs @@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.ViewModels; using Microsoft.AspNetCore.Mvc; -namespace BeautyStudioRestApi.Controllers +namespace BeautyStudioRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] diff --git a/BeautyStudio/BeautyStudioRestAPI/Program.cs b/BeautyStudio/BeautyStudioRestAPI/Program.cs index b87d1cc..7f3667d 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Program.cs +++ b/BeautyStudio/BeautyStudioRestAPI/Program.cs @@ -1,4 +1,4 @@ -using BeautyStudioBusinessLogic.BusinessLogics; +using BeautyStudioBusinessLogic.BusinessLogic; using BeautyStudioContracts.BindingModels; using BeautyStudioContracts.BusinessLogicContracts; using BeautyStudioContracts.StoragesContracts; @@ -7,9 +7,7 @@ using BeautyStudioBusinessLogic.OfficePackage; using BeautyStudioBusinessLogic.OfficePackage.Implements; using Microsoft.OpenApi.Models; using System.Reflection.PortableExecutable; -using BeautyStudioBusinesLogics.OfficePackage; -using BeautyStudioBusinesLogic.OfficePackage.Implements; -using BeautyStudioBusinesLogic.OfficePackage; +using BeautyStudioBusinessLogic.MailWorker; var builder = WebApplication.CreateBuilder(args); @@ -32,11 +30,16 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + builder.Services.AddControllers(); @@ -44,16 +47,25 @@ builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "BeautyStudioRestApi", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "BeautyStudioRestAPI", Version = "v1" }); }); var app = builder.Build(); - +var mailSender = app.Services.GetService(); +mailSender?.MailConfig(new MailConfigBindingModel +{ + MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty, + MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty, + SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty, + SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()), + PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty, + PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString()) +}); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BeautyStudioRestApi v1")); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BeautyStudioRestAPI v1")); } app.UseAuthorization(); diff --git a/BeautyStudio/BeautyStudioRestAPI/Properties/launchSettings.json b/BeautyStudio/BeautyStudioRestAPI/Properties/launchSettings.json index 75d8edb..056b0c4 100644 --- a/BeautyStudio/BeautyStudioRestAPI/Properties/launchSettings.json +++ b/BeautyStudio/BeautyStudioRestAPI/Properties/launchSettings.json @@ -9,7 +9,7 @@ } }, "profiles": { - "BeautyStudioRestApi": { + "BeautyStudioRestAPI": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, diff --git a/BeautyStudio/BeautyStudioRestAPI/appsettings.json b/BeautyStudio/BeautyStudioRestAPI/appsettings.json index 91ecd19..10f68b8 100644 --- a/BeautyStudio/BeautyStudioRestAPI/appsettings.json +++ b/BeautyStudio/BeautyStudioRestAPI/appsettings.json @@ -5,11 +5,5 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*", - "SmtpClientHost": "smtp.gmail.com", - "SmtpClientPort": "587", - "PopHost": "pop.gmail.com", - "PopPort": "995", - "MailLogin": "rpplabs724@gmail.com", - "MailPassword": "pyen krno ssaj rlvm" + "AllowedHosts": "*" } diff --git a/BeautyStudio/BeautyStudioRestAPI/log4net.config b/BeautyStudio/BeautyStudioRestAPI/log4net.config index 650c290..2b5b964 100644 --- a/BeautyStudio/BeautyStudioRestAPI/log4net.config +++ b/BeautyStudio/BeautyStudioRestAPI/log4net.config @@ -1,7 +1,7 @@  - + diff --git a/BeautyStudio/StoreKeeperWebApp/APIStoreKeeper.cs b/BeautyStudio/StoreKeeperWebApp/APIStoreKeeper.cs new file mode 100644 index 0000000..76febdb --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/APIStoreKeeper.cs @@ -0,0 +1,49 @@ +using BeautyStudioContracts.ViewModels; +using Newtonsoft.Json; +using System.Net.Http.Headers; +using System.Text; + +namespace StoreKeeperWebApp +{ + public class APIStoreKeeper + { + private static readonly HttpClient _storekeeper = new(); + + public static StoreKeeperViewModel? Storekeeper { get; set; } = null; + + public static void Connect(IConfiguration configuration) + { + _storekeeper.BaseAddress = new Uri(configuration["IPAddress"]); + _storekeeper.DefaultRequestHeaders.Accept.Clear(); + _storekeeper.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + } + + public static T? GetRequest(string requestUrl) + { + var response = _storekeeper.GetAsync(requestUrl); + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + + public static void PostRequest(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _storekeeper.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + if (!response.Result.IsSuccessStatusCode) + { + throw new Exception(result); + } + } + } +} \ No newline at end of file diff --git a/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs b/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs index 0d3db9b..2d9d045 100644 --- a/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs +++ b/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs @@ -1,27 +1,264 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.ViewModels; +using StoreKeeperWebApp; using Microsoft.AspNetCore.Mvc; -using StoreKeeperWebApp.Models; using System.Diagnostics; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioBusinessLogic.MailWorker; +using DocumentFormat.OpenXml.Spreadsheet; +using Microsoft.Extensions.Hosting; +using BeautyStudioContracts.SearchModels; +using StoreKeeperWebApp.Models; +using Microsoft.AspNetCore.Identity.Data; namespace StoreKeeperWebApp.Controllers { public class HomeController : Controller { - private readonly ILogger _logger; + private readonly ILogger _logger; + private readonly IStoreKeeperLogic _logic; + private readonly ICosmeticLogic _cosmeticLogic; + private readonly IReportLogic _reportLogic; - public HomeController(ILogger logger) + private readonly AbstractMailWorker _mailLogic; + + public HomeController(ILogger logger, IStoreKeeperLogic workerLogic, ICosmeticLogic cosmeticLogic, IReportLogic reportLogic, AbstractMailWorker mailLogic) { _logger = logger; + _logic = workerLogic; + _cosmeticLogic = cosmeticLogic; + _reportLogic = reportLogic; + _mailLogic = mailLogic; } + [HttpGet] public IActionResult Index() { - return View(); + if (APIStoreKeeper.Storekeeper == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIStoreKeeper.Storekeeper); } + [HttpGet] public IActionResult Privacy() { + if (APIStoreKeeper.Storekeeper == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIStoreKeeper.Storekeeper); + } + [HttpPost] + + public void Privacy(string login, string password, string fio, string phone) + { + if (APIStoreKeeper.Storekeeper == null) + { + throw new Exception(" ?... , !!!"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception(" , , "); + } + _logic.Update(new StoreKeeperBindingModel + { + Id = APIStoreKeeper.Storekeeper.Id, + StoreKeeperFIO = fio, + StoreKeeperLogin = login, + StoreKeeperPassword = password, + StoreKeeperEmail = login, + StoreKeeperPhone = phone + + }); + APIStoreKeeper.Storekeeper.StoreKeeperFIO = fio; + APIStoreKeeper.Storekeeper.StoreKeeperLogin = login; + APIStoreKeeper.Storekeeper.StoreKeeperPassword = password; + APIStoreKeeper.Storekeeper.StoreKeeperEmail = login; + APIStoreKeeper.Storekeeper.StoreKeeperPhone = phone; + + Response.Redirect("Privacy"); + } + + [HttpGet] + public IActionResult Enter() + { + if (APIStoreKeeper.Storekeeper != null) + { + throw new Exception(" !"); + } + return View(); } + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + { + throw new Exception(" !"); + } + + APIStoreKeeper.Storekeeper = _logic.ReadElement(new StoreKeeperSearchModel + { + StoreKeeperEmail = login, + StoreKeeperPassword = password + }); + if (APIStoreKeeper.Storekeeper == null) + { + throw new Exception(" /"); + } + + Response.Redirect("Index"); + } + + [HttpGet] + public IActionResult Register() + { + if (APIStoreKeeper.Storekeeper != null) + { + throw new Exception(" !"); + } + + return View(); + } + [HttpPost] + public void Register(string fullname, string email, string password, string phone) + { + if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(phone)) + { + throw new Exception(" !"); + } + + _logic.Create(new StoreKeeperBindingModel + { + StoreKeeperFIO = fullname, + StoreKeeperEmail = email, + StoreKeeperPassword = password, + StoreKeeperLogin = email, + StoreKeeperPhone = phone + }); + + Response.Redirect("Enter"); + } + [HttpGet] + public void Logout() + { + if (APIStoreKeeper.Storekeeper == null) + { + throw new Exception(" !"); + } + + APIStoreKeeper.Storekeeper = null; + Response.Redirect("Enter"); + } + + [HttpGet] + public IActionResult Reports() + { + if (APIStoreKeeper.Storekeeper == null) + { + throw new Exception(" !"); + } + var data = _reportLogic.GetServices(new ReportServiceBindingModel()); + + return View(data); + } + + [HttpPost] + public async Task CreateReportWord(List cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment) + { + // + var folderName = "C:\\"; + var fileName = $" {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.docx"; + var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName); + + _reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel + { + FileName = filePath, + DateFrom = dateFrom, + DateTo = dateTo + }); + + // + var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath); + return File(fileBytes, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", fileName); + } + + [HttpPost] + public async Task CreateReportExcel(List cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment) + { + // + var folderName = "C:\\"; + var fileName = $" {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx"; + var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName); + + _reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel + { + FileName = filePath, + DateFrom = dateFrom, + DateTo = dateTo + }); + + // + var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath); + return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); + } + + [HttpPost] + public async Task CreateReportPdf(DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment) + { + // + var folderName = "C:\\"; + var fileName = $" {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.pdf"; + var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName); + + _reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel + { + FileName = filePath, + StorekeeperId = APIStoreKeeper.Storekeeper.Id + }); + + // + var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath); + return File(fileBytes, "application/pdf", fileName); + } + + [HttpPost] + public async Task SendReport(IFormFile fileUpload, [FromServices] IWebHostEnvironment hostingEnvironment) + { + if (APIStoreKeeper.Storekeeper == null) + { + throw new Exception(" !"); + } + + if (fileUpload == null || fileUpload.Length <= 0) + { + throw new Exception(" !"); + } + + // + var uploadPath = Path.Combine(hostingEnvironment.ContentRootPath, "C:\\"); + var fileName = Path.GetFileName(fileUpload.FileName); + var fullPath = Path.Combine(uploadPath, fileName); + + using (var fileStream = new FileStream(fullPath, FileMode.Create)) + { + await fileUpload.CopyToAsync(fileStream); + } + + _mailLogic.MailSendAsync(new MailSendInfoBindingModel + { + MailAddress = APIStoreKeeper.Storekeeper.StoreKeeperEmail, + Subject = $"{fileName.Split('.')[0]}", + Text = $" {DateTime.Now}", + Path = fullPath + }); + + return RedirectToAction("Reports", "Home"); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() @@ -29,4 +266,4 @@ namespace StoreKeeperWebApp.Controllers return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } -} +} \ No newline at end of file diff --git a/BeautyStudio/StoreKeeperWebApp/StoreKeeperWebApp.csproj b/BeautyStudio/StoreKeeperWebApp/StoreKeeperWebApp.csproj index 901abdd..1799b73 100644 --- a/BeautyStudio/StoreKeeperWebApp/StoreKeeperWebApp.csproj +++ b/BeautyStudio/StoreKeeperWebApp/StoreKeeperWebApp.csproj @@ -6,6 +6,12 @@ enable + + + + + + diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Shared/UpdateLaborCosts.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Shared/UpdateLaborCosts.cshtml new file mode 100644 index 0000000..605c2ce --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/Views/Shared/UpdateLaborCosts.cshtml @@ -0,0 +1,29 @@ +@using BeautyStudioContracts.ViewModels + +@model LaborCostViewModel + +@{ + ViewData["Title"] = "Редактирование трудозатраты"; +} + +
+

Редактирование трудозатрат

+
+ +
+
+
Потрачено времени (часов):
+
+
+ +
+
Сложность:
+
+
+ + +
+
+
+
+
diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml index 547adf4..a43f47b 100644 --- a/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml +++ b/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml @@ -6,7 +6,7 @@ @ViewData["Title"] - StoreKeeperApp - +
@@ -29,13 +29,13 @@ Авторизация diff --git a/BeautyStudio/StoreKeeperWebApp/appsettings.json b/BeautyStudio/StoreKeeperWebApp/appsettings.json index 10f68b8..4702e80 100644 --- a/BeautyStudio/StoreKeeperWebApp/appsettings.json +++ b/BeautyStudio/StoreKeeperWebApp/appsettings.json @@ -5,5 +5,11 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "SmtpClientHost": "smtp.gmail.com", + "SmtpClientPort": "587", + "PopHost": "pop.gmail.com", + "PopPort": "995", + "MailLogin": "rpplabs724@gmail.com", + "MailPassword": "tdqp zkqz avzv yebn" }