я все блин блинский переделал, осталось только отчеты...
This commit is contained in:
parent
48cb2d71aa
commit
cf5f70a3fd
@ -12,7 +12,8 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="NLog" Version="5.3.2" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.10" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage, IStoreKeeperStorage staffmemberStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageInfoStorage = messageInfoStorage;
|
||||
_staffmemberStorage = staffmemberStorage;
|
||||
}
|
||||
public List<MessageInfoViewModel>? 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<OrderLogic> 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<OrderViewModel>? 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<OrderLogic> 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<OrderViewModel>? 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<ReportCosmeticProceduresViewModel> GetCosmeticProcedures()
|
||||
{
|
||||
var cosmetics = _cosmeticStorage.GetFullList();
|
||||
var procedures = _procedureStorage.GetFullList();
|
||||
var list = new List<ReportCosmeticProceduresViewModel>();
|
||||
foreach (var cosmetic in cosmetics)
|
||||
{
|
||||
var record = new ReportCosmeticProceduresViewModel
|
||||
{
|
||||
CosmeticName = cosmetic.CosmeticName,
|
||||
Procedures = new List<string>(),
|
||||
};
|
||||
foreach (var procedure in procedures)
|
||||
{
|
||||
if (cosmetic.CosmeticProcedure.ContainsKey(procedure.Id))
|
||||
{
|
||||
record.Procedures.Add(new(procedure.ProcedureName));
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportServicesViewModel> GetServices(ReportServiceBindingModel model)
|
||||
{
|
||||
List<ReportServicesViewModel> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<StoreKeeperViewModel>? 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))
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -35,8 +35,8 @@ namespace BeautyStudioBusinessLogic.OfficePackage
|
||||
Style = "Normal"
|
||||
});
|
||||
|
||||
// Создаем таблицу с тремя колонками
|
||||
CreateTable(new List<string> { "7cm", "4cm", "4cm" });
|
||||
// Создаем таблицу с двумя колонками
|
||||
CreateTable(new List<string> { "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<string> { view.ServiceName, "", "" },
|
||||
Texts = new List<string> { "Номер услуги", "Заказ" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { report.Id.ToString(), "" },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
|
||||
// Конвертируем из HashSet в List, чтобы можно было обращаться по индексу
|
||||
List<string> cosmetics = new List<string>();
|
||||
foreach (var item in view.Cosmetics)
|
||||
{
|
||||
var cosmeticModel = item.Value.Item1;
|
||||
cosmetics.Add(cosmeticModel.CosmeticName);
|
||||
}
|
||||
List<string> procedures = new List<string>();
|
||||
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<string> { "", procedure, cosmetic },
|
||||
Texts = new List<string> { "", product },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "", "Трудозатраты" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var production in report.LaborCosts)
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "", production },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Сохраняем файл
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<ReportCosmeticProceduresViewModel> CosmeticProcedures { get; set; } = new();
|
||||
public List<ReportProcedureCosmeticsViewModel> ProcedureCosmetics { get; set; } = new();
|
||||
public List<ReportCosmeticViewModel> cosmeticProceduresReport { get; set; } = new();
|
||||
public int maxleng { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||
public List<ReportServicesViewModel> Services { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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<ReportCosmeticProceduresViewModel> CosmeticProcedures { get; set; } = new();
|
||||
public List<ReportProcedureCosmeticsViewModel> ProcedureCosmetics { get; set; } = new();
|
||||
public List<ReportCosmeticViewModel> cosmeticProceduresReport { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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<WorkbookStylesPart>();
|
||||
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<WorkbookStylesPart>();
|
||||
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<SharedStringTablePart>().Any()
|
||||
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
// Создаем 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<SharedStringTablePart>().Any()
|
||||
?
|
||||
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||
:
|
||||
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
// Создаем лист в книгу
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
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<SheetData>();
|
||||
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<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().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<SheetData>();
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Cell cell;
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ищем строку, либо добавляем ее
|
||||
Row row;
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().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<Cell>())
|
||||
{
|
||||
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<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Все ячейки должны быть последовательно друг за другом расположены
|
||||
// нужно определить, после какой вставлять
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
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<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().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<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
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<string> 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)
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<int, IProcedureModel> CosmeticProcedure { get; set; } = new();
|
||||
public DateTime DateCreate { get; set; }
|
||||
public Dictionary<int, IServiceModel> CosmeticServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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<int, (IServiceModel, int)> OrderServices { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> OrderCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; set; } = new();
|
||||
public DateTime PaymentDate { get; set; } = DateTime.Now;
|
||||
public double Sum { get; set; }
|
||||
public Dictionary<int, IProcedureModel> OrderProcedures { get; set; } = new();
|
||||
public Dictionary<int, ICosmeticModel> Cosmetics { get; set; } = new();
|
||||
}
|
||||
}
|
||||
}
|
@ -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<int, (ICosmeticModel, int)> ProcedureCosmetics { get; set; } = new();
|
||||
public Dictionary<int, IServiceModel> ProcedureServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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<int, (ICosmeticModel, int)> ServiceCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; set; } = new();
|
||||
public DateTime DateCreate { get; set; }
|
||||
public Dictionary<int, IProcedureModel> ServiceProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
@ -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<OrderViewModel>? 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<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioContracts.BusinessLogicContracts
|
||||
namespace BeautyStudioContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
List<ReportServicesViewModel> GetServices(ReportServiceBindingModel model);
|
||||
List<ReportCosmeticProceduresViewModel> GetCosmeticProcedures();
|
||||
void SaveCosmeticProceduresToExcelFile(ReportBindingModel model);
|
||||
void SaveCosmeticProceduresToWordFile(ReportBindingModel model);
|
||||
void SaveServicesToPdfFile(ReportServiceBindingModel model);
|
||||
}
|
||||
}
|
||||
public interface IReportLogic
|
||||
{
|
||||
List<ReportServicesViewModel> GetBundligs(ReportBindingModel model);
|
||||
List<ReportCosmeticViewModel> GetCars(ReportBindingModel model);
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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<OrderStatus>? Statuses { get; set; }
|
||||
public List<int>? CosmeticIds { get; set; }
|
||||
public List<int>? ProcedureIds { get; set; }
|
||||
public List<int>? 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<IProcedureModel> Procedures { get; set; } = new();
|
||||
public List<ICosmeticModel> Cosmetics { get; set; } = new();
|
||||
public DateTime? DateCreate { get; set; }
|
||||
public DateTime? DateComplete { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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<int>? CosmeticIds { get; set; }
|
||||
public List<int>? ProcedureIds { get; set; }
|
||||
public DateTime? DateCreate { get; set; }
|
||||
public DateTime? DateComplete { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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;}
|
||||
|
@ -17,6 +17,5 @@ namespace BeautyStudioContracts.StoragesContracts
|
||||
CosmeticViewModel? Insert(CosmeticBindingModel model);
|
||||
CosmeticViewModel? Update(CosmeticBindingModel model);
|
||||
CosmeticViewModel? Delete(CosmeticBindingModel model);
|
||||
List<ProcedureViewModel> GetCosmeticProcedures(CosmeticSearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -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<MessageInfoViewModel> GetFullList();
|
||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioContracts.StoragesContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,5 @@ namespace BeautyStudioContracts.StoragesContracts
|
||||
ProcedureViewModel? Insert(ProcedureBindingModel model);
|
||||
ProcedureViewModel? Update(ProcedureBindingModel model);
|
||||
ProcedureViewModel? Delete(ProcedureBindingModel model);
|
||||
List<CosmeticViewModel> GetProcedureCosmetics(ProcedureSearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<int, IProcedureModel> CosmeticProcedure { get; set; } = new();
|
||||
public Dictionary<int, IServiceModel> CosmeticServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<int, (IServiceModel, int)> OrderServices { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> OrderCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; set; } = new();
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime PaymentDate { get; set; }
|
||||
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
public Dictionary<int, IProcedureModel> OrderProcedures { get; set; } = new();
|
||||
public Dictionary<int, ICosmeticModel> Cosmetics { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<int, (ICosmeticModel, int)> ProcedureCosmetics { get; set; } = new();
|
||||
public Dictionary<int, IServiceModel> ProcedureServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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<string> Procedures { get; set; } = new();
|
||||
|
@ -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<int, (ICosmeticModel, int)> Cosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> Procedures { get; set; } = new();
|
||||
public Dictionary<int, (IServiceModel, int)> Services { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
@ -11,10 +11,8 @@ namespace BeautyStudioContracts.ViewModels
|
||||
public class ReportServicesViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
public Dictionary <int, (ICosmeticModel, int)> Cosmetics { get; set; } = new();
|
||||
public Dictionary <int, (IProcedureModel, int)> Procedures { get; set; } = new();
|
||||
public double ServicePrice { get; set; }
|
||||
public List<string> Orders { get; set; } = new();
|
||||
public List<string> LaborCosts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,8 +19,10 @@ namespace BeautyStudioContracts.ViewModels
|
||||
public double ServicePrice { get; set; }
|
||||
[DisplayName("Сотрудник")]
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics { get; set; } = new();
|
||||
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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<int, IProcedureModel> ProcedureCosmetics;
|
||||
public int? Count;
|
||||
}
|
||||
}
|
16
BeautyStudio/BeautyStudioDataModels/Enums/Difficulties.cs
Normal file
16
BeautyStudio/BeautyStudioDataModels/Enums/Difficulties.cs
Normal file
@ -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,
|
||||
}
|
||||
}
|
19
BeautyStudio/BeautyStudioDataModels/Enums/TimeSpent.cs
Normal file
19
BeautyStudio/BeautyStudioDataModels/Enums/TimeSpent.cs
Normal file
@ -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,
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace BeautyStudioDataModels.Models
|
||||
string CosmeticName { get; }
|
||||
double CosmeticPrice { get; }
|
||||
int LaborCostId { get; }
|
||||
Dictionary<int, IProcedureModel> CosmeticProcedure { get; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
Dictionary<int, IServiceModel> CosmeticServices { get; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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<int, (ICosmeticModel, int)> OrderCosmetics { get; } // список косметики "участвующей" в заказе
|
||||
Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; } // список процедур "участвующих" в заказе
|
||||
Dictionary<int, (IServiceModel, int)> OrderServices { get; } // список услуг "участвующих" в заказе
|
||||
}
|
||||
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
string OrderName { get; set; }
|
||||
DateTime PaymentDate { get; set; }
|
||||
double Sum { get; set; }
|
||||
Dictionary<int, IProcedureModel> OrderProcedures { get; }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ namespace BeautyStudioDataModels.Models
|
||||
string ProcedureName { get; }
|
||||
double ProcedureCost { get; }
|
||||
string ProcedureDescription { get; }
|
||||
int StoreKeeperId { get; }
|
||||
Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics { get; }
|
||||
Dictionary<int, IServiceModel> ProcedureServices { get; }
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ namespace BeautyStudioDataModels.Models
|
||||
{
|
||||
string ServiceName { get; }
|
||||
double ServicePrice { get; }
|
||||
int StoreKeeperId { get; set; }
|
||||
Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics { get; }
|
||||
Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; }
|
||||
DateTime DateCreate { get; }
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,13 @@ namespace BeautyStudioDatabaseImplement
|
||||
}
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<LaborCost> LaborCost { set; get; }
|
||||
public virtual DbSet<LaborCost> LaborCosts { set; get; }
|
||||
public virtual DbSet<Cosmetic> Cosmetics { set; get; }
|
||||
public virtual DbSet<Service> Services { set; get; }
|
||||
public virtual DbSet<Procedure> Procedures { set; get; }
|
||||
public virtual DbSet<ServiceCosmetic> ServiceCosmetics { set; get; }
|
||||
public virtual DbSet<ServiceProcedure> ServiceProcedures { set; get; }
|
||||
public virtual DbSet<OrderCosmetic> OrderCosmetics { set; get; }
|
||||
public virtual DbSet<OrderService> OrderServices { set; get; }
|
||||
public virtual DbSet<OrderProcedure> OrderProcedures { set; get; }
|
||||
public virtual DbSet<CosmeticProcedure> CosmeticProcedures { set; get; }
|
||||
public virtual DbSet<ProcedureCosmetic> ProcedureCosmetics { set; get; }
|
||||
public virtual DbSet<CosmeticServices> CosmeticServices { set; get; }
|
||||
public virtual DbSet<ProcedureServices> ProcedureServices { set; get; }
|
||||
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
|
||||
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -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<CosmeticViewModel> 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<CosmeticViewModel> 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<ProcedureViewModel> 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<CosmeticViewModel> 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<CosmeticViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<LaborCostViewModel> 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<LaborCostViewModel> 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<LaborCostViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.LaborCosts
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<LaborCostViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<MessageInfoViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.MessageInfos.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
if (!model.StorekeeperId.HasValue)
|
||||
{
|
||||
return new List<MessageInfoViewModel>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<OrderViewModel> 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<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
public List<OrderViewModel> 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<OrderViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,115 +12,99 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
public class ProcedureStorage : IProcedureStorage
|
||||
{
|
||||
public List<ProcedureViewModel> 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<ProcedureViewModel> 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<ProcedureViewModel> 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<ProcedureViewModel> 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<CosmeticViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<ServiceViewModel> 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<ServiceViewModel> 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<ServiceViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.Services
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ServiceViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<StoreKeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.StoreKeepers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<StoreKeeperViewModel> 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<StoreKeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.StoreKeepers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<StoreKeeperViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -40,9 +40,15 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<double>("CosmeticPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("LaborCostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -66,19 +74,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureCosmeticCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
b.Property<int>("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<int>("Id"));
|
||||
|
||||
b.Property<string>("Difficulty")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
b.Property<int>("Difficulty")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("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<string>("MessageId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("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<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
b.Property<string>("OrderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
b.Property<DateTime>("PaymentDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -166,32 +136,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.ToTable("OrderCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -203,9 +147,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderProcedureCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -218,32 +159,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("OrderProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderServiceCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("OrderServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -281,22 +194,22 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.Property<int>("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<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceCosmeticCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceProcedureCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Property<int>("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
|
||||
}
|
@ -7,11 +7,58 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace BeautyStudioDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Mig : Migration
|
||||
public partial class InitialMig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LaborCosts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
TimeSpent = table.Column<int>(type: "integer", nullable: false),
|
||||
Difficulty = table.Column<int>(type: "integer", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LaborCosts", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Procedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProcedureName = table.Column<string>(type: "text", nullable: false),
|
||||
ProcedureCost = table.Column<double>(type: "double precision", nullable: false),
|
||||
ProcedureDescription = table.Column<string>(type: "text", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
ServiceName = table.Column<string>(type: "text", nullable: false),
|
||||
ServicePrice = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StoreKeepers",
|
||||
columns: table => new
|
||||
@ -30,45 +77,30 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LaborCost",
|
||||
name: "ProcedureServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
TimeSpent = table.Column<int>(type: "integer", nullable: false),
|
||||
Difficulty = table.Column<string>(type: "text", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LaborCost", x => x.Id);
|
||||
table.PrimaryKey("PK_ProcedureServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_LaborCost_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
name: "FK_ProcedureServices_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MessageInfos",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "text", nullable: false),
|
||||
StorekeeperId = table.Column<int>(type: "integer", nullable: true),
|
||||
SenderName = table.Column<string>(type: "text", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Subject = table.Column<string>(type: "text", nullable: false),
|
||||
Body = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MessageInfos", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_MessageInfos_StoreKeepers_StorekeeperId",
|
||||
column: x => x.StorekeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id");
|
||||
name: "FK_ProcedureServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -77,11 +109,10 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateComplete = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderName = table.Column<string>(type: "text", nullable: false),
|
||||
PaymentDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -94,69 +125,33 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Procedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProcedureName = table.Column<string>(type: "text", nullable: false),
|
||||
ProcedureCost = table.Column<double>(type: "double precision", nullable: false),
|
||||
ProcedureDescription = table.Column<string>(type: "text", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Procedures_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ServiceName = table.Column<string>(type: "text", nullable: false),
|
||||
ServicePrice = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Services_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: true),
|
||||
CosmeticName = table.Column<string>(type: "text", nullable: false),
|
||||
CosmeticPrice = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false),
|
||||
LaborCostId = table.Column<int>(type: "integer", nullable: false)
|
||||
LaborCostId = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cosmetics_LaborCost_LaborCostId",
|
||||
name: "FK_Cosmetics_LaborCosts_LaborCostId",
|
||||
column: x => x.LaborCostId,
|
||||
principalTable: "LaborCost",
|
||||
principalTable: "LaborCosts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cosmetics_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Cosmetics_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
@ -172,8 +167,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderProcedureCount = table.Column<int>(type: "integer", nullable: false)
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -193,206 +187,55 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderServices",
|
||||
name: "CosmeticServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderServiceCount = table.Column<int>(type: "integer", nullable: false)
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderServices", x => x.Id);
|
||||
table.PrimaryKey("PK_CosmeticServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderServices_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
name: "FK_CosmeticServices_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderServices_Services_ServiceId",
|
||||
name: "FK_CosmeticServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceProcedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceProcedureCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ServiceProcedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceProcedures_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceProcedures_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CosmeticProcedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureCosmeticCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CosmeticProcedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CosmeticProcedures_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CosmeticProcedures_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderCosmetics_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProcedureCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProcedureCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureCosmetics_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceCosmeticCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ServiceCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceCosmetics_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CosmeticProcedures_CosmeticId",
|
||||
table: "CosmeticProcedures",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CosmeticProcedures_ProcedureId",
|
||||
table: "CosmeticProcedures",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cosmetics_LaborCostId",
|
||||
table: "Cosmetics",
|
||||
column: "LaborCostId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cosmetics_OrderId",
|
||||
table: "Cosmetics",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cosmetics_StoreKeeperId",
|
||||
table: "Cosmetics",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LaborCost_StoreKeeperId",
|
||||
table: "LaborCost",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MessageInfos_StorekeeperId",
|
||||
table: "MessageInfos",
|
||||
column: "StorekeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderCosmetics_CosmeticId",
|
||||
table: "OrderCosmetics",
|
||||
name: "IX_CosmeticServices_CosmeticId",
|
||||
table: "CosmeticServices",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderCosmetics_OrderId",
|
||||
table: "OrderCosmetics",
|
||||
column: "OrderId");
|
||||
name: "IX_CosmeticServices_ServiceId",
|
||||
table: "CosmeticServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderProcedures_OrderId",
|
||||
@ -410,85 +253,27 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderServices_OrderId",
|
||||
table: "OrderServices",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderServices_ServiceId",
|
||||
table: "OrderServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureCosmetics_CosmeticId",
|
||||
table: "ProcedureCosmetics",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureCosmetics_ProcedureId",
|
||||
table: "ProcedureCosmetics",
|
||||
name: "IX_ProcedureServices_ProcedureId",
|
||||
table: "ProcedureServices",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Procedures_StoreKeeperId",
|
||||
table: "Procedures",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceCosmetics_CosmeticId",
|
||||
table: "ServiceCosmetics",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceCosmetics_ServiceId",
|
||||
table: "ServiceCosmetics",
|
||||
name: "IX_ProcedureServices_ServiceId",
|
||||
table: "ProcedureServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceProcedures_ProcedureId",
|
||||
table: "ServiceProcedures",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceProcedures_ServiceId",
|
||||
table: "ServiceProcedures",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Services_StoreKeeperId",
|
||||
table: "Services",
|
||||
column: "StoreKeeperId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CosmeticProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MessageInfos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderCosmetics");
|
||||
name: "CosmeticServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProcedureCosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceCosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
name: "ProcedureServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cosmetics");
|
||||
@ -500,7 +285,10 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
name: "Services");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LaborCost");
|
||||
name: "LaborCosts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "StoreKeepers");
|
@ -37,9 +37,15 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<double>("CosmeticPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("LaborCostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -47,12 +53,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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -63,19 +71,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureCosmeticCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
b.Property<int>("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 =>
|
||||
@ -86,9 +91,8 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Difficulty")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
b.Property<int>("Difficulty")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
@ -98,39 +102,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("LaborCost");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("MessageId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("MessageInfos");
|
||||
b.ToTable("LaborCosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
|
||||
@ -141,15 +113,13 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
b.Property<string>("OrderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
b.Property<DateTime>("PaymentDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -163,32 +133,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.ToTable("OrderCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -200,9 +144,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderProcedureCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -215,32 +156,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("OrderProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderServiceCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("OrderServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -265,12 +180,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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -278,22 +191,22 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.Property<int>("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 =>
|
||||
@ -304,6 +217,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -316,63 +232,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceCosmeticCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ServiceProcedureCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -414,54 +276,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 =>
|
||||
@ -475,25 +323,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")
|
||||
@ -503,7 +332,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany()
|
||||
.WithMany("OrderProcedures")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -513,95 +342,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();
|
||||
@ -613,7 +363,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b =>
|
||||
@ -626,20 +376,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
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public class Cosmetic : ICosmeticModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? OrderId { get; set; }
|
||||
[Required]
|
||||
public string CosmeticName { get; set; } = string.Empty;
|
||||
|
||||
@ -27,29 +27,29 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public int LaborCostId { get; set; }
|
||||
public virtual LaborCost LaborCost { get; set; } = new();
|
||||
public virtual Order? Order { get; set; }
|
||||
|
||||
//// связь многие-ко-многим заказов и косметики
|
||||
//[ForeignKey("CosmeticId")]
|
||||
//public virtual List<OrderCosmetic> Orders { get; set; } = new();
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
|
||||
private Dictionary<int, IServiceModel>? _cosmeticServices = null;
|
||||
// связь многие-ко-многим косметики с процедурами
|
||||
[ForeignKey("CosmeticId")]
|
||||
private Dictionary<int, IProcedureModel>? _cosmeticProcedures = null;
|
||||
public virtual List<CosmeticServices> Services { get; set; } = new();
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IProcedureModel> CosmeticProcedure
|
||||
public Dictionary<int, IServiceModel> CosmeticServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cosmeticProcedures == null)
|
||||
if (_cosmeticServices == null)
|
||||
{
|
||||
_cosmeticProcedures = Procedures.ToDictionary(recPC => recPC.ProcedureId, recPC => (recPC.Procedure as IProcedureModel));
|
||||
_cosmeticServices = Services.ToDictionary(recPC => recPC.ServiceId, recPC => (recPC.Service as IServiceModel));
|
||||
}
|
||||
return _cosmeticProcedures;
|
||||
return _cosmeticServices;
|
||||
}
|
||||
}
|
||||
// список косметики в закаче
|
||||
public virtual List<CosmeticProcedure> Procedures { get; set; } = new();
|
||||
|
||||
public static Cosmetic Create(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
@ -58,49 +58,54 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var cosmetic = new Cosmetic()
|
||||
return new Cosmetic()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
LaborCostId = model.LaborCostId,
|
||||
OrderId = model.OrderId,
|
||||
CosmeticName = model.CosmeticName,
|
||||
CosmeticPrice = model.CosmeticPrice,
|
||||
LaborCostId = model.LaborCostId,
|
||||
StoreKeeperId = model.StoreKeeperId
|
||||
DateCreate = model.DateCreate,
|
||||
|
||||
Services = model.CosmeticServices.Select(x => new CosmeticServices
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
return cosmetic;
|
||||
}
|
||||
|
||||
public void Update(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
CosmeticName = model.CosmeticName;
|
||||
CosmeticPrice = model.CosmeticPrice;
|
||||
LaborCostId = model.LaborCostId;
|
||||
}
|
||||
public void Update(CosmeticBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreKeeperId = model.StoreKeeperId;
|
||||
LaborCostId = model.LaborCostId;
|
||||
OrderId = model.OrderId;
|
||||
CosmeticName = model.CosmeticName;
|
||||
DateCreate = model.DateCreate;
|
||||
CosmeticPrice = model.CosmeticPrice;
|
||||
}
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
public void UpdateServices(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
var cosmeticProcedures = context.CosmeticProcedures.Where(rec => rec.CosmeticId == model.Id).ToList();
|
||||
if (cosmeticProcedures != null && cosmeticProcedures.Count > 0)
|
||||
{
|
||||
context.CosmeticProcedures.RemoveRange(cosmeticProcedures.Where(rec => !model.CosmeticProcedure.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateProcedure in cosmeticProcedures)
|
||||
{
|
||||
model.CosmeticProcedure.Remove(updateProcedure.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var cosmetic = context.Cosmetics.First(x => x.Id == Id);
|
||||
foreach (var rp in model.CosmeticProcedure)
|
||||
foreach (var pc in model.CosmeticServices)
|
||||
{
|
||||
context.CosmeticProcedures.Add(new CosmeticProcedure
|
||||
if (!context.CosmeticServices.Any(ps => ps.CosmeticId == cosmetic.Id && ps.ServiceId == pc.Value.Id))
|
||||
{
|
||||
Cosmetic = cosmetic,
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
context.CosmeticServices.Add(new CosmeticServices
|
||||
{
|
||||
Cosmetic = cosmetic,
|
||||
Service = context.Services.First(x => x.Id == pc.Key),
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
_cosmeticProcedures = null;
|
||||
context.SaveChanges();
|
||||
_cosmeticServices = null;
|
||||
}
|
||||
|
||||
public CosmeticViewModel GetViewModel => new()
|
||||
@ -108,8 +113,9 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
Id = Id,
|
||||
CosmeticName = CosmeticName,
|
||||
CosmeticPrice = CosmeticPrice,
|
||||
OrderId = OrderId,
|
||||
LaborCostId = LaborCostId,
|
||||
CosmeticProcedure = CosmeticProcedure,
|
||||
CosmeticServices = CosmeticServices,
|
||||
StoreKeeperId = StoreKeeperId
|
||||
};
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class CosmeticProcedure
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProcedureCosmeticCount { get; set; }
|
||||
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
|
||||
public virtual Procedure Procedure { get; set; } = new();
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class ServiceCosmetic
|
||||
public class CosmeticServices
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -17,9 +17,6 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ServiceCosmeticCount { get; set; }
|
||||
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
|
||||
public virtual Service Service { get; set; } = new();
|
@ -1,5 +1,6 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDataModels.Enums;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -12,15 +13,13 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int TimeSpent { get; set; }
|
||||
public TimeSpent TimeSpent { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Difficulty { get; set; } = string.Empty;
|
||||
public Difficulties Difficulty { get; set; }
|
||||
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
|
||||
// связь один-ко-многим трудозатрат с косметикой
|
||||
[ForeignKey("LaborCostId")]
|
||||
public virtual List<Cosmetic> Cosmetics { get; set; } = new();
|
||||
@ -46,6 +45,7 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreKeeperId = model.StoreKeeperId;
|
||||
TimeSpent = model.TimeSpent;
|
||||
Difficulty = model.Difficulty;
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
public int? StorekeeperId { get; set; }
|
||||
|
||||
public virtual StoreKeeper? Storekeeper { get; set; }
|
||||
|
||||
[Required]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
MessageId = model.MessageId,
|
||||
StorekeeperId = model.StorekeeperId,
|
||||
SenderName = model.SenderName,
|
||||
DateDelivery = model.DateDelivery,
|
||||
Subject = model.Subject,
|
||||
Body = model.Body,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
MessageId = MessageId,
|
||||
StorekeeperId = StorekeeperId,
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
Subject = Subject,
|
||||
Body = Body
|
||||
};
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDataModels.Enums;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -15,202 +16,94 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
public DateTime? DateComplete { get; set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
public string OrderName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime PaymentDate { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
[Required]
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<Cosmetic> Cosmetics { get; set; } = new();
|
||||
private Dictionary<int, IProcedureModel>? _orderProcedures = null;
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _orderCosmetics = null; // поле для
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ICosmeticModel?, int)>? OrderCosmetics
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderCosmetics == null)
|
||||
{
|
||||
_orderCosmetics = Cosmetics.ToDictionary(recPC => recPC.CosmeticId, recPC => (recPC.Cosmetic as ICosmeticModel, recPC.Count));
|
||||
}
|
||||
return _orderCosmetics;
|
||||
}
|
||||
}
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderProcedure> Procedures { get; set; } = new();
|
||||
[NotMapped]
|
||||
public Dictionary<int, IProcedureModel> OrderProcedures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderProcedures == null)
|
||||
{
|
||||
_orderProcedures = Procedures.ToDictionary(recPc => recPc.ProcedureId, recPc => recPc.Procedure as IProcedureModel);
|
||||
}
|
||||
return _orderProcedures;
|
||||
}
|
||||
}
|
||||
public static Order? Create(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var order = new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
OrderName = model.OrderName,
|
||||
PaymentDate = model.PaymentDate,
|
||||
Sum = model.Sum,
|
||||
Procedures = model.OrderProcedures.Select(x => new OrderProcedure
|
||||
{
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Value.Id)
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderCosmetic> Cosmetics { get; set; } = new(); // список косметических товаров для данного заказа.
|
||||
foreach (var cosmetic in model.Cosmetics)
|
||||
{
|
||||
var cosm = context.Cosmetics.FirstOrDefault(x => x.Id == cosmetic.Value.Id);
|
||||
if (cosm != null)
|
||||
{
|
||||
order.Cosmetics.Add(cosm);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, (IProcedureModel, int)>? _orderProcedures = null; // поле для хранения словаря OrderCosmetics.
|
||||
return order;
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures // список косметики используемых в заказе.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderProcedures == null)
|
||||
{
|
||||
_orderProcedures = Procedures
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
(recPC.Procedure as IProcedureModel, recPC.OrderProcedureCount));
|
||||
}
|
||||
return _orderProcedures;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderProcedure> Procedures { get; set; } = new(); // представляет список процедур для данного заказа.
|
||||
|
||||
private Dictionary<int, (IServiceModel, int)>? _orderServices = null; // поле для хранения словаря OrderServices.
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IServiceModel, int)> OrderServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderServices == null)
|
||||
{
|
||||
_orderServices = Services.ToDictionary(recPC => recPC.ServiceId, recPC => (recPC.Service as IServiceModel, recPC.OrderServiceCount));
|
||||
}
|
||||
return _orderServices;
|
||||
}
|
||||
}
|
||||
|
||||
// связь услуги и заказов многие - ко - многим
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderService> Services { get; set; } = new();
|
||||
public static Order Create(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var order = new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
Sum = model.Sum,
|
||||
DateCreate = model.DateCreate,
|
||||
DateComplete = model.DateComplete,
|
||||
Status = model.Status,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.OrderCosmetics.Select(x => new OrderCosmetic
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Procedures = model.OrderProcedures.Select(x => new OrderProcedure
|
||||
{
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Services = model.OrderServices.Select(x => new OrderService
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateComplete = model.DateComplete;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DateCreate = DateCreate,
|
||||
DateComplete = DateComplete,
|
||||
Sum = Sum,
|
||||
Status = Status
|
||||
};
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderCosmetics = context.OrderCosmetics.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderCosmetics != null && orderCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderCosmetics.RemoveRange(orderCosmetics.Where(rec => !model.OrderCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in orderCosmetics)
|
||||
{
|
||||
model.OrderCosmetics.Remove(updateCosmetic.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var rp in model.OrderCosmetics)
|
||||
{
|
||||
context.OrderCosmetics.Add(new OrderCosmetic
|
||||
{
|
||||
Order = order,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderCosmetics = null;
|
||||
}
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderProcedures = context.OrderProcedures.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderProcedures != null && orderProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderProcedures.RemoveRange(orderProcedures.Where(rec => !model.OrderProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateProcedure in orderProcedures)
|
||||
{
|
||||
model.OrderProcedures.Remove(updateProcedure.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var rp in model.OrderProcedures)
|
||||
{
|
||||
context.OrderProcedures.Add(new OrderProcedure
|
||||
{
|
||||
Order = order,
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderProcedures = null;
|
||||
}
|
||||
|
||||
public void UpdateServices(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderServices = context.OrderServices.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderServices != null && orderServices.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderServices.RemoveRange(orderServices.Where(rec => !model.OrderServices.ContainsKey(rec.ServiceId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateService in orderServices)
|
||||
{
|
||||
model.OrderServices.Remove(updateService.ServiceId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var rp in model.OrderServices)
|
||||
{
|
||||
context.OrderServices.Add(new OrderService
|
||||
{
|
||||
Order = order,
|
||||
Service = context.Services.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderServices = null;
|
||||
}
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OrderName = model.OrderName;
|
||||
PaymentDate = model.PaymentDate;
|
||||
Sum = model.Sum;
|
||||
}
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var pc in model.OrderProcedures)
|
||||
{
|
||||
context.OrderProcedures.Add(new OrderProcedure
|
||||
{
|
||||
Order = order,
|
||||
Procedure = context.Procedures.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderProcedures = null;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
OrderName = OrderName,
|
||||
PaymentDate = PaymentDate,
|
||||
Sum = Sum,
|
||||
OrderProcedures = OrderProcedures,
|
||||
Cosmetics = Cosmetics.ToDictionary(x => x.Id, x => x as ICosmeticModel),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class OrderCosmetic
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
}
|
||||
}
|
@ -17,9 +17,6 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderProcedureCount { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Procedure Procedure { get; set; } = new();
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class OrderService
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderServiceCount { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Service Service { get; set; } = new();
|
||||
}
|
||||
}
|
@ -26,91 +26,84 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
|
||||
[Required]
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _procedureCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics //представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_procedureCosmetics == null)
|
||||
{
|
||||
_procedureCosmetics = Cosmetics
|
||||
.ToDictionary(recPC => recPC.CosmeticId, recPC => (recPC.Cosmetic as ICosmeticModel, recPC.ProcedureCosmeticCount));
|
||||
}
|
||||
return _procedureCosmetics;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<OrderProcedure> OrderProcedures { get; set; } = new();
|
||||
|
||||
public virtual List<CosmeticProcedure> Cosmetics { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
private Dictionary<int, IServiceModel>? _procedureServices = null;
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<ProcedureServices> Services { get; set; } = new();
|
||||
|
||||
public static Procedure Create(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var procedure = new Procedure()
|
||||
{
|
||||
Id = model.Id,
|
||||
ProcedureName = model.ProcedureName,
|
||||
ProcedureCost = model.ProcedureCost,
|
||||
ProcedureDescription = model.ProcedureDescription,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.ProcedureCosmetics.Select(x => new CosmeticProcedure
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
public Dictionary<int, IServiceModel> ProcedureServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_procedureServices == null)
|
||||
{
|
||||
_procedureServices = Services.ToDictionary(recPc => recPc.ServiceId, recPc => recPc.Service as IServiceModel);
|
||||
}
|
||||
return _procedureServices;
|
||||
}
|
||||
}
|
||||
public static Procedure? Create(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var procedure = new Procedure()
|
||||
{
|
||||
Id = model.Id,
|
||||
ProcedureName = model.ProcedureName,
|
||||
ProcedureCost = model.ProcedureCost,
|
||||
ProcedureDescription = model.ProcedureDescription,
|
||||
Services = model.ProcedureServices.Select(x => new ProcedureServices
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Value.Id)
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
};
|
||||
return procedure;
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
public void Update(ProcedureBindingModel model)
|
||||
{
|
||||
ProcedureName = model.ProcedureName;
|
||||
ProcedureCost = model.ProcedureCost;
|
||||
ProcedureDescription = model.ProcedureDescription;
|
||||
}
|
||||
public void UpdateServices(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
var procedure = context.Procedures.First(x => x.Id == model.Id);
|
||||
|
||||
public ProcedureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ProcedureName = ProcedureName,
|
||||
ProcedureCost = ProcedureCost,
|
||||
ProcedureDescription = ProcedureDescription,
|
||||
ProcedureCosmetics = ProcedureCosmetics,
|
||||
StoreKeeperId = StoreKeeperId,
|
||||
StoreKeeperName = StoreKeeper.StoreKeeperFIO,
|
||||
};
|
||||
foreach (var pc in model.ProcedureServices)
|
||||
{
|
||||
// Проверяем, существует ли уже запись-связь
|
||||
if (!context.ProcedureServices.Any(ps => ps.ProcedureId == procedure.Id && ps.ServiceId == pc.Value.Id))
|
||||
{
|
||||
context.ProcedureServices.Add(new ProcedureServices
|
||||
{
|
||||
Procedure = procedure,
|
||||
Service = context.Services.First(x => x.Id == pc.Value.Id),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
var procedureCosmetics = context.CosmeticProcedures.Where(rec => rec.ProcedureId == model.Id).ToList();
|
||||
if (procedureCosmetics != null && procedureCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.CosmeticProcedures.RemoveRange(procedureCosmetics.Where(rec => !model.ProcedureCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in procedureCosmetics)
|
||||
{
|
||||
model.ProcedureCosmetics.Remove(updateCosmetic.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var procedure = context.Procedures.First(x => x.Id == Id);
|
||||
foreach (var rp in model.ProcedureCosmetics)
|
||||
{
|
||||
context.CosmeticProcedures.Add(new CosmeticProcedure
|
||||
{
|
||||
Procedure = procedure,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_procedureCosmetics = null;
|
||||
}
|
||||
}
|
||||
context.SaveChanges(); // Сохраняем изменения только один раз
|
||||
_procedureServices = null;
|
||||
}
|
||||
public void Update(ProcedureBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ProcedureName = model.ProcedureName;
|
||||
ProcedureCost = model.ProcedureCost;
|
||||
ProcedureDescription = model.ProcedureDescription;
|
||||
}
|
||||
|
||||
public ProcedureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ProcedureName = ProcedureName,
|
||||
ProcedureCost = ProcedureCost,
|
||||
ProcedureDescription = ProcedureDescription,
|
||||
ProcedureServices = ProcedureServices,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class ProcedureCosmetic
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Procedure Procedure { get; set; } = new();
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -8,21 +7,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class ServiceProcedure
|
||||
public class ProcedureServices
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ServiceProcedureCount { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
|
||||
public virtual Service Service { get; set; } = new();
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Procedure Procedure { get; set; } = new();
|
||||
public virtual Service Service { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -8,6 +9,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -17,7 +19,8 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public class Service : IServiceModel
|
||||
{
|
||||
public int Id {get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get ; set; } = DateTime.Now;
|
||||
[Required]
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
|
||||
@ -25,144 +28,56 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public double ServicePrice { get; set; }
|
||||
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _serviceCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics //представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_serviceCosmetics == null)
|
||||
{
|
||||
_serviceCosmetics = Cosmetics
|
||||
.ToDictionary(recPC => recPC.CosmeticId, recPC =>
|
||||
(recPC.Cosmetic as ICosmeticModel, recPC.ServiceCosmeticCount));
|
||||
}
|
||||
return _serviceCosmetics;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceCosmetic> Cosmetics { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
|
||||
|
||||
|
||||
private Dictionary<int, (IProcedureModel, int)>? _serviceProcedures = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures//представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_serviceProcedures == null)
|
||||
{
|
||||
_serviceProcedures = Procedures
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
(recPC.Procedure as IProcedureModel, recPC.ServiceProcedureCount));
|
||||
}
|
||||
return _serviceProcedures;
|
||||
}
|
||||
}
|
||||
public virtual List<CosmeticServices> CosmeticServices { get; set; } = new();
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceProcedure> Procedures { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
public virtual List<ProcedureServices> ProcedureServices { get; set; } = new();
|
||||
|
||||
public static Service Create(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
public static Service? Create(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var service = new Service()
|
||||
return new Service()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
ServiceName = model.ServiceName,
|
||||
ServicePrice = model.ServicePrice,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.ServiceCosmetics.Select(x => new ServiceCosmetic
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Procedures = model.ServiceProcedures.Select(x => new ServiceProcedure
|
||||
{
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
DateCreate = model.DateCreate,
|
||||
};
|
||||
}
|
||||
public static Service Create(ServiceViewModel model)
|
||||
{
|
||||
return new Service
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
ServiceName = model.ServiceName,
|
||||
ServicePrice = model.ServicePrice,
|
||||
DateCreate = model.DateCreate,
|
||||
};
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
public void Update(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DateCreate = model.DateCreate;
|
||||
StoreKeeperId = model.StoreKeeperId;
|
||||
ServiceName = model.ServiceName;
|
||||
ServicePrice = model.ServicePrice;
|
||||
StoreKeeperId = model.StoreKeeperId;
|
||||
}
|
||||
|
||||
public ServiceViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreKeeperId = StoreKeeperId,
|
||||
ServiceName = ServiceName,
|
||||
ServicePrice = ServicePrice,
|
||||
ServiceCosmetics = ServiceCosmetics,
|
||||
ServiceProcedures = ServiceProcedures,
|
||||
StoreKeeperId = StoreKeeperId,
|
||||
DateCreate = DateCreate,
|
||||
};
|
||||
|
||||
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
{
|
||||
var serviceCosmetics = context.ServiceCosmetics.Where(rec => rec.ServiceId == model.Id).ToList();
|
||||
if (serviceCosmetics != null && serviceCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ServiceCosmetics.RemoveRange(serviceCosmetics.Where(rec => !model.ServiceCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in serviceCosmetics)
|
||||
{
|
||||
model.ServiceCosmetics.Remove(updateCosmetic.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var service = context.Services.First(x => x.Id == Id);
|
||||
foreach (var rp in model.ServiceCosmetics)
|
||||
{
|
||||
context.ServiceCosmetics.Add(new ServiceCosmetic
|
||||
{
|
||||
Service = service,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_serviceCosmetics = null;
|
||||
}
|
||||
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
{
|
||||
var serviceProcedures = context.ServiceProcedures.Where(rec => rec.ServiceId == model.Id).ToList();
|
||||
if (serviceProcedures != null && serviceProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ServiceProcedures.RemoveRange(serviceProcedures.Where(rec => !model.ServiceProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in serviceProcedures)
|
||||
{
|
||||
model.ServiceProcedures.Remove(updateCosmetic.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var service = context.Services.First(x => x.Id == Id);
|
||||
foreach (var rp in model.ServiceProcedures)
|
||||
{
|
||||
context.ServiceProcedures.Add(new ServiceProcedure
|
||||
{
|
||||
Service = service,
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_serviceProcedures = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public string StoreKeeperPhone { get; set; } = string.Empty;
|
||||
|
||||
[ForeignKey("StoreKeeperId")]
|
||||
public virtual List<Cosmetic> Cosmetics { get; set; } = new();
|
||||
|
||||
public static StoreKeeper? Create(StoreKeeperBindingModel model)
|
||||
{
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -53,7 +53,7 @@ namespace BeautyStudioRestAPI.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return cosmetic.ReadList(new CosmeticSearchModel { LaborCostId = userId });
|
||||
return cosmetic.ReadList(new CosmeticSearchModel { Id = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,89 +0,0 @@
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeautyStudioRestAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
public ReportController(ILogger<ReportController> logger, IReportLogic reportLogic, AbstractMailWorker abstractMailWorker)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportLogic = reportLogic;
|
||||
_mailWorker = abstractMailWorker;
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveServicesPdfFile(ReportBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
FileName = "C:\\reports\\pdfservicesreport.pdf",
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveCosmeticProceduresToWordFile(ReportBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel { FileName = "C:\\reports\\wordcosmeticproceduresreport.docx" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveCosmeticProceduresToExcelFile(ReportBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel { FileName = "C:\\reports\\excelcosmeticproceduresreport.xlsx" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void MailSend(ReportServiceBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
FileName = report.FileName,
|
||||
StorekeeperId = report.StorekeeperId,
|
||||
Email = report.Email,
|
||||
});
|
||||
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = report.Email!,
|
||||
Subject = "Отчет по услугам",
|
||||
Text = "Ваш отчет:"
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отправки письма");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioDatabaseImplement.Implements;
|
||||
using BeautyStudioBusinessLogic.OfficePackage;
|
||||
using BeautyStudioBusinessLogic.OfficePackage.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
|
||||
@ -16,7 +15,6 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IStoreKeeperStorage, StoreKeeperStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<ILaborCostStorage, LaborCostStorage>();
|
||||
@ -24,7 +22,6 @@ builder.Services.AddTransient<ICosmeticStorage, CosmeticStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
|
||||
builder.Services.AddTransient<IStoreKeeperLogic, StoreKeeperLogic>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<ILaborCostLogic, LaborCostLogic>();
|
||||
@ -34,22 +31,12 @@ builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BeautyStudioRestAPI", Version = "v1" });
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
@ -62,11 +49,7 @@ mailSender?.MailConfig(new MailConfigBindingModel
|
||||
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||
});
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BeautyStudioRestAPI v1"));
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
@ -1,49 +0,0 @@
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace StoreKeeperWebApp
|
||||
{
|
||||
public class APIStoreKeeper
|
||||
{
|
||||
private static readonly HttpClient _storekeeper = new();
|
||||
|
||||
public static StoreKeeperViewModel? Storekeeper { get; set; } = null;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_storekeeper.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_storekeeper.DefaultRequestHeaders.Accept.Clear();
|
||||
_storekeeper.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _storekeeper.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = _storekeeper.PostAsync(requestUrl, data);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class CosmeticController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
private readonly ILaborCostLogic laborCost;
|
||||
private readonly IProcedureLogic procedure;
|
||||
|
||||
public CosmeticController(ILogger<CosmeticController> logger, ICosmeticLogic cosmetic, IProcedureLogic procedure, ILaborCostLogic laborCost)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
this.procedure = procedure;
|
||||
this.laborCost = laborCost;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CosmeticViewModel? GetCosmetic(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Cosmetics()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(cosmetic.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateCosmetics(int laborCostId)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.LaborCost = laborCost.ReadList(new LaborCostSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCosmetics(string name, double price, int laborCost)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || price <= 0 || laborCost <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
cosmetic.Create(new CosmeticBindingModel
|
||||
{
|
||||
CosmeticName = name,
|
||||
CosmeticPrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
LaborCostId = laborCost
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateCosmetics(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.LaborCost = laborCost.ReadList(new LaborCostSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View(cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCosmetics(int id, string name, double price, int laborCost)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || laborCost <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
cosmetic.Update(new CosmeticBindingModel
|
||||
{
|
||||
Id = id,
|
||||
CosmeticName = name,
|
||||
CosmeticPrice = price,
|
||||
LaborCostId = laborCost
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить косметику
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public void DeleteCosmetics(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
cosmetic.Delete(new CosmeticBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
}
|
||||
}
|
@ -3,267 +3,422 @@ using BeautyStudioContracts.ViewModels;
|
||||
using StoreKeeperWebApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using BeautyStudioDataModels.Enums;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using StoreKeeperWebApp.Models;
|
||||
using Microsoft.AspNetCore.Identity.Data;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreKeeperLogic _logic;
|
||||
private readonly ICosmeticLogic _cosmeticLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly StoreKeeperData _data;
|
||||
public HomeController(ILogger<HomeController> logger, StoreKeeperData data)
|
||||
{
|
||||
_logger = logger;
|
||||
_data = data;
|
||||
}
|
||||
private bool IsLoggedIn { get { return UserStoreKeeper.user != null; } }
|
||||
private int UserId { get { return UserStoreKeeper.user!.Id; } }
|
||||
public IActionResult IndexNonReg()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return View();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return View();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
var user = _data.Login(login, password);
|
||||
if (user != null)
|
||||
{
|
||||
UserStoreKeeper.user = user;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Logout()
|
||||
{
|
||||
UserStoreKeeper.user = null;
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string name, string phone, string email, string password1, string password2)
|
||||
{
|
||||
if (password1 == password2 && _data.Register(new() { StoreKeeperEmail = email, StoreKeeperLogin = email, StoreKeeperFIO = name, StoreKeeperPhone = phone, StoreKeeperPassword = password1 }))
|
||||
{
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult IndexService()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
var list = _data.GetServices(UserStoreKeeper.user.Id);
|
||||
if (list != null)
|
||||
return View(list);
|
||||
return View(new List<ServiceViewModel>());
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public void IndexService(int id)
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
_data.DeleteService(id);
|
||||
}
|
||||
Response.Redirect("IndexService");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateService(int id)
|
||||
{
|
||||
var procedures = _data.GetProcedures();
|
||||
ViewBag.AllProcedures = procedures;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetService(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new ServiceViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateService(ServiceBindingModel model, int[] procedureIds)
|
||||
{
|
||||
var procedures = _data.GetProcedures();
|
||||
if (model.Id == 0)
|
||||
{
|
||||
model.DateCreate = DateTime.UtcNow;
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
for (int i = 0; i < procedureIds.Length; i++)
|
||||
{
|
||||
var procedure = procedures!.FirstOrDefault(x => x.Id == procedureIds[i])!;
|
||||
model.ServiceProcedures.Add(i, procedure);
|
||||
}
|
||||
if (_data.CreateService(model))
|
||||
return RedirectToAction("IndexService");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < procedureIds.Length; i++)
|
||||
{
|
||||
var procedure = procedures!.FirstOrDefault(x => x.Id == procedureIds[i])!;
|
||||
model.ServiceProcedures.Add(i, procedure);
|
||||
}
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
if (_data.UpdateService(model))
|
||||
return RedirectToAction("IndexService");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
private readonly AbstractMailWorker _mailLogic;
|
||||
[HttpGet]
|
||||
public IActionResult IndexLaborCost()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
var list = _data.GetLaborCosts(UserStoreKeeper.user.Id);
|
||||
if (list != null)
|
||||
return View(list);
|
||||
return View(new List<LaborCostViewModel>());
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public void IndexLaborCost(int id)
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
_data.DeleteLaborCost(id);
|
||||
}
|
||||
Response.Redirect("IndexLaborCost");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateLaborCost(int id)
|
||||
{
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetLaborCost(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new LaborCostViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateLaborCost(LaborCostBindingModel model)
|
||||
{
|
||||
if (model.Id == 0)
|
||||
{
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
if (_data.CreateLaborCost(model))
|
||||
return RedirectToAction("IndexLaborCost");
|
||||
}
|
||||
else
|
||||
{
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
if (_data.UpdateLaborCost(model))
|
||||
return RedirectToAction("IndexLaborCost");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult IndexCosmetic()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
var cosmetics = _data.GetCosmetics(UserStoreKeeper.user.Id);
|
||||
return View(cosmetics);
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult IndexCosmetic(int id)
|
||||
{
|
||||
_data.DeleteCosmetic(id);
|
||||
return RedirectToAction("IndexCosmetic");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateCosmetic(int id)
|
||||
{
|
||||
var services = _data.GetServices(UserStoreKeeper.user!.Id);
|
||||
var laborCosts = _data.GetLaborCosts(UserStoreKeeper.user!.Id);
|
||||
ViewBag.AllServices = services;
|
||||
ViewBag.LaborCosts = laborCosts;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetCosmetic(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new CosmeticViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateCosmetic(int id, string CosmeticName, int LaborCostId, int[] serviceIds)
|
||||
{
|
||||
CosmeticBindingModel model = new CosmeticBindingModel();
|
||||
model.Id = id;
|
||||
model.CosmeticName = CosmeticName;
|
||||
model.LaborCostId = LaborCostId;
|
||||
model.DateCreate = DateTime.UtcNow;
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
var services = _data.GetServices(UserStoreKeeper.user!.Id);
|
||||
double sum = 0;
|
||||
for (int i = 0; i < serviceIds.Length; i++)
|
||||
{
|
||||
var service = services!.FirstOrDefault(x => x.Id == serviceIds[i])!;
|
||||
model.CosmeticServices[serviceIds[i]] = service;
|
||||
sum += service.ServicePrice;
|
||||
}
|
||||
model.CosmeticPrice = sum;
|
||||
bool changed = false;
|
||||
if (model.CosmeticServices.Count > 0)
|
||||
{
|
||||
if (id != 0)
|
||||
{
|
||||
changed = _data.UpdateCosmetic(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = _data.CreateCosmetic(model);
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
return RedirectToAction("IndexCosmetic");
|
||||
else
|
||||
{
|
||||
ViewBag.AllServices = services;
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IStoreKeeperLogic workerLogic, ICosmeticLogic cosmeticLogic, IReportLogic reportLogic, AbstractMailWorker mailLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = workerLogic;
|
||||
_cosmeticLogic = cosmeticLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_mailLogic = mailLogic;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (IsLoggedIn)
|
||||
return View(UserStoreKeeper.user);
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Privacy(int id, string fullname, string email, string password, string phone)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
StoreKeeperBindingModel user = new()
|
||||
{
|
||||
Id = id,
|
||||
StoreKeeperFIO = fullname,
|
||||
StoreKeeperEmail = email,
|
||||
StoreKeeperPhone = phone,
|
||||
};
|
||||
if (_data.UpdateUser(user))
|
||||
{
|
||||
UserStoreKeeper.user = new StoreKeeperViewModel
|
||||
{
|
||||
Id = id,
|
||||
StoreKeeperEmail = email,
|
||||
StoreKeeperFIO = fullname,
|
||||
StoreKeeperPhone = phone,
|
||||
};
|
||||
}
|
||||
return View(user);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ServiceTimeChoose()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult SendReport(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ServiceTimeReport()
|
||||
{
|
||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||
|
||||
return View(APIStoreKeeper.Storekeeper);
|
||||
}
|
||||
if (string.IsNullOrEmpty(startDateStr) || string.IsNullOrEmpty(endDateStr))
|
||||
{
|
||||
return RedirectToAction("ServiceTimeChoose");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIStoreKeeper.Storekeeper);
|
||||
}
|
||||
[HttpPost]
|
||||
var startDate = DateTime.Parse(startDateStr);
|
||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||
|
||||
public void Privacy(string login, string password, string fio, string phone)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè?... Ñþäà âõîä òîëüêî àâòîðèçîâàííûì, ëèáî óõîäè îòñþäà!!!");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü, ÔÈÎ è òåëåôîí");
|
||||
}
|
||||
_logic.Update(new StoreKeeperBindingModel
|
||||
{
|
||||
Id = APIStoreKeeper.Storekeeper.Id,
|
||||
StoreKeeperFIO = fio,
|
||||
StoreKeeperLogin = login,
|
||||
StoreKeeperPassword = password,
|
||||
StoreKeeperEmail = login,
|
||||
StoreKeeperPhone = phone
|
||||
|
||||
});
|
||||
APIStoreKeeper.Storekeeper.StoreKeeperFIO = fio;
|
||||
APIStoreKeeper.Storekeeper.StoreKeeperLogin = login;
|
||||
APIStoreKeeper.Storekeeper.StoreKeeperPassword = password;
|
||||
APIStoreKeeper.Storekeeper.StoreKeeperEmail = login;
|
||||
APIStoreKeeper.Storekeeper.StoreKeeperPhone = phone;
|
||||
var values = _data.GetTimeReport(startDate, endDate, UserId);
|
||||
|
||||
Response.Redirect("Privacy");
|
||||
}
|
||||
ViewBag.StartDate = startDate;
|
||||
ViewBag.EndDate = endDate;
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper != null)
|
||||
{
|
||||
throw new Exception("Âû óæå àâòîðèçîâàëèñü!");
|
||||
}
|
||||
return View(values);
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäåíû íå âñå äàííûå!");
|
||||
}
|
||||
HttpContext.Session.SetString("StartDate", startDate.ToString("yyyy-MM-dd"));
|
||||
HttpContext.Session.SetString("EndDate", endDate.ToString("yyyy-MM-dd"));
|
||||
|
||||
APIStoreKeeper.Storekeeper = _logic.ReadElement(new StoreKeeperSearchModel
|
||||
{
|
||||
StoreKeeperLogin = login,
|
||||
StoreKeeperPassword = password
|
||||
});
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
}
|
||||
return RedirectToAction("ServiceTimeReport");
|
||||
}
|
||||
[HttpPost]
|
||||
public void ServiceTimeMail()
|
||||
{
|
||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||
var startDate = DateTime.Parse(startDateStr);
|
||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
|
||||
}
|
||||
Response.Redirect("ServiceTimeReport");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CosmeticProcedureChoose()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
var details = _data.GetCosmetics(UserId);
|
||||
return View(details);
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CosmeticProcedureChoose(List<int> selectedItems, string reportType)
|
||||
{
|
||||
string value = string.Join("/", selectedItems);
|
||||
HttpContext.Session.SetString("Cosmetics", value);
|
||||
if (reportType.Equals("default"))
|
||||
return RedirectToAction("CosmeticProceduresReport");
|
||||
else if (reportType.Equals("excel"))
|
||||
return RedirectToAction("ExcelGenerate");
|
||||
else
|
||||
return RedirectToAction("WordGenerate");
|
||||
}
|
||||
public async Task<IActionResult> ExcelGenerate()
|
||||
{
|
||||
var value = HttpContext.Session.GetString("Cosmetics");
|
||||
if (value != null)
|
||||
{
|
||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
_data.SaveReportExcel(rawReports, memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
var outputStream = new MemoryStream();
|
||||
await memoryStream.CopyToAsync(outputStream);
|
||||
outputStream.Seek(0, SeekOrigin.Begin);
|
||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
|
||||
}
|
||||
}
|
||||
return RedirectToAction("CosmeticProceduresChoose");
|
||||
}
|
||||
public async Task<IActionResult> WordGenerate()
|
||||
{
|
||||
var value = HttpContext.Session.GetString("Cosmetics");
|
||||
if (value != null)
|
||||
{
|
||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
_data.SaveReportWord(rawReports, memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
var outputStream = new MemoryStream();
|
||||
await memoryStream.CopyToAsync(outputStream);
|
||||
outputStream.Seek(0, SeekOrigin.Begin);
|
||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
|
||||
}
|
||||
}
|
||||
return RedirectToAction("CosmeticProceduresChoose");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CosmeticProceduresReport()
|
||||
{
|
||||
var value = HttpContext.Session.GetString("Cosmetics");
|
||||
if (value != null)
|
||||
{
|
||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||
var reports = _data.GetProcedureReports(rawReports);
|
||||
return View(reports);
|
||||
}
|
||||
return View(new List<ReportCosmeticViewModel>());
|
||||
}
|
||||
public IActionResult ReportMenu()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper != null)
|
||||
{
|
||||
throw new Exception("Âû óæå çàðåãèñòðèðîâàëèñü!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string fio, string email, string password, string phone)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(phone))
|
||||
{
|
||||
throw new Exception("Ââåäåíû íå âñå äàííûå!");
|
||||
}
|
||||
|
||||
_logic.Create(new StoreKeeperBindingModel
|
||||
{
|
||||
StoreKeeperFIO = fio,
|
||||
StoreKeeperEmail = email,
|
||||
StoreKeeperPassword = password,
|
||||
StoreKeeperLogin = email,
|
||||
StoreKeeperPhone = phone
|
||||
});
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
[HttpGet]
|
||||
public void Logout()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
|
||||
}
|
||||
|
||||
APIStoreKeeper.Storekeeper = null;
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Reports()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
|
||||
}
|
||||
var data = _reportLogic.GetServices(new ReportServiceBindingModel());
|
||||
|
||||
return View(data);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateReportWord(List<int> cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
// Ïðîâåðêè ââîäà è àâòîðèçàöèè
|
||||
var folderName = "C:\\îò÷åòû";
|
||||
var fileName = $"Ñïèñîê ïðîöåäóð {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.docx";
|
||||
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
|
||||
|
||||
_reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = filePath,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
|
||||
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
|
||||
return File(fileBytes, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", fileName);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateReportExcel(List<int> cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
// Ïðîâåðêè ââîäà è àâòîðèçàöèè
|
||||
var folderName = "C:\\îò÷åòû";
|
||||
var fileName = $"Ñïèñîê ïðîöåäóð {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx";
|
||||
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
|
||||
|
||||
_reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = filePath,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
|
||||
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
|
||||
return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateReportPdf(DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
// Ïðîâåðêè àâòîðèçàöèè è ââîäà
|
||||
var folderName = "C:\\îò÷åòû";
|
||||
var fileName = $"Ñïèñîê óñëóã {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.pdf";
|
||||
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
|
||||
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
FileName = filePath,
|
||||
StorekeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
|
||||
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
|
||||
return File(fileBytes, "application/pdf", fileName);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SendReport(IFormFile fileUpload, [FromServices] IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
|
||||
}
|
||||
|
||||
if (fileUpload == null || fileUpload.Length <= 0)
|
||||
{
|
||||
throw new Exception("Ôàéë íå âûáðàí èëè ïóñò!");
|
||||
}
|
||||
|
||||
// Ïóòü äî ôàéëà
|
||||
var uploadPath = Path.Combine(hostingEnvironment.ContentRootPath, "C:\\îò÷åòû");
|
||||
var fileName = Path.GetFileName(fileUpload.FileName);
|
||||
var fullPath = Path.Combine(uploadPath, fileName);
|
||||
|
||||
using (var fileStream = new FileStream(fullPath, FileMode.Create))
|
||||
{
|
||||
await fileUpload.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
_mailLogic.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = APIStoreKeeper.Storekeeper.StoreKeeperEmail,
|
||||
Subject = $"{fileName.Split('.')[0]}",
|
||||
Text = $"Îò÷¸ò îòïðàâëåí {DateTime.Now}",
|
||||
Path = fullPath
|
||||
});
|
||||
|
||||
return RedirectToAction("Reports", "Home");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
@ -1,179 +0,0 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class LaborCostController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ILaborCostLogic laborCost;
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
|
||||
public LaborCostController(ILogger<LaborCostController> logger, ILaborCostLogic laborCost, ICosmeticLogic cosmetic)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.laborCost = laborCost;
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public LaborCostViewModel? GetLaborCosts(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return laborCost.ReadElement(new LaborCostSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult LaborCosts()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(laborCost.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateLaborCosts()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateLaborCosts(int hours, string difficulty, int cosmeticId)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (hours <= 0 || string.IsNullOrEmpty(difficulty) || cosmeticId <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
laborCost.Create(new LaborCostBindingModel
|
||||
{
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
var labor = laborCost.ReadElement(new LaborCostSearchModel
|
||||
{
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
var cosm = cosmetic.ReadElement(new CosmeticSearchModel { Id = cosmeticId });
|
||||
if (cosm != null && labor != null)
|
||||
{
|
||||
cosm.LaborCostId = labor.Id; // Присваиваем айди трудозатраты к объекту косметики
|
||||
cosmetic.Update(new CosmeticBindingModel
|
||||
{
|
||||
Id = cosm.Id,
|
||||
CosmeticName = cosm.CosmeticName,
|
||||
CosmeticPrice = cosm.CosmeticPrice,
|
||||
LaborCostId = cosm.LaborCostId
|
||||
});
|
||||
}
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCosts");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateLaborCosts(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View(laborCost.ReadElement(new LaborCostSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateLaborCosts(int hours, string difficulty)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(difficulty) || hours <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
laborCost.Update(new LaborCostBindingModel
|
||||
{
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCosts");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить косметику
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public void DeleteLaborCosts(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
laborCost.Delete(new LaborCostBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCosts");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
using BeautyStudioBusinessLogic.BusinessLogic;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class ProcedureController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
private readonly IProcedureLogic procedure;
|
||||
private readonly IServiceLogic service;
|
||||
|
||||
public ProcedureController(ILogger<ProcedureController> logger, ICosmeticLogic cosmetic, IProcedureLogic procedure)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ProcedureViewModel? GetProcedure(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return procedure.ReadElement(new ProcedureSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Procedures()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(procedure.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateProcedures()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Procedures = procedure.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateProcedures(string name, double cost, string description)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || cost <= 0 || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
procedure.Create(new ProcedureBindingModel
|
||||
{
|
||||
ProcedureName = name,
|
||||
ProcedureCost = cost,
|
||||
ProcedureDescription = description,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateProcedures(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateProcedures(int id, string name, double cost, string description)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
procedure.Update(new ProcedureBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ProcedureName = name,
|
||||
ProcedureCost = cost,
|
||||
ProcedureDescription = description,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteProcedure(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
procedure.Delete(new ProcedureBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioDataModels.Enums;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Контроллер для сущности "Рецепт"
|
||||
/// </summary>
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
private readonly ILogger<ServiceController> _logger;
|
||||
private readonly IServiceLogic _serviceLogic;
|
||||
private readonly ICosmeticLogic _cosmeticLogic;
|
||||
private readonly IProcedureLogic _procedureLogic;
|
||||
|
||||
public ServiceController(ILogger<ServiceController> logger, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic, IProcedureLogic procedurecLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceLogic = serviceLogic;
|
||||
_cosmeticLogic = cosmeticLogic;
|
||||
_procedureLogic = procedurecLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Services()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_serviceLogic.ReadList(new ServiceSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateServices()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = _cosmeticLogic.ReadList(null);
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateServices(string name, double price, int count, List<int> cosmetics, List<int> procedures)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || price <= 0 || cosmetics == null || procedures == null)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, (ICosmeticModel, int)> serviceCosmetics = new Dictionary<int, (ICosmeticModel, int)>();
|
||||
foreach (var cosmeticId in cosmetics)
|
||||
{
|
||||
serviceCosmetics.Add(cosmeticId, (_cosmeticLogic.ReadElement(new CosmeticSearchModel { Id = cosmeticId })!, count));
|
||||
}
|
||||
|
||||
Dictionary<int, (IProcedureModel, int)> serviceProcedures = new Dictionary<int, (IProcedureModel, int)>();
|
||||
foreach (var procedureId in cosmetics)
|
||||
{
|
||||
serviceProcedures.Add(procedureId, (_procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!, count));
|
||||
}
|
||||
|
||||
_serviceLogic.Create(new ServiceBindingModel
|
||||
{
|
||||
ServiceName = name,
|
||||
ServicePrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
ServiceCosmetics = serviceCosmetics,
|
||||
ServiceProcedures = serviceProcedures
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateServices(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = _cosmeticLogic.ReadList(null);
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
||||
|
||||
return View(_serviceLogic.ReadElement(new ServiceSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateServices(int id, string name, double price, List<int> cosmetics, List<int> procedures)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || price <= 0 || cosmetics == null || procedures == null)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, (ICosmeticModel, int)> serviceCosmetics = new Dictionary<int, (ICosmeticModel, int)>();
|
||||
foreach (var cosmeticId in cosmetics)
|
||||
{
|
||||
serviceCosmetics.Add(cosmeticId, (_cosmeticLogic.ReadElement(new CosmeticSearchModel { Id = cosmeticId })!, 1));
|
||||
}
|
||||
|
||||
Dictionary<int, (IProcedureModel, int)> serviceProcedures = new Dictionary<int, (IProcedureModel, int)>();
|
||||
foreach (var procedureId in cosmetics)
|
||||
{
|
||||
serviceProcedures.Add(procedureId, (_procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!, 1));
|
||||
}
|
||||
|
||||
_serviceLogic.Update(new ServiceBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ServiceName = name,
|
||||
ServicePrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
ServiceCosmetics = serviceCosmetics,
|
||||
ServiceProcedures = serviceProcedures
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteService(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
_serviceLogic.Delete(new ServiceBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
public IActionResult AddProcedureToService()
|
||||
{
|
||||
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
||||
ViewBag.Services = _serviceLogic.ReadList(null);
|
||||
return View();
|
||||
}
|
||||
//[HttpPost]
|
||||
//public void AddProcedureToService(int product, int order)
|
||||
//{
|
||||
// if (APIStoreKeeper.Storekeeper == null)
|
||||
// {
|
||||
// throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
// }
|
||||
// APIStoreKeeper.PostRequest("api/main/updateorder", new OrderBindingModel
|
||||
// {
|
||||
// Id = order,
|
||||
// ProductId = product,
|
||||
// Status = OrderStatus.Принят,
|
||||
// });
|
||||
// Response.Redirect("");
|
||||
//}
|
||||
}
|
||||
}
|
@ -5,8 +5,8 @@ using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioBusinessLogic.OfficePackage.Implements;
|
||||
using BeautyStudioBusinessLogic.OfficePackage;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using BeautyStudioDatabaseImplement.Implements;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@ -16,19 +16,17 @@ builder.Services.AddControllersWithViews();
|
||||
|
||||
// Logger service
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<ILaborCostStorage, LaborCostStorage>();
|
||||
builder.Services.AddTransient<ICosmeticStorage, CosmeticStorage>();
|
||||
builder.Services.AddTransient<IStoreKeeperStorage, StoreKeeperStorage>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
@ -41,8 +39,14 @@ builder.Services.AddTransient<IStoreKeeperLogic, StoreKeeperLogic>();
|
||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
builder.Services.AddTransient<StoreKeeperData>();
|
||||
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
298
BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs
Normal file
298
BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs
Normal file
@ -0,0 +1,298 @@
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using BeautyStudioBusinessLogic.OfficePackage;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using System.Linq;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using BeautyStudioBusinessLogic.BusinessLogic;
|
||||
|
||||
namespace StoreKeeperWebApp
|
||||
{
|
||||
public class StoreKeeperData
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreKeeperLogic _StoreKeeperLogic;
|
||||
private readonly IServiceLogic _serviceLogic;
|
||||
private readonly ILaborCostLogic _laborCostLogic;
|
||||
private readonly ICosmeticLogic _cosmeticLogic;
|
||||
private readonly IProcedureLogic _procedureLogic;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly AbstractSaveToExcel _excel;
|
||||
private readonly AbstractSaveToWord _word;
|
||||
private readonly AbstractSaveToPdf _pdf;
|
||||
private readonly AbstractMailWorker _mail;
|
||||
|
||||
public StoreKeeperData(ILogger<StoreKeeperData> logger, IStoreKeeperLogic StoreKeeperLogic,
|
||||
IServiceLogic serviceLogic, ILaborCostLogic laborCostLogic, ICosmeticLogic cosmeticLogic,
|
||||
IProcedureLogic procedureLogic, IOrderLogic orderLogic,
|
||||
AbstractSaveToExcel excel,
|
||||
AbstractSaveToWord word,
|
||||
AbstractMailWorker mail,
|
||||
AbstractSaveToPdf pdf)
|
||||
{
|
||||
_logger = logger;
|
||||
_StoreKeeperLogic = StoreKeeperLogic;
|
||||
_serviceLogic = serviceLogic;
|
||||
_laborCostLogic = laborCostLogic;
|
||||
_cosmeticLogic = cosmeticLogic;
|
||||
_procedureLogic = procedureLogic;
|
||||
_orderLogic = orderLogic;
|
||||
_excel = excel;
|
||||
_word = word;
|
||||
_mail = mail;
|
||||
_pdf = pdf;
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel? Login(string email, string password)
|
||||
{
|
||||
return _StoreKeeperLogic.ReadElement(new()
|
||||
{
|
||||
StoreKeeperEmail = email,
|
||||
StoreKeeperPassword = password
|
||||
});
|
||||
}
|
||||
public bool Register(StoreKeeperBindingModel model)
|
||||
{
|
||||
return _StoreKeeperLogic.Create(model);
|
||||
}
|
||||
public bool UpdateUser(StoreKeeperBindingModel model)
|
||||
{
|
||||
return _StoreKeeperLogic.Update(model);
|
||||
}
|
||||
|
||||
public List<ServiceViewModel>? GetServices(int userId)
|
||||
{
|
||||
return _serviceLogic.ReadList(new ServiceSearchModel() { StoreKeeperId = userId });
|
||||
}
|
||||
public bool DeleteService(int serviceId)
|
||||
{
|
||||
return _serviceLogic.Delete(new() { Id = serviceId });
|
||||
}
|
||||
public bool CreateService(ServiceBindingModel model)
|
||||
{
|
||||
return _serviceLogic.Create(model);
|
||||
}
|
||||
public bool UpdateService(ServiceBindingModel model)
|
||||
{
|
||||
return _serviceLogic.Update(model);
|
||||
}
|
||||
public ServiceViewModel? GetService(int id)
|
||||
{
|
||||
return _serviceLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public List<LaborCostViewModel>? GetLaborCosts(int userId)
|
||||
{
|
||||
return _laborCostLogic.ReadList(new LaborCostSearchModel() { StoreKeeperId = userId });
|
||||
}
|
||||
public bool DeleteLaborCost(int serviceId)
|
||||
{
|
||||
return _laborCostLogic.Delete(new() { Id = serviceId });
|
||||
}
|
||||
public bool CreateLaborCost(LaborCostBindingModel model)
|
||||
{
|
||||
return _laborCostLogic.Create(model);
|
||||
}
|
||||
public bool UpdateLaborCost(LaborCostBindingModel model)
|
||||
{
|
||||
return _laborCostLogic.Update(model);
|
||||
}
|
||||
public LaborCostViewModel? GetLaborCost(int id)
|
||||
{
|
||||
return _laborCostLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public List<CosmeticViewModel>? GetCosmetics(int userId)
|
||||
{
|
||||
return _cosmeticLogic.ReadList(new CosmeticSearchModel() { StoreKeeperId = userId });
|
||||
}
|
||||
public CosmeticViewModel? GetCosmetic(int id)
|
||||
{
|
||||
return _cosmeticLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public bool CreateCosmetic(CosmeticBindingModel model)
|
||||
{
|
||||
return _cosmeticLogic.Create(model);
|
||||
}
|
||||
public bool UpdateCosmetic(CosmeticBindingModel model)
|
||||
{
|
||||
return _cosmeticLogic.Update(model);
|
||||
}
|
||||
public bool DeleteCosmetic(int cosmeticId)
|
||||
{
|
||||
return _cosmeticLogic.Delete(new() { Id = cosmeticId });
|
||||
}
|
||||
public List<ProcedureViewModel>? GetProcedures()
|
||||
{
|
||||
return _procedureLogic.ReadList(null);
|
||||
}
|
||||
public List<OrderViewModel>? GetOrders()
|
||||
{
|
||||
return _orderLogic.ReadList(null);
|
||||
}
|
||||
|
||||
public List<ReportServicesViewModel> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
|
||||
{
|
||||
var services = _serviceLogic.ReadList(new() { DateCreate = startDate, DateComplete = endDate, StoreKeeperId = UserId });
|
||||
if (services == null)
|
||||
return new();
|
||||
List<ReportServicesViewModel> serviceTimeReports = new List<ReportServicesViewModel>();
|
||||
foreach (var service in services)
|
||||
{
|
||||
var report = new ReportServicesViewModel();
|
||||
report.Id = service.Id;
|
||||
|
||||
List<ProcedureViewModel> prs = new List<ProcedureViewModel>();
|
||||
HashSet<OrderViewModel> filteredOrders = new HashSet<OrderViewModel>();
|
||||
|
||||
var procedures = _procedureLogic.ReadList(null);//get all procedures
|
||||
var orders = _orderLogic.ReadList(null); //get all orders
|
||||
|
||||
foreach (var p in procedures)
|
||||
{
|
||||
foreach(var s in p.ProcedureServices)
|
||||
{
|
||||
if(s.Value.Id == service.Id)
|
||||
{
|
||||
prs.Add(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var o in orders)
|
||||
{
|
||||
foreach (var p in prs)
|
||||
{
|
||||
foreach (var op in o.OrderProcedures)
|
||||
{
|
||||
if(op.Value.Id == p.Id)
|
||||
{
|
||||
filteredOrders.Add(o); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<int> laborcosts = new HashSet<int>();
|
||||
var cosmetics = _cosmeticLogic.ReadList(null);
|
||||
|
||||
foreach(var c in cosmetics)
|
||||
{
|
||||
foreach(var s in c.CosmeticServices)
|
||||
{
|
||||
if(s.Value.Id == service.Id)
|
||||
{
|
||||
laborcosts.Add(c.LaborCostId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
report.Orders = filteredOrders.Select(w => w.Id.ToString()).ToList();
|
||||
foreach (int l in laborcosts)
|
||||
{
|
||||
report.LaborCosts.Add(l.ToString());
|
||||
}
|
||||
|
||||
serviceTimeReports.Add(report);
|
||||
}
|
||||
return serviceTimeReports;
|
||||
}
|
||||
|
||||
public List<ReportCosmeticViewModel>? GetProcedureReports(List<int> cosmetics)
|
||||
{
|
||||
List<ReportCosmeticViewModel> reports = new();
|
||||
foreach (int i in cosmetics)
|
||||
{
|
||||
ReportCosmeticViewModel report = new();
|
||||
var cosmetic = _cosmeticLogic.ReadElement(new() { Id = i });
|
||||
report.CosmeticName = cosmetic!.CosmeticName;
|
||||
var procedures = _procedureLogic.ReadList(null);
|
||||
|
||||
HashSet<ProcedureViewModel> filteredProcedures = new HashSet<ProcedureViewModel>();
|
||||
|
||||
if (cosmetic.CosmeticServices != null && procedures != null)
|
||||
{
|
||||
var servicesC = new HashSet<IServiceModel>(cosmetic.CosmeticServices.Values);
|
||||
|
||||
foreach (var procedure in procedures)
|
||||
{
|
||||
if (procedure.ProcedureServices != null)
|
||||
{
|
||||
var servicesP = new HashSet<IServiceModel>(procedure.ProcedureServices.Values);
|
||||
foreach (IServiceModel serv in servicesP)
|
||||
{
|
||||
foreach(IServiceModel s in servicesC)
|
||||
{
|
||||
if (s.Id == serv.Id)
|
||||
{
|
||||
filteredProcedures.Add(procedure);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
report.Procedures = filteredProcedures.Select(w => w.ProcedureName).ToList();
|
||||
reports.Add(report);
|
||||
}
|
||||
return reports;
|
||||
}
|
||||
|
||||
public void SaveReportExcel(List<int> services, MemoryStream stream)
|
||||
{
|
||||
var reports = GetProcedureReports(services);
|
||||
if (reports == null)
|
||||
return;
|
||||
int maxsize = 0;
|
||||
foreach (var report in reports) { maxsize = Math.Max(maxsize, report.Procedures.Count); }
|
||||
_excel.CreateReport(new()
|
||||
{
|
||||
cosmeticProceduresReport = reports,
|
||||
Title = "Отчет Косметика-Процедуры",
|
||||
memoryStream = stream,
|
||||
maxleng = maxsize
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveReportWord(List<int> services, MemoryStream stream)
|
||||
{
|
||||
var reports = GetProcedureReports(services);
|
||||
if (reports == null)
|
||||
return;
|
||||
_word.CreateDoc(new()
|
||||
{
|
||||
memoryStream = stream,
|
||||
Title = "Отчет. Косметика-Процедуры",
|
||||
cosmeticProceduresReport = reports
|
||||
});
|
||||
}
|
||||
|
||||
public void SendMailReport(DateTime? startDate, DateTime? endDate, int UserId, MemoryStream stream)
|
||||
{
|
||||
var reports = GetTimeReport(startDate, endDate, UserId);
|
||||
if (reports == null)
|
||||
return;
|
||||
_pdf.CreateReport(new()
|
||||
{
|
||||
DateFrom = startDate!.Value,
|
||||
DateTo = endDate!.Value,
|
||||
FileName = stream,
|
||||
Services = reports,
|
||||
Title = "Отчет"
|
||||
});
|
||||
byte[] report = stream.GetBuffer();
|
||||
_mail.MailSendAsync(new() { MailAddress = UserStoreKeeper.user!.StoreKeeperEmail, Subject = "Отчет", FileName = "PdfReport.pdf", Pdf = report });
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user