diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj b/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj
index 3ef7d76..efe0b63 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj
+++ b/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj
@@ -12,7 +12,8 @@
-
+
+
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs
index 954af34..fb203b3 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs
@@ -94,23 +94,6 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
{
return;
}
- if (model.TimeSpent <= 0)
- {
- throw new ArgumentNullException("Количество часов должно быть больше 0", nameof(model.TimeSpent));
- }
- if (string.IsNullOrEmpty(model.Difficulty))
- {
- throw new ArgumentNullException("Не указана сложность трудозатраты", nameof(model.Difficulty));
- }
- var element = _laborCostsStorage.GetElement(new LaborCostSearchModel
- {
- TimeSpent = model.TimeSpent,
- Difficulty = model.Difficulty,
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Такая трудозатрата уже уже есть");
- }
_logger.LogInformation("LaborCost. TimeSpent: {TimeSpent}. Difficulty: {Difficulty}. Id: {Id}",
model.TimeSpent, model.Difficulty, model.Id);
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs
deleted file mode 100644
index 9b76b52..0000000
--- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/MessageInfoLogic.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-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 487c02f..639d526 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -1,10 +1,8 @@
-using BeautyStudioBusinessLogic.MailWorker;
-using BeautyStudioContracts.BindingModels;
+using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
-using BeautyStudioDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@@ -14,167 +12,95 @@ using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogic
{
- public class OrderLogic : IOrderLogic
- {
- private readonly ILogger _logger;
- private readonly IOrderStorage _orderStorage;
- private readonly AbstractMailWorker _mailWorker;
- private readonly IStoreKeeperLogic _clientLogic;
- public OrderLogic(ILogger logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IStoreKeeperLogic clientLogic)
- {
- _logger = logger;
- _orderStorage = orderStorage;
- _mailWorker = mailWorker;
- _clientLogic = clientLogic;
- }
- public OrderViewModel? ReadElement(OrderSearchModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- _logger.LogInformation("ReadElement. DateFrom:{DateFrom}. DateTo:{DateTo}. Id:{Id}", model.DateCreate, model.DateComplete, model.Id);
- var element = _orderStorage.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(OrderSearchModel? model)
- {
- _logger.LogInformation("ReadList. Id: {Id}", model?.Id);
- var list = model == null ? _orderStorage.GetFullList() : _orderStorage.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(OrderBindingModel model)
- {
- CheckModel(model);
- model.Status = OrderStatus.Принято;
- if (_orderStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
- }
- public bool Update(OrderBindingModel model)
- {
- CheckModel(model, false);
- var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
- if (order == null)
- {
- throw new ArgumentNullException(nameof(order));
- }
- if (_orderStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- public bool Delete(OrderBindingModel model)
- {
- CheckModel(model, false);
- _logger.LogInformation("Delete. Id:{Id}", model.Id);
- if (_orderStorage.Delete(model) == null)
- {
- _logger.LogWarning("Delete order operation failed");
- return false;
- }
- return true;
- }
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. OrderId:Id:{ Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
- private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
- {
- var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
- if (viewModel == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (viewModel.Status + 1 != newStatus)
- {
- _logger.LogWarning("Change status operation failed");
- throw new InvalidOperationException();
- }
- model.Status = newStatus;
- if (model.Status == OrderStatus.Выполнено)
- {
- model.DateComplete = DateTime.Now;
- }
- else
- {
- model.DateComplete = viewModel.DateComplete;
- }
- CheckModel(model, false);
- var result = _orderStorage.Update(model);
- if (result == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- //Отсылка письма при изменении статуса
- SendOrderStatusMail(result.StoreKeeperId, $"Изменен статус заказа #{result.Id}", $"Заказ #{model.Id} изменен статус на {result.Status}");
- return true;
- }
- public bool TakeOrderInWork(OrderBindingModel model)
- {
- return StatusUpdate(model, OrderStatus.Выполняется);
- }
- public bool FinishOrder(OrderBindingModel model)
- {
- model.DateComplete = DateTime.Now;
- return StatusUpdate(model, OrderStatus.Выполнено);
- }
- public bool DeliveryOrder(OrderBindingModel model)
- {
+ public OrderViewModel? ReadElement(OrderSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. OrderId:Id:{ Id}", model.Id);
+ var element = _orderStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
- return StatusUpdate(model, OrderStatus.Выдан);
- }
- private void CheckModel(OrderBindingModel model, bool withParams = true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (model.Sum <= 0)
- {
- throw new ArgumentNullException("Стоимость должна быть больше 0", nameof(model.Sum));
- }
- _logger.LogInformation("Order. Id: {Id}. Sum: {Sum}.", model.Id, model.Sum);
- var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
- if (element != null && element.Id == model.Id)
- {
- throw new InvalidOperationException("Заказ с таким номером уже есть");
- }
- }
- private bool SendOrderStatusMail(int clientId, string subject, string text)
- {
- var client = _clientLogic.ReadElement(new() { Id = clientId });
- if (client == null)
- {
- return false;
- }
- _mailWorker.MailSendAsync(new()
- {
- MailAddress = client.StoreKeeperEmail,
- Subject = subject,
- Text = text
- });
- return true;
- }
- }
+ public bool Create(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Update(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(OrderBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_orderStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if(model.Sum < 0)
+ {
+ throw new ArgumentOutOfRangeException("Сумма меньше нуля",nameof(model.Sum));
+ }
+ _logger.LogInformation("Order. Order:Id:{ Id}.Sum:{ Sum}", model.Id, model.Sum);
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs
deleted file mode 100644
index 83ebe62..0000000
--- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ReportLogic.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-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.ServiceCosmetics,
- Procedures = x.ServiceProcedures,
- ServicePrice = x.ServiceProcedures.Sum(kv => kv.Value.Item1.ProcedureCost) +
- x.ServiceCosmetics.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/StoreKeeperLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs
index 185a276..7a598a9 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StoreKeeperLogic.cs
@@ -56,8 +56,8 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
throw new ArgumentNullException(nameof(model));
}
- _logger.LogInformation("ReadElement. StoreKeeperLogin: {StoreKeeperLogin}. StoreKeeperEmail: {StoreKeeperEmail} Id: {Id}",
- model.StoreKeeperLogin, model.StoreKeeperEmail, model.Id);
+ _logger.LogInformation("ReadElement. StoreKeeperEmail: {StoreKeeperEmail} Id: {Id}",
+ model.StoreKeeperEmail, model.Id);
var element = _storeKeeperStorage.GetElement(model);
@@ -74,8 +74,8 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
public List? ReadList(StoreKeeperSearchModel? model)
{
- _logger.LogInformation("ReadElement. StoreKeeperLogin: {StoreKeeperLogin}. StoreKeeperEmail: {StoreKeeperEmail} Id: {Id}",
- model?.StoreKeeperLogin, model?.StoreKeeperEmail, model?.Id);
+ _logger.LogInformation("ReadElement. StoreKeeperEmail: {StoreKeeperEmail} Id: {Id}",
+ model?.StoreKeeperEmail, model?.Id);
var list = model == null ? _storeKeeperStorage.GetFullList() : _storeKeeperStorage.GetFilteredList(model);
@@ -114,7 +114,7 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
}
if (string.IsNullOrEmpty(model.StoreKeeperFIO))
{
- throw new ArgumentNullException("Нет имени кладовщика", nameof(model.StoreKeeperLogin));
+ throw new ArgumentNullException("Нет имени кладовщика", nameof(model.StoreKeeperFIO));
}
if (string.IsNullOrEmpty(model.StoreKeeperLogin))
{
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
index 796beab..2d00a29 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -29,9 +29,28 @@ namespace BeautyStudioBusinessLogic.OfficePackage
CellToName = "C1"
});
- uint rowIndex = 2;
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = 2,
+ Text = "Косметика",
+ StyleInfo = ExcelStyleInfoType.Title
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "B",
+ RowIndex = 2,
+ Text = "Процедуры",
+ StyleInfo = ExcelStyleInfoType.Title
+ });
- foreach (var pc in info.CosmeticProcedures)
+ MergeCells(new ExcelMergeParameters
+ {
+ CellFromName = "B2",
+ CellToName = ColumnLetter(info.maxleng + 1) + "2"
+ });
+ uint rowIndex = 3;
+ foreach (var pc in info.cosmeticProceduresReport)
{
InsertCellInWorksheet(new ExcelCellParameters
{
@@ -40,22 +59,41 @@ namespace BeautyStudioBusinessLogic.OfficePackage
Text = pc.CosmeticName,
StyleInfo = ExcelStyleInfoType.Text
});
- rowIndex++;
- foreach (var procedure in pc.Procedures)
+ int place = 2;
+ foreach (var proc in pc.Procedures)
{
InsertCellInWorksheet(new ExcelCellParameters
{
- ColumnName = "B",
+ ColumnName = ColumnLetter(place),
RowIndex = rowIndex,
- Text = procedure,
+ Text = proc,
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
+
+ place++;
}
rowIndex++;
}
+
SaveExcel(info);
}
+ private static string ColumnLetter(int columnIndex)
+ {
+ int dividend = columnIndex;
+ string columnName = String.Empty;
+ int modulo;
+
+ while (dividend > 0)
+ {
+ modulo = (dividend - 1) % 26;
+ columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
+ dividend = (dividend - modulo) / 26;
+ }
+
+ return columnName;
+ }
+
//Создание эксель файла
protected abstract void CreateExcel(ExcelInfo info);
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
index 668e6c3..a8cecb3 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
@@ -35,8 +35,8 @@ namespace BeautyStudioBusinessLogic.OfficePackage
Style = "Normal"
});
- // Создаем таблицу с тремя колонками
- CreateTable(new List { "7cm", "4cm", "4cm" });
+ // Создаем таблицу с двумя колонками
+ CreateTable(new List { "5cm", "10cm" });
// Создаем заголовок таблицы
CreateRow(new PdfRowParameters
@@ -47,43 +47,40 @@ namespace BeautyStudioBusinessLogic.OfficePackage
});
// Записываем основную информацию
- foreach (var view in info.Services)
+ foreach (var report in info.Services)
{
CreateRow(new PdfRowParameters
{
- Texts = new List { view.ServiceName, "", "" },
+ Texts = new List { "Номер услуги", "Заказ" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { report.Id.ToString(), "" },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
-
- // Конвертируем из HashSet в List, чтобы можно было обращаться по индексу
- List cosmetics = new List();
- foreach (var item in view.Cosmetics)
- {
- var cosmeticModel = item.Value.Item1;
- cosmetics.Add(cosmeticModel.CosmeticName);
- }
- List procedures = new List();
- foreach (var item in view.Procedures)
- {
- var procedureModel = item.Value.Item1;
- procedures.Add(procedureModel.ProcedureName);
- }
-
- // Записываем названия лекарств во 2 колонку
- // и названия лекарств в 3 колонку
- int maxLength = Math.Max(cosmetics.Count, procedures.Count);
- for (int i = 0; i < maxLength; i++)
- {
- string cosmetic = (i < cosmetics.Count) ? cosmetics[i] : "";
- string procedure = (i < procedures.Count) ? procedures[i] : "";
+ foreach (var product in report.Orders)
CreateRow(new PdfRowParameters
{
- Texts = new List { "", procedure, cosmetic },
+ Texts = new List { "", product },
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Left
+ });
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "", "Трудозатраты" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ foreach (var production in report.LaborCosts)
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "", production },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
- }
}
// Сохраняем файл
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs
index 82bed17..873ed4b 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/AbstractSaveToWord.cs
@@ -15,18 +15,9 @@ namespace BeautyStudioBusinessLogic.OfficePackage
CreateWord(info);
CreateParagraph(new WordParagraph
{
- Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties
- { Bold = true, Size = "24", }) },
- TextProperties = new WordTextProperties
+ Texts = new List<(string, WordTextProperties)>
{
- Size = "24",
- JustificationType = WordJustificationType.Center
- }
- });
- CreateParagraph(new WordParagraph
- {
- Texts = new List<(string, WordTextProperties)> {
- ("Косметика" +" - " + "Процедура", new WordTextProperties { Size = "24", Bold = true, }),
+ (info.Title, new WordTextProperties { Bold = true, Size = "24", })
},
TextProperties = new WordTextProperties
{
@@ -34,31 +25,23 @@ namespace BeautyStudioBusinessLogic.OfficePackage
JustificationType = WordJustificationType.Both
}
});
- int i = 1;
- foreach (var cp in info.CosmeticProcedures)
- {
- foreach (var procedure in cp.Procedures)
- {
- CreateParagraph(new WordParagraph
- {
- Texts = new List<(string, WordTextProperties)> {
- (i + ". " + cp.CosmeticName + " - " + procedure, new WordTextProperties { Size = "24", Bold = false, }),
- },
- TextProperties = new WordTextProperties
- {
- Size = "24",
- JustificationType = WordJustificationType.Both
- }
- });
- }
- i++;
- }
+ foreach (var report in info.cosmeticProceduresReport)
+ {
+ CreateNumberedParagraph(1, 0, report.CosmeticName);
+ foreach (var workshop in report.Procedures)
+ {
+ CreateNumberedParagraph(1, 1, workshop);
+ }
+
+ }
SaveWord(info);
}
//Создание док-файла
protected abstract void CreateWord(WordInfo info);
//Создание абзаца с текстом
protected abstract void CreateParagraph(WordParagraph paragraph);
+ //Создание абзаца с нумерованной маркировкой текста
+ protected abstract void CreateNumberedParagraph(int numId, int ilvl, string text);
//Сохранение файла
protected abstract void SaveWord(WordInfo info);
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
index e0c3255..fedaf22 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
@@ -9,9 +9,9 @@ namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfo
{
- public string FileName { get; set; } = string.Empty;
+ public MemoryStream memoryStream { get; set; } = new MemoryStream();
public string Title { get; set; } = string.Empty;
- public List CosmeticProcedures { get; set; } = new();
- public List ProcedureCosmetics { get; set; } = new();
+ public List cosmeticProceduresReport { get; set; } = new();
+ public int maxleng { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
index 76dada7..152ee12 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
@@ -9,11 +9,10 @@ namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
{
- public string FileName { get; set; } = string.Empty;
+ public MemoryStream FileName { get; set; } = new();
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
- public List Orders { get; set; } = new();
public List Services { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
index 4dce0ad..2d2e5ed 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
@@ -9,9 +9,8 @@ namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class WordInfo
{
- public string FileName { get; set; } = string.Empty;
+ public MemoryStream memoryStream { get; set; } = new MemoryStream();
public string Title { get; set; } = string.Empty;
- public List CosmeticProcedures { get; set; } = new();
- public List ProcedureCosmetics { get; set; } = new();
+ public List cosmeticProceduresReport { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
index 48d5210..2e083ca 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
@@ -13,303 +13,276 @@ using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.OfficePackage.Implements
{
- public class SaveToExcel : AbstractSaveToExcel
- {
- 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 };
+ public class SaveToExcel : AbstractSaveToExcel
+ {
+ private SpreadsheetDocument? _spreadsheetDocument;
- 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.TextWithBorder => 1U,
- ExcelStyleInfoType.Text => 0U,
- _ => 0U,
- };
- }
- protected override void CreateExcel(ExcelInfo info)
- {
- string directoryPath = @"C:\reports\";
- if (!Directory.Exists(directoryPath))
+ 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
{
- Directory.CreateDirectory(directoryPath);
+ ExcelStyleInfoType.Title => 2U,
+ ExcelStyleInfoType.TextWithBorder => 1U,
+ ExcelStyleInfoType.Text => 0U,
+ _ => 0U,
+ };
+ }
+
+ protected override void CreateExcel(ExcelInfo info)
+ {
+ _spreadsheetDocument = SpreadsheetDocument.Create(info.memoryStream, SpreadsheetDocumentType.Workbook);
+ // Создаем книгу (в ней хранятся листы)
+ var workbookpart = _spreadsheetDocument.AddWorkbookPart();
+ workbookpart.Workbook = new Workbook();
+
+ CreateStyles(workbookpart);
+
+ // Получаем/создаем хранилище текстов для книги
+ _shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType().Any()
+ ? _spreadsheetDocument.WorkbookPart.GetPartsOfType().First()
+ : _spreadsheetDocument.WorkbookPart.AddNewPart();
+
+ // Создаем SharedStringTable, если его нет
+ if (_shareStringPart.SharedStringTable == null)
+ {
+ _shareStringPart.SharedStringTable = new SharedStringTable();
}
- _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 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;
- }
+ // Добавляем лист в книгу
+ var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
+ var sheet = new Sheet()
+ {
+ Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
+ SheetId = 1,
+ Name = "Лист"
+ };
+ sheets.Append(sheet);
- 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);
- }
+ _worksheet = worksheetPart.Worksheet;
+ }
+ protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
+ {
+ if (_worksheet == null || _shareStringPart == null)
+ {
+ return;
+ }
+ var sheetData = _worksheet.GetFirstChild();
+ if (sheetData == null)
+ {
+ return;
+ }
- 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
- {
+ // Ищем строку, либо добавляем ее
+ 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? 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;
- }
+ // Ищем нужную ячейку
+ 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;
+ }
+ }
- _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(ExcelInfo info)
- {
- if (_spreadsheetDocument == null)
- {
- return;
- }
- _spreadsheetDocument.WorkbookPart!.Workbook.Save();
- _spreadsheetDocument.Dispose();
- }
+ 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(ExcelInfo info)
+ {
+ if (_spreadsheetDocument == null)
+ {
+ return;
+ }
+ _spreadsheetDocument.WorkbookPart!.Workbook.Save();
+ _spreadsheetDocument.Dispose();
+ }
+
+ }
}
\ No newline at end of file
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
index 99677c2..978c327 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
@@ -15,10 +15,12 @@ namespace BeautyStudioBusinessLogic.OfficePackage.Implements
public class SaveToPdf : AbstractSaveToPdf
{
private Document? _document;
+
private Section? _section;
+
private Table? _table;
- private static ParagraphAlignment
- GetParagraphAlignment(PdfParagraphAlignmentType type)
+
+ private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
@@ -29,26 +31,28 @@ namespace BeautyStudioBusinessLogic.OfficePackage.Implements
};
}
+ ///
/// Создание стилей для документа
+ ///
+ ///
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 CreatePdf(PdfInfo info)
{
- string directoryPath = @"C:\reports\";
- if (!Directory.Exists(directoryPath))
- {
- Directory.CreateDirectory(directoryPath);
- }
_document = new Document();
DefineStyles(_document);
+
_section = _document.AddSection();
}
+
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
@@ -60,6 +64,7 @@ namespace BeautyStudioBusinessLogic.OfficePackage.Implements
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
+
protected override void CreateTable(List columns)
{
if (_document == null)
@@ -67,11 +72,13 @@ namespace BeautyStudioBusinessLogic.OfficePackage.Implements
return;
}
_table = _document.LastSection.AddTable();
+
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
+
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
@@ -82,19 +89,24 @@ namespace BeautyStudioBusinessLogic.OfficePackage.Implements
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 SavePdf(PdfInfo info)
{
var renderer = new PdfDocumentRenderer(true)
diff --git a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs
index f9ea149..1971d3c 100644
--- a/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs
+++ b/BeautyStudio/BeautyStudioBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -15,115 +15,128 @@ using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
namespace BeautyStudioBusinessLogic.OfficePackage.Implements
{
- public class SaveToWord : AbstractSaveToWord
- {
- private WordprocessingDocument? _wordDocument;
- private Body? _docBody;
+ public class SaveToWord : AbstractSaveToWord
+ {
+ private WordprocessingDocument? _wordDocument;
- 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();
+ private Body? _docBody;
- 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 CreateWord(WordInfo info)
- {
- string directoryPath = @"C:\reports\";
- if (!Directory.Exists(directoryPath))
+ private static JustificationValues GetJustificationValues(WordJustificationType type)
+ {
+ return type switch
{
- Directory.CreateDirectory(directoryPath);
+ 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;
}
- _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
- MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
- mainPart.Document = new Document();
- _docBody = mainPart.Document.AppendChild(new Body());
- }
- protected override void CreateParagraph(WordParagraph paragraph)
- {
- if (_docBody == null || paragraph == null)
- {
- return;
- }
- var docParagraph = new Paragraph();
- docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
+ var properties = new ParagraphProperties();
- foreach (var run in paragraph.Texts)
- {
- var docRun = new Run();
+ properties.AppendChild(new Justification()
+ {
+ Val = GetJustificationValues(paragraphProperties.JustificationType)
+ });
- var properties = new RunProperties();
- properties.AppendChild(new FontSize { Val = run.Item2.Size });
- if (run.Item2.Bold)
- {
- properties.AppendChild(new Bold());
- }
- docRun.AppendChild(properties);
+ properties.AppendChild(new SpacingBetweenLines
+ {
+ LineRule = LineSpacingRuleValues.Auto
+ });
- docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
+ properties.AppendChild(new Indentation());
- docParagraph.AppendChild(docRun);
- }
+ var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
+ if (!string.IsNullOrEmpty(paragraphProperties.Size))
+ {
+ paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
+ }
+ properties.AppendChild(paragraphMarkRunProperties);
- _docBody.AppendChild(docParagraph);
- }
- protected override void SaveWord(WordInfo info)
- {
- if (_docBody == null || _wordDocument == null)
- {
- return;
- }
- _docBody.AppendChild(CreateSectionProperties());
+ return properties;
+ }
- _wordDocument.MainDocumentPart!.Document.Save();
+ protected override void CreateWord(WordInfo info)
+ {
+ _wordDocument = WordprocessingDocument.Create(info.memoryStream, WordprocessingDocumentType.Document);
+ MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
+ mainPart.Document = new Document();
+ _docBody = mainPart.Document.AppendChild(new Body());
+ }
- _wordDocument.Dispose();
- }
- }
+ 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 CreateNumberedParagraph(int numId, int ilvl, string text)
+ {
+ Paragraph paragraph = new Paragraph(
+ new ParagraphProperties(
+ new NumberingProperties(
+ new NumberingLevelReference() { Val = ilvl },
+ new NumberingId() { Val = numId })),
+ new Run(new Text(text)));
+
+ _docBody!.Append(paragraph);
+ }
+
+ protected override void SaveWord(WordInfo info)
+ {
+ if (_docBody == null || _wordDocument == null)
+ {
+ return;
+ }
+ _docBody.AppendChild(CreateSectionProperties());
+
+ _wordDocument.MainDocumentPart!.Document.Save();
+
+ _wordDocument.Dispose();
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs
index cdafdfa..6b3eca5 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs
@@ -13,8 +13,10 @@ namespace BeautyStudioContracts.BindingModels
public int Id { get; set; }
public string CosmeticName { get; set; } = string.Empty;
public double CosmeticPrice { get; set; }
+ public int? OrderId { get; set; }
public int LaborCostId { get; set; }
public int StoreKeeperId { get; set; }
- public Dictionary CosmeticProcedure { get; set; } = new();
+ public DateTime DateCreate { get; set; }
+ public Dictionary CosmeticServices { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs
index 57693c1..bc5a5cd 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs
@@ -1,4 +1,5 @@
-using BeautyStudioDataModels.Models;
+using BeautyStudioDataModels.Enums;
+using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,8 +11,8 @@ namespace BeautyStudioContracts.BindingModels
public class LaborCostBindingModel : ILaborCostModel
{
public int Id { get ; set; }
- public int TimeSpent { get; set; }
- public string Difficulty { get; set; } = string.Empty;
+ public TimeSpent TimeSpent { get; set; }
+ public Difficulties Difficulty { get; set; }
public int StoreKeeperId { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/MailSendInfoBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/MailSendInfoBindingModel.cs
index c8d3ef3..c36494a 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/MailSendInfoBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/MailSendInfoBindingModel.cs
@@ -11,6 +11,7 @@ namespace BeautyStudioContracts.BindingModels
public string MailAddress { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Text { get; set; } = string.Empty;
- public string Path { get; set; } = string.Empty;
- }
+ public byte[] Pdf { get; set; }
+ public string FileName { get; set; } = string.Empty;
+ }
}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs
deleted file mode 100644
index 5ded4b1..0000000
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/MessageInfoBindingModel.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using BeautyStudioDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.BindingModels
-{
- public class MessageInfoBindingModel : IMessageInfoModel
- {
- public string MessageId { get; set; } = string.Empty;
- public int? StorekeeperId { get; set; }
- public string SenderName { get; set; } = string.Empty;
- public string Subject { get; set; } = string.Empty;
- public string Body { get; set; } = string.Empty;
- public DateTime DateDelivery { get; set; }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs
index 479a3b0..0602b60 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs
@@ -1,25 +1,16 @@
-using BeautyStudioContracts.ViewModels;
-using BeautyStudioDataModels.Enums;
+using BeautyStudioDataModels.Enums;
using BeautyStudioDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BeautyStudioContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
- public double Sum { get; set; }
- public DateTime DateCreate { get; set; } = DateTime.Now;
- public DateTime? DateComplete { get; set; }
- public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ public string OrderName { get; set; } = string.Empty;
public int StoreKeeperId { get; set; }
-
- public Dictionary OrderServices { get; set; } = new();
- public Dictionary OrderCosmetics { get; set; } = new();
- public Dictionary OrderProcedures { get; set; } = new();
+ public DateTime PaymentDate { get; set; } = DateTime.Now;
+ public double Sum { get; set; }
+ public Dictionary OrderProcedures { get; set; } = new();
+ public Dictionary Cosmetics { get; set; } = new();
}
-}
+}
\ No newline at end of file
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs
index 04316f4..4a2759e 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs
@@ -3,6 +3,7 @@ using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -15,6 +16,6 @@ namespace BeautyStudioContracts.BindingModels
public double ProcedureCost { get; set; }
public string ProcedureDescription { get; set; } = string.Empty;
public int StoreKeeperId { get; set; }
- public Dictionary ProcedureCosmetics { get; set; } = new();
+ public Dictionary ProcedureServices { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs
deleted file mode 100644
index 90c5eb8..0000000
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/ReportServiceBindingModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-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/BindingModels/ServiceBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs
index 0ed868a..9622270 100644
--- a/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs
@@ -14,7 +14,7 @@ namespace BeautyStudioContracts.BindingModels
public string ServiceName { get; set; } = string.Empty;
public double ServicePrice { get; set; }
public int StoreKeeperId { get; set; }
- public Dictionary ServiceCosmetics { get; set; } = new();
- public Dictionary ServiceProcedures { get; set; } = new();
+ public DateTime DateCreate { get; set; }
+ public Dictionary ServiceProcedures { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs
deleted file mode 100644
index bc16df2..0000000
--- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IMessageInfoLogic.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-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/IOrderLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs
index bb34e67..8df7b75 100644
--- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs
+++ b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs
@@ -1,20 +1,20 @@
-using System.Collections.Generic;
-using BeautyStudioContracts.BindingModels;
-using BeautyStudioContracts.ViewModels;
+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 IOrderLogic
- {
- List? ReadList(OrderSearchModel? model);
- OrderViewModel? ReadElement(OrderSearchModel model);
- bool Create(OrderBindingModel model);
- bool Delete(OrderBindingModel model);
- bool Update(OrderBindingModel model);
-
- bool TakeOrderInWork(OrderBindingModel model);
- bool FinishOrder(OrderBindingModel model);
- bool DeliveryOrder(OrderBindingModel model);
- }
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
+ bool Create(OrderBindingModel model);
+ bool Update(OrderBindingModel model);
+ bool Delete(OrderBindingModel model);
+ }
}
diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs
index 0559561..66aa737 100644
--- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs
+++ b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IReportLogic.cs
@@ -6,14 +6,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace BeautyStudioContracts.BusinessLogicContracts
+namespace BeautyStudioContracts.BusinessLogicsContracts
{
- public interface IReportLogic
- {
- List GetServices(ReportServiceBindingModel model);
- List GetCosmeticProcedures();
- void SaveCosmeticProceduresToExcelFile(ReportBindingModel model);
- void SaveCosmeticProceduresToWordFile(ReportBindingModel model);
- void SaveServicesToPdfFile(ReportServiceBindingModel model);
- }
-}
+ public interface IReportLogic
+ {
+ List GetBundligs(ReportBindingModel model);
+ List GetCars(ReportBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs
index f715d5f..f3819b9 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs
@@ -9,8 +9,9 @@ namespace BeautyStudioContracts.SearchModels
public class CosmeticSearchModel
{
public int? Id { get; set; }
- public string? CosmeticName { get; set; }
- public int? LaborCostId { get; set; }
+ public string CosmeticName { get; set; } = string.Empty;
+ public DateTime? DateCreate { get; set; }
+ public DateTime? DateComplete { get; set; }
public int? StoreKeeperId { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs
index 5bd7228..6b5c141 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs
@@ -9,8 +9,7 @@ namespace BeautyStudioContracts.SearchModels
public class LaborCostSearchModel
{
public int? Id { get; set; }
- public int? TimeSpent { get; set; }
- public string? Difficulty { get; set; }
public int? StoreKeeperId { get; set; }
+ public int? ServiceId { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs
deleted file mode 100644
index 50e0809..0000000
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/MessageInfoSearchModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-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/SearchModels/OrderSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs
index d17fb62..0735929 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs
@@ -1,4 +1,5 @@
using BeautyStudioDataModels.Enums;
+using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,17 +8,14 @@ using System.Threading.Tasks;
namespace BeautyStudioContracts.SearchModels
{
-
- public class OrderSearchModel
- {
- public int? Id { get; set; }
- public double? Sum { get; set; }
- public DateTime? DateCreate { get; set; }
- public DateTime? DateComplete { get; set; }
- public List? Statuses { get; set; }
- public List? CosmeticIds { get; set; }
- public List? ProcedureIds { get; set; }
- public List? ServiceIds { get; set; }
- public int? StoreKeeperId { get; set; }
- }
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ public int? ServiceId { get; set; }
+ public int? StoreKeeperId { get; set; }
+ public List Procedures { get; set; } = new();
+ public List Cosmetics { get; set; } = new();
+ public DateTime? DateCreate { get; set; }
+ public DateTime? DateComplete { get; set; }
+ }
}
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs
index d789b1d..d9d5a94 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs
@@ -9,9 +9,10 @@ namespace BeautyStudioContracts.SearchModels
public class ProcedureSearchModel
{
public int? Id { get; set; }
- public string? ProcedureName { get; set; }
- public string? ProcedureDescription { get; set; }
+ public string ProcedureName { get; set; } = string.Empty;
+ public string ProcedureDescription { get; set; } = string.Empty;
public int? StoreKeeperId { get; set; }
+ public int? ComseticId { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs
index f99d098..0468895 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs
@@ -9,9 +9,9 @@ namespace BeautyStudioContracts.SearchModels
public class ServiceSearchModel
{
public int? Id { get; set; }
- public string? ServiceName { get; set; }
+ public string? ServiceName { get; set; } = string.Empty;
public int? StoreKeeperId { get; set; }
- public List? CosmeticIds { get; set; }
- public List? ProcedureIds { get; set; }
+ public DateTime? DateCreate { get; set; }
+ public DateTime? DateComplete { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/StoreKeeperSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/StoreKeeperSearchModel.cs
index 5d0ceee..6ef729f 100644
--- a/BeautyStudio/BeautyStudioContracts/SearchModels/StoreKeeperSearchModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/SearchModels/StoreKeeperSearchModel.cs
@@ -9,8 +9,7 @@ namespace BeautyStudioContracts.SearchModels
public class StoreKeeperSearchModel
{
public int? Id { get; set; }
- public string? StoreKeeperFIO { get; set;}
- public string? StoreKeeperLogin { get; set;}
+ public string? StoreKeeperLogin { get; set; }
public string? StoreKeeperPassword { get; set;}
public string? StoreKeeperEmail { get; set;}
public string? StoreKeeperPhone { get; set;}
diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs
index fe30cdb..5fe7126 100644
--- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs
+++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs
@@ -17,6 +17,5 @@ namespace BeautyStudioContracts.StoragesContracts
CosmeticViewModel? Insert(CosmeticBindingModel model);
CosmeticViewModel? Update(CosmeticBindingModel model);
CosmeticViewModel? Delete(CosmeticBindingModel model);
- List GetCosmeticProcedures(CosmeticSearchModel model);
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs
deleted file mode 100644
index 16f7c57..0000000
--- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IMessageInfoStorage.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-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/StoragesContracts/IOrderStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IOrderStorage.cs
index 2eb6abc..83e404d 100644
--- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IOrderStorage.cs
+++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IOrderStorage.cs
@@ -9,13 +9,13 @@ using System.Threading.Tasks;
namespace BeautyStudioContracts.StoragesContracts
{
- public interface IOrderStorage
- {
- List GetFullList();
- List GetFilteredList(OrderSearchModel model);
- OrderViewModel? GetElement(OrderSearchModel model);
- OrderViewModel? Insert(OrderBindingModel model);
- OrderViewModel? Update(OrderBindingModel model);
- OrderViewModel? Delete(OrderBindingModel model);
- }
+ public interface IOrderStorage
+ {
+ List GetFullList();
+ List GetFilteredList(OrderSearchModel model);
+ OrderViewModel? GetElement(OrderSearchModel model);
+ OrderViewModel? Insert(OrderBindingModel model);
+ OrderViewModel? Update(OrderBindingModel model);
+ OrderViewModel? Delete(OrderBindingModel model);
+ }
}
diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs
index 0d11dd1..e345f10 100644
--- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs
+++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs
@@ -17,6 +17,5 @@ namespace BeautyStudioContracts.StoragesContracts
ProcedureViewModel? Insert(ProcedureBindingModel model);
ProcedureViewModel? Update(ProcedureBindingModel model);
ProcedureViewModel? Delete(ProcedureBindingModel model);
- List GetProcedureCosmetics(ProcedureSearchModel model);
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs
deleted file mode 100644
index 50d805a..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class CosmeticProcedureViewModel
- {
- public CosmeticViewModel Cosmetic { get; set; } = null!;
- public ProcedureViewModel Procedure { get; set; } = null!;
- public int Count { get; set; }
-
- public CosmeticProcedureViewModel() { }
-
- public CosmeticProcedureViewModel(CosmeticViewModel cosmetic, ProcedureViewModel procedure, int count)
- {
- Cosmetic = cosmetic;
- Procedure = procedure;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs
index d081cbb..853cdbe 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs
@@ -18,12 +18,13 @@ namespace BeautyStudioContracts.ViewModels
[DisplayName("Цена косметики")]
public double CosmeticPrice { get; set; }
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; }
+ public int? OrderId { get; set; }
public int LaborCostId { get; set; }
public int StoreKeeperId { get; set; }
- public string StoreKeeperName { get; set; } = string.Empty;
-
- public Dictionary CosmeticProcedure { get; set; } = new();
+ public Dictionary CosmeticServices { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs
index 55b6745..7ee42f6 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs
@@ -1,4 +1,5 @@
-using BeautyStudioDataModels.Models;
+using BeautyStudioDataModels.Enums;
+using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -12,10 +13,10 @@ namespace BeautyStudioContracts.ViewModels
{
public int Id { get; set; }
[DisplayName("Потрачено времени (часов)")]
- public int TimeSpent { get; set; }
+ public TimeSpent TimeSpent { get; set; }
[DisplayName("Сложность")]
- public string Difficulty { get; set; } = string.Empty;
+ public Difficulties Difficulty { get; set; }
public int StoreKeeperId { get; set; }
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs
deleted file mode 100644
index 72a41a7..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/MessageInfoViewModel.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-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/OrderCosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderCosmeticViewModel.cs
deleted file mode 100644
index 1141364..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderCosmeticViewModel.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class OrderCosmeticViewModel
- {
- public CosmeticViewModel Cosmetic { get; set; } = null!;
-
- public OrderCosmeticViewModel() { }
-
- public OrderCosmeticViewModel(CosmeticViewModel cosmetic)
- {
- Cosmetic = cosmetic;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs
deleted file mode 100644
index 2d9d772..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class OrderProcedureViewModel
- {
- public ProcedureViewModel Procedure { get; set; } = null!;
- public int Count { get; set; }
-
- public OrderProcedureViewModel() { }
-
- public OrderProcedureViewModel(ProcedureViewModel procedure, int count)
- {
- Procedure = procedure;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs
deleted file mode 100644
index 39c25db..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class OrderServiceViewModel
- {
- public ServiceViewModel Service { get; set; } = null!;
- public int Count { get; set; }
-
- public OrderServiceViewModel() { }
-
- public OrderServiceViewModel(ServiceViewModel service, int count)
- {
- Service = service;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs
index 3a64ea5..53fffb0 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs
@@ -12,30 +12,16 @@ namespace BeautyStudioContracts.ViewModels
public class OrderViewModel : IOrderModel
{
public int Id { get; set; }
- public int CosmeticId { get; set; }
-
- public int ServiceId { get; set; }
-
- [DisplayName("Именование услуги")]
- public string ServiceName { get; set; } = string.Empty;
-
- [DisplayName("Стоимость")]
- public double Sum { get; set; }
-
- [DisplayName("Статус")]
- public OrderStatus Status { get; set; }
-
- [DisplayName("Дата создания")]
- public DateTime DateCreate { get; set; }
-
- [DisplayName("Дата выполнения")]
- public DateTime? DateComplete { get; set; }
-
- [DisplayName("Клиент")]
public int StoreKeeperId { get; set; }
+ [DisplayName("Название заказа")]
+ public string OrderName { get; set; } = string.Empty;
- public Dictionary OrderServices { get; set; } = new();
- public Dictionary OrderCosmetics { get; set; } = new();
- public Dictionary OrderProcedures { get; set; } = new();
+ [DisplayName("Дата оплаты")]
+ public DateTime PaymentDate { get; set; }
+
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+ public Dictionary OrderProcedures { get; set; } = new();
+ public Dictionary Cosmetics { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureCosmeticsViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureCosmeticsViewModel.cs
deleted file mode 100644
index 87316ae..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureCosmeticsViewModel.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class ProcedureCosmeticsViewModel
- {
- public CosmeticViewModel Cosmetic { get; set; } = null!;
- public ProcedureViewModel Procedure { get; set; } = null!;
- public int Count { get; set; }
-
- public ProcedureCosmeticsViewModel() { }
-
- public ProcedureCosmeticsViewModel(CosmeticViewModel cosmetic, ProcedureViewModel procedure, int count)
- {
- Cosmetic = cosmetic;
- Procedure = procedure;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs
index bdabafc..5cb3678 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs
@@ -19,7 +19,6 @@ namespace BeautyStudioContracts.ViewModels
[DisplayName("Описание процедуры")]
public string ProcedureDescription { get; set; } = string.Empty;
public int StoreKeeperId { get; set; }
- public string StoreKeeperName { get; set; } = string.Empty;
- public Dictionary ProcedureCosmetics { get; set; } = new();
+ public Dictionary ProcedureServices { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticViewModel.cs
similarity index 78%
rename from BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs
rename to BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticViewModel.cs
index 82eff51..8a716e7 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticProceduresViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportCosmeticViewModel.cs
@@ -6,8 +6,9 @@ using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
- public class ReportCosmeticProceduresViewModel
+ public class ReportCosmeticViewModel
{
+ public int CosmeticID { get; set; }
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
deleted file mode 100644
index 47b050c..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportOrdersViewModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-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
deleted file mode 100644
index 6e0c24a..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportProcedureCosmeticsViewModel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-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
index 6f6e4e8..0840134 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ReportServicesViewModel.cs
@@ -11,10 +11,8 @@ 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; }
+ public List Orders { get; set; } = new();
+ public List LaborCosts { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs
deleted file mode 100644
index 63e1aaa..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class ServiceCosmeticViewModel
- {
- public CosmeticViewModel Cosmetic { get; set; } = null!;
- public ServiceViewModel Service { get; set; } = null!;
- public int Count { get; set; }
-
- public ServiceCosmeticViewModel() { }
-
- public ServiceCosmeticViewModel(CosmeticViewModel cosmetic, ServiceViewModel service, int count)
- {
- Cosmetic = cosmetic;
- Service = service;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs
deleted file mode 100644
index 8fa1a0c..0000000
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeautyStudioContracts.ViewModels
-{
- public class ServiceProcedureViewModel
- {
- public ProcedureViewModel Procedure { get; set; } = null!;
- public int Count { get; set; }
-
- public ServiceProcedureViewModel() { }
-
- public ServiceProcedureViewModel(ProcedureViewModel procedure, int count)
- {
- Procedure = procedure;
- Count = count;
- }
- }
-}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs
index ddf72ec..08fde4a 100644
--- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs
@@ -19,8 +19,10 @@ namespace BeautyStudioContracts.ViewModels
public double ServicePrice { get; set; }
[DisplayName("Сотрудник")]
public int StoreKeeperId { get; set; }
-
- public Dictionary ServiceCosmetics { get; set; } = new();
+
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; }
+
public Dictionary ServiceProcedures { get; set; } = new();
}
}
diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/StoreKeeprReportViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/StoreKeeprReportViewModel.cs
new file mode 100644
index 0000000..9a4c0b6
--- /dev/null
+++ b/BeautyStudio/BeautyStudioContracts/ViewModels/StoreKeeprReportViewModel.cs
@@ -0,0 +1,16 @@
+using BeautyStudioDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BeautyStudioContracts.ViewModels
+{
+ internal class StoreKeeperReportViewModel
+ {
+ public int? Id;
+ public Dictionary ProcedureCosmetics;
+ public int? Count;
+ }
+}
diff --git a/BeautyStudio/BeautyStudioDataModels/Enums/Difficulties.cs b/BeautyStudio/BeautyStudioDataModels/Enums/Difficulties.cs
new file mode 100644
index 0000000..460f9c2
--- /dev/null
+++ b/BeautyStudio/BeautyStudioDataModels/Enums/Difficulties.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BeautyStudioDataModels.Enums
+{
+ public enum Difficulties
+ {
+ Неизвестно = -1,
+ Легко = 0,
+ Средне = 1,
+ Тяжело = 2,
+ }
+}
diff --git a/BeautyStudio/BeautyStudioDataModels/Enums/TimeSpent.cs b/BeautyStudio/BeautyStudioDataModels/Enums/TimeSpent.cs
new file mode 100644
index 0000000..3b4e5bb
--- /dev/null
+++ b/BeautyStudio/BeautyStudioDataModels/Enums/TimeSpent.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BeautyStudioDataModels.Enums
+{
+ public enum TimeSpent
+ {
+ Неизвестно = -1,
+ Полчаса = 0,
+ Час = 1,
+ ПолтораЧаса = 2,
+ ДваЧаса = 3,
+ ТриЧаса = 4,
+ ПятьЧасов = 5,
+ }
+}
diff --git a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs
index 81247a2..801e73c 100644
--- a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs
+++ b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs
@@ -11,6 +11,7 @@ namespace BeautyStudioDataModels.Models
string CosmeticName { get; }
double CosmeticPrice { get; }
int LaborCostId { get; }
- Dictionary CosmeticProcedure { get; }
+ public DateTime DateCreate { get; set; }
+ Dictionary CosmeticServices { get; }
}
}
diff --git a/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs
index 8a9052f..b3c9e52 100644
--- a/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs
+++ b/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs
@@ -1,4 +1,5 @@
-using System;
+using BeautyStudioDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,8 +9,7 @@ namespace BeautyStudioDataModels.Models
{
public interface ILaborCostModel : IId
{
- int TimeSpent { get; }
- string Difficulty { get; }
- int StoreKeeperId { get; }
+ TimeSpent TimeSpent { get; }
+ Difficulties Difficulty { get; }
}
}
diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs
deleted file mode 100644
index a3907e1..0000000
--- a/BeautyStudio/BeautyStudioDataModels/Models/IMessageInfoModel.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-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 bb6f08d..425491c 100644
--- a/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs
+++ b/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs
@@ -1,22 +1,17 @@
-using System;
+using BeautyStudioDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using BeautyStudioDataModels.Enums;
namespace BeautyStudioDataModels.Models
{
- public interface IOrderModel : IId
- {
- double Sum { get; }
- DateTime DateCreate { get; }
- DateTime? DateComplete { get; }
- OrderStatus Status { get; }
- int StoreKeeperId { get; }
- Dictionary OrderCosmetics { get; } // список косметики "участвующей" в заказе
- Dictionary OrderProcedures { get; } // список процедур "участвующих" в заказе
- Dictionary OrderServices { get; } // список услуг "участвующих" в заказе
- }
-
+ public interface IOrderModel : IId
+ {
+ string OrderName { get; set; }
+ DateTime PaymentDate { get; set; }
+ double Sum { get; set; }
+ Dictionary OrderProcedures { get; }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs
index ec6a233..7d8c981 100644
--- a/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs
+++ b/BeautyStudio/BeautyStudioDataModels/Models/IProcedureModel.cs
@@ -11,7 +11,6 @@ namespace BeautyStudioDataModels.Models
string ProcedureName { get; }
double ProcedureCost { get; }
string ProcedureDescription { get; }
- int StoreKeeperId { get; }
- Dictionary ProcedureCosmetics { get; }
+ Dictionary ProcedureServices { get; }
}
}
diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs
index 208d90b..e498d81 100644
--- a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs
+++ b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs
@@ -11,8 +11,6 @@ namespace BeautyStudioDataModels.Models
{
string ServiceName { get; }
double ServicePrice { get; }
- int StoreKeeperId { get; set; }
- Dictionary ServiceCosmetics { get; }
- Dictionary ServiceProcedures { get; }
+ DateTime DateCreate { get; }
}
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs
index 5babffa..53837a2 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs
@@ -16,18 +16,13 @@ namespace BeautyStudioDatabaseImplement
}
public virtual DbSet Orders { set; get; }
- public virtual DbSet LaborCost { set; get; }
+ public virtual DbSet LaborCosts { set; get; }
public virtual DbSet Cosmetics { set; get; }
public virtual DbSet Services { set; get; }
public virtual DbSet Procedures { set; get; }
- public virtual DbSet ServiceCosmetics { set; get; }
- public virtual DbSet ServiceProcedures { set; get; }
- public virtual DbSet OrderCosmetics { set; get; }
- public virtual DbSet OrderServices { set; get; }
public virtual DbSet OrderProcedures { set; get; }
- public virtual DbSet CosmeticProcedures { set; get; }
- public virtual DbSet ProcedureCosmetics { set; get; }
+ public virtual DbSet CosmeticServices { set; get; }
+ public virtual DbSet ProcedureServices { set; get; }
public virtual DbSet StoreKeepers { set; get; }
- public virtual DbSet MessageInfos { set; get; }
}
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs
index 416402d..d94c526 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs
@@ -4,119 +4,129 @@ using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class CosmeticStorage : ICosmeticStorage
- {
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.Cosmetics
- .Include(x => x.StoreKeeper)
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- public List GetFilteredList(CosmeticSearchModel model)
- {
- using var context = new BeautyStudioDatabase();
- if (model.Id.HasValue)
- {
- return context.Cosmetics
- .Include(x => x.StoreKeeper)
- .Where(x => x.Id == model.Id)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- if (model.StoreKeeperId.HasValue)
- {
- return context.Cosmetics
- .Include(x => x.StoreKeeper)
- .Where(x => x.StoreKeeperId == model.StoreKeeperId)
- .Select(x => x.GetViewModel)
- .ToList();
- }
-
- return new();
- }
-
- public CosmeticViewModel? GetElement(CosmeticSearchModel model)
- {
- if (string.IsNullOrEmpty(model.CosmeticName) && !model.Id.HasValue)
- {
- return null;
- }
- using var context = new BeautyStudioDatabase();
- return context.Cosmetics
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .FirstOrDefault(x => (!string.IsNullOrEmpty(model.CosmeticName) && x.CosmeticName == model.CosmeticName) ||
- (model.Id.HasValue && x.Id == model.Id))
- ?.GetViewModel;
- }
-
- public CosmeticViewModel? Insert(CosmeticBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var newCosmetic = Cosmetic.Create(context, model);
- if (newCosmetic == null)
- {
- return null;
- }
-
- context.Cosmetics.Add(newCosmetic);
- context.SaveChanges();
- return newCosmetic.GetViewModel;
- }
-
- public CosmeticViewModel? Update(CosmeticBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Cosmetics
- .Include(x => x.LaborCost)
- .FirstOrDefault(x => x.Id.Equals(model.Id));
- if (element == null)
- {
- return null;
- }
-
- element.Update(context, model);
- context.SaveChanges();
- return element.GetViewModel;
- }
-
- public CosmeticViewModel? Delete(CosmeticBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Cosmetics
- .Include(x => x.LaborCost)
- .FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- context.Cosmetics.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
-
- public List GetCosmeticProcedures(CosmeticSearchModel model)
- {
- if (model == null)
- {
- return new();
- }
- using var context = new BeautyStudioDatabase();
- var procedures = context.CosmeticProcedures
- .Where(x => x.CosmeticId == model.Id)
- .Select(x => x.Procedure.GetViewModel)
- .ToList();
- return procedures;
- }
- }
+ public class CosmeticStorage : ICosmeticStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.Cosmetics
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(CosmeticSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (model.DateCreate.HasValue) // Для отчета списка
+ {
+ //будет применятся в ReportLogic
+ return context.Cosmetics
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Where(x => x.DateCreate <= model.DateComplete && x.DateCreate >= model.DateCreate)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ else if (model.StoreKeeperId.HasValue)
+ {
+ return context.Cosmetics
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+ public CosmeticViewModel? GetElement(CosmeticSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return context.Cosmetics
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public CosmeticViewModel? Insert(CosmeticBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var newCosm = Cosmetic.Create(context, model);
+ if (newCosm == null)
+ {
+ return null;
+ }
+ context.Cosmetics.Add(newCosm);
+ context.SaveChanges();
+ return context.Cosmetics
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .FirstOrDefault(x => x.Id == newCosm.Id)
+ ?.GetViewModel;
+ }
+ public CosmeticViewModel? Update(CosmeticBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var cosm = context.Cosmetics.FirstOrDefault(x => x.Id == model.Id);
+ if (cosm == null)
+ {
+ return null;
+ }
+ cosm.Update(model);
+ cosm.UpdateServices(context, model);
+ context.SaveChanges();
+ return context.Cosmetics
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public CosmeticViewModel? Delete(CosmeticBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var element = context.Cosmetics
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ var deletedElement = context.Cosmetics
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Include(x => x.LaborCost)
+ .Include(x => x.Order)
+ .Include(x => x.StoreKeeper)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ context.Cosmetics.Remove(element);
+ context.SaveChanges();
+ return deletedElement;
+ }
+ return null;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs
index 66568ba..a584577 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs
@@ -3,110 +3,90 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class LaborCostStorage : ILaborCostStorage
- {
- public LaborCostViewModel? Delete(LaborCostBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
-
- var element = context.LaborCost.FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- var deletedElement = context.LaborCost
- .FirstOrDefault(x => x.Id == model.Id)
- ?.GetViewModel;
- context.LaborCost.Remove(element);
- context.SaveChanges();
- return deletedElement;
- }
- return null;
- }
-
- public LaborCostViewModel? GetElement(LaborCostSearchModel model)
- {
- if (!model.Id.HasValue)
- {
- using var context = new BeautyStudioDatabase();
- return context.LaborCost
- .FirstOrDefault(x => x.TimeSpent == model.TimeSpent
- && x.Difficulty == model.Difficulty
- && x.StoreKeeperId == model.StoreKeeperId)
- ?.GetViewModel;
- }
- else
- {
- using var context = new BeautyStudioDatabase();
- return context.LaborCost
- .FirstOrDefault(x => x.Id == model.Id)
- ?.GetViewModel;
- }
- }
-
- public List GetFilteredList(LaborCostSearchModel model)
- {
- using var context = new BeautyStudioDatabase();
- if (model.Id.HasValue)
- {
- return context.LaborCost
- .Where(x => x.Id == model.Id)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- if (model.StoreKeeperId.HasValue)
- {
- return context.LaborCost
- .Where(x => x.StoreKeeperId == model.StoreKeeperId)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- return new();
- }
-
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.LaborCost
- .Select(x => x.GetViewModel)
- .ToList();
- }
-
- public LaborCostViewModel? Insert(LaborCostBindingModel model)
- {
- var newLaborCost = LaborCost.Create(model);
- if (newLaborCost == null)
- {
- return null;
- }
- using var context = new BeautyStudioDatabase();
- context.LaborCost.Add(newLaborCost);
- context.SaveChanges();
- return context.LaborCost
- .FirstOrDefault(x => x.Id == newLaborCost.Id)
- ?.GetViewModel;
- }
-
- public LaborCostViewModel? Update(LaborCostBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var order = context.LaborCost.FirstOrDefault(x => x.Id == model.Id);
- if (order == null)
- {
- return null;
- }
- order.Update(model);
- context.SaveChanges();
- return context.LaborCost
- .FirstOrDefault(x => x.Id == model.Id)
- ?.GetViewModel;
- }
- }
+ public class LaborCostStorage : ILaborCostStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.LaborCosts
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(LaborCostSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (model.StoreKeeperId.HasValue)
+ {
+ return context.LaborCosts
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+ public LaborCostViewModel? GetElement(LaborCostSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return context.LaborCosts
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public LaborCostViewModel? Insert(LaborCostBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var newFeature = LaborCost.Create(model);
+ if (newFeature == null)
+ {
+ return null;
+ }
+ context.LaborCosts.Add(newFeature);
+ context.SaveChanges();
+ return context.LaborCosts
+ .FirstOrDefault(x => x.Id == newFeature.Id)
+ ?.GetViewModel;
+ }
+ public LaborCostViewModel? Update(LaborCostBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var order = context.LaborCosts.FirstOrDefault(x => x.Id == model.Id);
+ if (order == null)
+ {
+ return null;
+ }
+ order.Update(model);
+ context.SaveChanges();
+ return context.LaborCosts
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public LaborCostViewModel? Delete(LaborCostBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var element = context.LaborCosts
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ var deletedElement = context.LaborCosts
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ context.LaborCosts.Remove(element);
+ context.SaveChanges();
+ return deletedElement;
+ }
+ return null;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs
deleted file mode 100644
index 285a194..0000000
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/MessageInfoStorage.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-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/Implements/OrderStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs
index 3dc7fe6..404eb8e 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs
@@ -12,132 +12,150 @@ using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class OrderStorage : IOrderStorage
- {
- public OrderViewModel? Delete(OrderBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Orders
- .Include(x => x.Services)
- .Include(x => x.Procedures)
- .Include(x => x.Cosmetics)
- .FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- context.Orders.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
+ public class OrderStorage : IOrderStorage
+ {
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var element = context.Orders
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ var deletedElement = context.Orders
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ context.Orders.Remove(element);
+ context.SaveChanges();
+ return deletedElement;
+ }
+ return null;
+ }
- public OrderViewModel? GetElement(OrderSearchModel model)
- {
- if (!model.Id.HasValue)
- {
- return null;
- }
- using var context = new BeautyStudioDatabase();
- return context.Orders
- .Include(x => x.Services)
- .ThenInclude(x => x.Service)
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
- ?.GetViewModel;
- }
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return context.Orders
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
- public List GetFilteredList(OrderSearchModel model)
- {
- if (model == null)
- {
- return new();
- }
- using var context = new BeautyStudioDatabase();
- if (model.Id.HasValue)
- {
- return context.Orders
- .Include(x => x.Services)
- .ThenInclude(x => x.Service)
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Where(x => x.Id == model.Id)
- .ToList()
- .Select(x => x.GetViewModel)
- .ToList();
- }
- if (model.StoreKeeperId.HasValue)
- {
- return context.Orders
- .Include(x => x.Services)
- .ThenInclude(x => x.Service)
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Where(x => x.StoreKeeperId == model.StoreKeeperId)
- .ToList()
- .Select(x => x.GetViewModel)
- .ToList();
- }
- return new();
- }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.Orders
- .Include(x => x.Services)
- .ThenInclude(x => x.Service)
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Select(x => x.GetViewModel)
- .ToList();
- }
+ if (model.DateCreate.HasValue && model.DateComplete.HasValue)
+ {
+ return context.Orders
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .ThenInclude(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Where(x => x.PaymentDate >= model.DateCreate && x.PaymentDate <= model.DateComplete)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ else if (model.Procedures.Count > 0)
+ {
+ return context.Orders
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .Where(x => x.OrderProcedures.Any(p => model.Procedures.Any(procedure => p.Value == procedure)))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ else if (model.Cosmetics.Count > 0)
+ {
+ return context.Orders
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .Where(x => x.Cosmetics.Any(car => model.Cosmetics.Any(searchCosm => car.Id == searchCosm.Id)))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ else if (model.StoreKeeperId.HasValue)
+ {
+ return context.Orders
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
- public OrderViewModel? Insert(OrderBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var newOrder = Order.Create(context, model);
- if (newOrder == null)
- {
- return null;
- }
- context.Orders.Add(newOrder);
- context.SaveChanges();
- return newOrder.GetViewModel;
- }
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.Orders
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
- public OrderViewModel? Update(OrderBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- using var transaction = context.Database.BeginTransaction();
- try
- {
- var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
- if (order == null)
- {
- return null;
- }
- order.Update(model);
- context.SaveChanges();
- order.UpdateCosmetics(context, model);
- order.UpdateProcedures(context, model);
- order.UpdateServices(context, model);
- transaction.Commit();
- return order.GetViewModel;
- }
- catch
- {
- transaction.Rollback();
- throw;
- }
- }
- }
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var newOrder = Order.Create(context, model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ context.Orders.Add(newOrder);
+ context.SaveChanges();
+ return context.Orders
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .FirstOrDefault(x => x.Id == newOrder.Id)
+ ?.GetViewModel;
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
+ if (order == null)
+ {
+ return null;
+ }
+ order.Update(model);
+ context.SaveChanges();
+ return context.Orders
+ .Include(x => x.StoreKeeper)
+ .Include(x => x.Cosmetics)
+ .Include(x => x.Procedures)
+ .ThenInclude(x => x.Procedure)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs
index ea42875..4cfedec 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs
@@ -12,115 +12,99 @@ using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class ProcedureStorage : IProcedureStorage
- {
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.Procedures
- .Include(x => x.StoreKeeper)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Select(x => x.GetViewModel)
- .ToList();
- }
+ public class ProcedureStorage : IProcedureStorage
+ {
+ public ProcedureViewModel? Delete(ProcedureBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var element = context.Procedures
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ var deletedElement = context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ context.Procedures.Remove(element);
+ context.SaveChanges();
+ return deletedElement;
+ }
+ return null;
+ }
- public List GetFilteredList(ProcedureSearchModel model)
- {
- using var context = new BeautyStudioDatabase();
- if (model.Id.HasValue)
- {
- return context.Procedures
- .Include(x => x.StoreKeeper)
- .Where(x => x.Id == model.Id)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- if (model.StoreKeeperId.HasValue)
- {
- return context.Procedures
- .Include(x => x.StoreKeeper)
- .Where(x => x.StoreKeeperId == model.StoreKeeperId)
- .Select(x => x.GetViewModel)
- .ToList();
- }
+ public ProcedureViewModel? GetElement(ProcedureSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
- return new();
- }
+ public List GetFilteredList(ProcedureSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (model.StoreKeeperId.HasValue)
+ {
+ return context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Where(x => x.StoreKeeperId == model.StoreKeeperId)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
- public ProcedureViewModel? GetElement(ProcedureSearchModel model)
- {
- if (string.IsNullOrEmpty(model.ProcedureName) && !model.Id.HasValue)
- {
- return null;
- }
- using var context = new BeautyStudioDatabase();
- return context.Procedures
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProcedureName) && x.ProcedureName == model.ProcedureName) ||
- (model.Id.HasValue && x.Id == model.Id))
- ?.GetViewModel;
- }
+ public ProcedureViewModel? Insert(ProcedureBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var newProcedure = Procedure.Create(context, model);
+ if (newProcedure == null)
+ {
+ return null;
+ }
+ context.Procedures.Add(newProcedure);
+ context.SaveChanges();
+ return context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .FirstOrDefault(x => x.Id == newProcedure.Id)
+ ?.GetViewModel;
+ }
- public ProcedureViewModel? Insert(ProcedureBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var newProcedure = Procedure.Create(context, model);
- if (newProcedure == null)
- {
- return null;
- }
-
- context.Procedures.Add(newProcedure);
- context.SaveChanges();
- return newProcedure.GetViewModel;
- }
-
-
- public ProcedureViewModel? Update(ProcedureBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Procedures
- .FirstOrDefault(x => x.Id.Equals(model.Id));
- if (element == null)
- {
- return null;
- }
-
- element.Update(model);
- context.SaveChanges();
- return element.GetViewModel;
- }
-
- public ProcedureViewModel? Delete(ProcedureBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Procedures
- .FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- context.Procedures.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
-
- public List GetProcedureCosmetics(ProcedureSearchModel model)
- {
- if (model == null)
- {
- return new();
- }
- using var context = new BeautyStudioDatabase();
- var cosmetics = context.ProcedureCosmetics
- .Where(x => x.ProcedureId == model.Id)
- .Select(x => x.Cosmetic.GetViewModel)
- .ToList();
- return cosmetics;
- }
-
- }
+ public ProcedureViewModel? Update(ProcedureBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var proc = context.Procedures.FirstOrDefault(x => x.Id == model.Id);
+ if (proc == null)
+ {
+ return null;
+ }
+ proc.Update(model);
+ proc.UpdateServices(context, model);
+ context.SaveChanges();
+ return context.Procedures
+ .Include(x => x.Services)
+ .ThenInclude(x => x.Service)
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs
index 17bcca9..fa4e1e6 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs
@@ -3,7 +3,6 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDatabaseImplement.Models;
-using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,123 +11,81 @@ using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class ServiceStorage : IServiceStorage
- {
- public ServiceViewModel? Delete(ServiceBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var element = context.Services
- .Include(x => x.Procedures)
- .Include(x => x.Cosmetics)
- .FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- context.Services.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
-
- public ServiceViewModel? GetElement(ServiceSearchModel model)
- {
- if (string.IsNullOrEmpty(model.ServiceName) && !model.Id.HasValue)
- {
- return null;
- }
- using var context = new BeautyStudioDatabase();
- return context.Services
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ServiceName) && x.ServiceName == model.ServiceName) ||
- (model.Id.HasValue && x.Id == model.Id))
- ?.GetViewModel;
- }
-
- public List GetFilteredList(ServiceSearchModel model)
- {
- if (model == null)
- {
- return new();
- }
- using var context = new BeautyStudioDatabase();
- if (model.Id.HasValue)
- {
- return context.Services
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Where(x => x.Id == model.Id)
- .ToList()
- .Select(x => x.GetViewModel)
- .ToList();
- }
- if (model.StoreKeeperId.HasValue)
- {
- return context.Services
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Where(x => x.StoreKeeperId == model.StoreKeeperId)
- .ToList()
- .Select(x => x.GetViewModel)
- .ToList();
- }
- return new();
- }
-
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.Services
- .Include(x => x.Procedures)
- .ThenInclude(x => x.Procedure)
- .Include(x => x.Cosmetics)
- .ThenInclude(x => x.Cosmetic)
- .Select(x => x.GetViewModel)
- .ToList();
- }
-
- public ServiceViewModel? Insert(ServiceBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var newService = Service.Create(context, model);
- if (newService == null)
- {
- return null;
- }
- context.Services.Add(newService);
- context.SaveChanges();
- return newService.GetViewModel;
- }
-
- public ServiceViewModel? Update(ServiceBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- using var transaction = context.Database.BeginTransaction();
- try
- {
- var service = context.Services.FirstOrDefault(rec => rec.Id == model.Id);
- if (service == null)
- {
- return null;
- }
- service.Update(model);
- context.SaveChanges();
- service.UpdateCosmetics(context, model);
- service.UpdateProcedures(context, model);
- transaction.Commit();
- return service.GetViewModel;
- }
- catch
- {
- transaction.Rollback();
- throw;
- }
- }
- }
+ public class ServiceStorage : IServiceStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.Services
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(ServiceSearchModel model)
+ {
+ if (!model.StoreKeeperId.HasValue && !model.DateCreate.HasValue && !model.DateComplete.HasValue)
+ {
+ return new();
+ }
+ using var context = new BeautyStudioDatabase();
+ if (model.DateCreate.HasValue)
+ return context.Services.Where(x => x.StoreKeeperId == model.StoreKeeperId).Where(x => x.DateCreate <= model.DateComplete && x.DateCreate >= model.DateCreate).Select(x => x.GetViewModel).ToList();
+ else
+ return context.Services.Where(x => x.StoreKeeperId == model.StoreKeeperId).Select(x => x.GetViewModel).ToList();
+ }
+ public ServiceViewModel? GetElement(ServiceSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return context.Services
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public ServiceViewModel? Insert(ServiceBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var newBundling = Service.Create(model);
+ if (newBundling == null)
+ {
+ return null;
+ }
+ context.Services.Add(newBundling);
+ context.SaveChanges();
+ return context.Services
+ .FirstOrDefault(x => x.Id == newBundling.Id)
+ ?.GetViewModel;
+ }
+ public ServiceViewModel? Update(ServiceBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var order = context.Services.FirstOrDefault(x => x.Id == model.Id);
+ if (order == null)
+ {
+ return null;
+ }
+ order.Update(model);
+ context.SaveChanges();
+ return context.Services
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public ServiceViewModel? Delete(ServiceBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var element = context.Services
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ var deletedElement = context.Services
+ .FirstOrDefault(x => x.Id == model.Id)
+ ?.GetViewModel;
+ context.Services.Remove(element);
+ context.SaveChanges();
+ return deletedElement;
+ }
+ return null;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StoreKeeperStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StoreKeeperStorage.cs
index 1483e77..340c8ec 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StoreKeeperStorage.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StoreKeeperStorage.cs
@@ -1,118 +1,94 @@
-using System;
+using BeautyStudioContracts.BindingModels;
+using BeautyStudioContracts.SearchModels;
+using BeautyStudioContracts.StoragesContracts;
+using BeautyStudioContracts.ViewModels;
+using BeautyStudioDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using System.Numerics;
-using BeautyStudioContracts.StoragesContracts;
-using BeautyStudioContracts.ViewModels;
-using BeautyStudioContracts.SearchModels;
-using BeautyStudioContracts.BindingModels;
-using BeautyStudioDatabaseImplement.Models;
namespace BeautyStudioDatabaseImplement.Implements
{
- public class StoreKeeperStorage : IStoreKeeperStorage
- {
- public List GetFullList()
- {
- using var context = new BeautyStudioDatabase();
- return context.StoreKeepers
- .Select(x => x.GetViewModel)
- .ToList();
- }
- public List GetFilteredList(StoreKeeperSearchModel model)
- {
- using var context = new BeautyStudioDatabase();
- // Фильтрация по ФИО
- if (!string.IsNullOrEmpty(model.StoreKeeperFIO))
- {
- return context.StoreKeepers
- .Where(x => x.StoreKeeperFIO.Contains(model.StoreKeeperFIO))
- .Select(x => x.GetViewModel)
- .ToList();
- }
+ public class StoreKeeperStorage : IStoreKeeperStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new BeautyStudioDatabase();
+ return context.StoreKeepers
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(StoreKeeperSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return new();
+ }
+ using var context = new BeautyStudioDatabase();
+ if (model.Id.HasValue)
+ {
+ return context.StoreKeepers.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
+ }
+ else
+ {
+ return new();
+ }
+ }
- // Фильтрация по логину
- if (!string.IsNullOrEmpty(model.StoreKeeperLogin))
- {
- return context.StoreKeepers
- .Where(x => x.StoreKeeperLogin.Contains(model.StoreKeeperLogin))
- .Select(x => x.GetViewModel)
- .ToList();
- }
+ public StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ if (!model.Id.HasValue && string.IsNullOrEmpty(model.StoreKeeperEmail)) { return null; }
+ return context.StoreKeepers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)
+ || (!string.IsNullOrEmpty(model.StoreKeeperEmail) && !string.IsNullOrEmpty(model.StoreKeeperPassword) && x.StoreKeeperEmail.Equals(model.StoreKeeperEmail) && x.StoreKeeperPassword.Equals(model.StoreKeeperPassword)))?.GetViewModel;
+ }
- return new();
- }
- public StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model)
- {
- using var context = new BeautyStudioDatabase();
- // Поиск по идентификатору
- if (model.Id.HasValue)
- {
- return context.StoreKeepers
- .FirstOrDefault(x => x.Id.Equals(model.Id))
- ?.GetViewModel;
- }
- // Поиск по логину и паролю
- if (!string.IsNullOrEmpty(model.StoreKeeperLogin) && !string.IsNullOrEmpty(model.StoreKeeperPassword))
- {
- return context.StoreKeepers
- .FirstOrDefault(x => x.StoreKeeperLogin.Equals(model.StoreKeeperLogin) && x.StoreKeeperPassword.Equals(model.StoreKeeperPassword))
- ?.GetViewModel;
- }
+ public StoreKeeperViewModel? Delete(StoreKeeperBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var res = context.StoreKeepers
+ .FirstOrDefault(x => x.Id == model.Id);
- //// Поиск по логину
- if (!string.IsNullOrEmpty(model.StoreKeeperLogin))
- {
- return context.StoreKeepers
- .FirstOrDefault(x => x.StoreKeeperLogin.Equals(model.StoreKeeperLogin))
- ?.GetViewModel;
- }
+ if (res != null)
+ {
+ context.StoreKeepers.Remove(res);
+ context.SaveChanges();
+ }
- return null;
- }
- public StoreKeeperViewModel? Insert(StoreKeeperBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var newStoreKeeper = StoreKeeper.Create(model);
- if (newStoreKeeper == null)
- {
- return null;
- }
+ return res?.GetViewModel;
+ }
- context.StoreKeepers.Add(newStoreKeeper);
- context.SaveChanges();
- return newStoreKeeper.GetViewModel;
- }
- public StoreKeeperViewModel? Update(StoreKeeperBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var storekeeper = context.StoreKeepers
- .FirstOrDefault(x => x.Id.Equals(model.Id));
- if (storekeeper == null)
- {
- return null;
- }
+ public StoreKeeperViewModel? Insert(StoreKeeperBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+ var res = StoreKeeper.Create(model);
- storekeeper.Update(model);
- context.SaveChanges();
- return storekeeper.GetViewModel;
- }
- public StoreKeeperViewModel? Delete(StoreKeeperBindingModel model)
- {
- using var context = new BeautyStudioDatabase();
- var storekeeper = context.StoreKeepers
- .FirstOrDefault(x => x.Id.Equals(model.Id));
- if (storekeeper == null)
- {
- return null;
- }
+ if (res != null)
+ {
+ context.StoreKeepers.Add(res);
+ context.SaveChanges();
+ }
- context.StoreKeepers.Remove(storekeeper);
- context.SaveChanges();
- return storekeeper.GetViewModel;
- }
- }
+ return res?.GetViewModel;
+ }
+
+ public StoreKeeperViewModel? Update(StoreKeeperBindingModel model)
+ {
+ using var context = new BeautyStudioDatabase();
+
+ var res = context.StoreKeepers.FirstOrDefault(x => x.Id == model.Id);
+
+ if (res != null)
+ {
+ res.Update(model);
+ context.SaveChanges();
+ }
+
+ return res?.GetViewModel;
+ }
+ }
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.Designer.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.Designer.cs
similarity index 57%
rename from BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.Designer.cs
rename to BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.Designer.cs
index 2f4b919..2326376 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.Designer.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.Designer.cs
@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BeautyStudioDatabaseImplement.Migrations
{
[DbContext(typeof(BeautyStudioDatabase))]
- [Migration("20240829021006_Mig")]
- partial class Mig
+ [Migration("20240909181355_InitialMig")]
+ partial class InitialMig
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -40,9 +40,15 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Property("CosmeticPrice")
.HasColumnType("double precision");
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
b.Property("LaborCostId")
.HasColumnType("integer");
+ b.Property("OrderId")
+ .HasColumnType("integer");
+
b.Property("StoreKeeperId")
.HasColumnType("integer");
@@ -50,12 +56,14 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.HasIndex("LaborCostId");
+ b.HasIndex("OrderId");
+
b.HasIndex("StoreKeeperId");
b.ToTable("Cosmetics");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b =>
+ modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticServices", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -66,19 +74,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Property("CosmeticId")
.HasColumnType("integer");
- b.Property("ProcedureCosmeticCount")
- .HasColumnType("integer");
-
- b.Property("ProcedureId")
+ b.Property("ServiceId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CosmeticId");
- b.HasIndex("ProcedureId");
+ b.HasIndex("ServiceId");
- b.ToTable("CosmeticProcedures");
+ b.ToTable("CosmeticServices");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b =>
@@ -89,9 +94,8 @@ namespace BeautyStudioDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("Difficulty")
- .IsRequired()
- .HasColumnType("text");
+ b.Property("Difficulty")
+ .HasColumnType("integer");
b.Property("StoreKeeperId")
.HasColumnType("integer");
@@ -101,39 +105,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.HasKey("Id");
- b.HasIndex("StoreKeeperId");
-
- b.ToTable("LaborCost");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
- {
- b.Property("MessageId")
- .HasColumnType("text");
-
- b.Property("Body")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property("DateDelivery")
- .HasColumnType("timestamp with time zone");
-
- b.Property("SenderName")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property("StorekeeperId")
- .HasColumnType("integer");
-
- b.Property("Subject")
- .IsRequired()
- .HasColumnType("text");
-
- b.HasKey("MessageId");
-
- b.HasIndex("StorekeeperId");
-
- b.ToTable("MessageInfos");
+ b.ToTable("LaborCosts");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
@@ -144,15 +116,13 @@ namespace BeautyStudioDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("DateComplete")
- .HasColumnType("timestamp with time zone");
+ b.Property("OrderName")
+ .IsRequired()
+ .HasColumnType("text");
- b.Property("DateCreate")
+ b.Property("PaymentDate")
.HasColumnType("timestamp with time zone");
- b.Property("Status")
- .HasColumnType("integer");
-
b.Property("StoreKeeperId")
.HasColumnType("integer");
@@ -166,32 +136,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.ToTable("Orders");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("CosmeticId")
- .HasColumnType("integer");
-
- b.Property("Count")
- .HasColumnType("integer");
-
- b.Property("OrderId")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.HasIndex("CosmeticId");
-
- b.HasIndex("OrderId");
-
- b.ToTable("OrderCosmetics");
- });
-
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b =>
{
b.Property("Id")
@@ -203,9 +147,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Property("OrderId")
.HasColumnType("integer");
- b.Property("OrderProcedureCount")
- .HasColumnType("integer");
-
b.Property("ProcedureId")
.HasColumnType("integer");
@@ -218,32 +159,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.ToTable("OrderProcedures");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("OrderId")
- .HasColumnType("integer");
-
- b.Property("OrderServiceCount")
- .HasColumnType("integer");
-
- b.Property("ServiceId")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.HasIndex("OrderId");
-
- b.HasIndex("ServiceId");
-
- b.ToTable("OrderServices");
- });
-
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
{
b.Property("Id")
@@ -268,12 +183,10 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.HasKey("Id");
- b.HasIndex("StoreKeeperId");
-
b.ToTable("Procedures");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
+ modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureServices", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -281,22 +194,22 @@ namespace BeautyStudioDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("CosmeticId")
- .HasColumnType("integer");
-
b.Property("Count")
.HasColumnType("integer");
b.Property("ProcedureId")
.HasColumnType("integer");
- b.HasKey("Id");
+ b.Property("ServiceId")
+ .HasColumnType("integer");
- b.HasIndex("CosmeticId");
+ b.HasKey("Id");
b.HasIndex("ProcedureId");
- b.ToTable("ProcedureCosmetics");
+ b.HasIndex("ServiceId");
+
+ b.ToTable("ProcedureServices");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
@@ -307,6 +220,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
b.Property("ServiceName")
.IsRequired()
.HasColumnType("text");
@@ -319,63 +235,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.HasKey("Id");
- b.HasIndex("StoreKeeperId");
-
b.ToTable("Services");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("CosmeticId")
- .HasColumnType("integer");
-
- b.Property("ServiceCosmeticCount")
- .HasColumnType("integer");
-
- b.Property("ServiceId")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.HasIndex("CosmeticId");
-
- b.HasIndex("ServiceId");
-
- b.ToTable("ServiceCosmetics");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ProcedureId")
- .HasColumnType("integer");
-
- b.Property("ServiceId")
- .HasColumnType("integer");
-
- b.Property("ServiceProcedureCount")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.HasIndex("ProcedureId");
-
- b.HasIndex("ServiceId");
-
- b.ToTable("ServiceProcedures");
- });
-
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
{
b.Property("Id")
@@ -417,54 +279,40 @@ namespace BeautyStudioDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order")
+ .WithMany("Cosmetics")
+ .HasForeignKey("OrderId");
+
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
- .WithMany()
+ .WithMany("Cosmetics")
.HasForeignKey("StoreKeeperId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LaborCost");
+ b.Navigation("Order");
+
b.Navigation("StoreKeeper");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b =>
+ modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticServices", b =>
{
b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
- .WithMany("Procedures")
+ .WithMany("Services")
.HasForeignKey("CosmeticId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
- .WithMany("Cosmetics")
- .HasForeignKey("ProcedureId")
+ b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
+ .WithMany("CosmeticServices")
+ .HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cosmetic");
- b.Navigation("Procedure");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
- .WithMany()
- .HasForeignKey("StoreKeeperId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("StoreKeeper");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "Storekeeper")
- .WithMany()
- .HasForeignKey("StorekeeperId");
-
- b.Navigation("Storekeeper");
+ b.Navigation("Service");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
@@ -478,25 +326,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Navigation("StoreKeeper");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
- .WithMany()
- .HasForeignKey("CosmeticId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order")
- .WithMany("Cosmetics")
- .HasForeignKey("OrderId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Cosmetic");
-
- b.Navigation("Order");
- });
-
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b =>
{
b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order")
@@ -506,7 +335,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
.IsRequired();
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
- .WithMany()
+ .WithMany("OrderProcedures")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -516,95 +345,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Navigation("Procedure");
});
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b =>
+ modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureServices", b =>
{
- b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order")
+ b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("Services")
- .HasForeignKey("OrderId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
- .WithMany()
- .HasForeignKey("ServiceId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Order");
-
- b.Navigation("Service");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
- .WithMany()
- .HasForeignKey("StoreKeeperId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("StoreKeeper");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
- .WithMany()
- .HasForeignKey("CosmeticId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
- .WithMany()
- .HasForeignKey("ProcedureId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Cosmetic");
-
- b.Navigation("Procedure");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
- .WithMany()
- .HasForeignKey("StoreKeeperId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("StoreKeeper");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
- .WithMany()
- .HasForeignKey("CosmeticId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
- .WithMany("Cosmetics")
- .HasForeignKey("ServiceId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Cosmetic");
-
- b.Navigation("Service");
- });
-
- modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
- {
- b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
- .WithMany()
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
- .WithMany("Procedures")
+ .WithMany("ProcedureServices")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -616,7 +366,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b =>
{
- b.Navigation("Procedures");
+ b.Navigation("Services");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b =>
@@ -629,20 +379,25 @@ namespace BeautyStudioDatabaseImplement.Migrations
b.Navigation("Cosmetics");
b.Navigation("Procedures");
-
- b.Navigation("Services");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
{
- b.Navigation("Cosmetics");
+ b.Navigation("OrderProcedures");
+
+ b.Navigation("Services");
});
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
{
- b.Navigation("Cosmetics");
+ b.Navigation("CosmeticServices");
- b.Navigation("Procedures");
+ b.Navigation("ProcedureServices");
+ });
+
+ modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
+ {
+ b.Navigation("Cosmetics");
});
#pragma warning restore 612, 618
}
diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.cs
similarity index 50%
rename from BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.cs
rename to BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.cs
index 0ed403f..3c30e07 100644
--- a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240829021006_Mig.cs
+++ b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240909181355_InitialMig.cs
@@ -7,11 +7,58 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BeautyStudioDatabaseImplement.Migrations
{
///
- public partial class Mig : Migration
+ public partial class InitialMig : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.CreateTable(
+ name: "LaborCosts",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ TimeSpent = table.Column(type: "integer", nullable: false),
+ Difficulty = table.Column(type: "integer", nullable: false),
+ StoreKeeperId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_LaborCosts", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Procedures",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ProcedureName = table.Column(type: "text", nullable: false),
+ ProcedureCost = table.Column(type: "double precision", nullable: false),
+ ProcedureDescription = table.Column(type: "text", nullable: false),
+ StoreKeeperId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Procedures", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Services",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ DateCreate = table.Column | | | | | |