the end
This commit is contained in:
43
BeautySalon.sln
Normal file
43
BeautySalon.sln
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32328.378
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonBusinessLogic", "BeautySalonBusinessLogic\BeautySalonBusinessLogic.csproj", "{DF288075-9E10-490A-8350-CDACC7E16C05}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonContracts", "BeautySalonContracts\BeautySalonContracts.csproj", "{A336AACF-F956-4E0E-AC3A-4BB4FBB3D91C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonDatabaseImplement", "BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj", "{35F051AF-6597-49BA-B076-B6A6FDA9CBDF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonViewEmployee", "BeautySalonViewEmployee\BeautySalonViewEmployee.csproj", "{287AB6C5-775E-45AD-962B-293338AD341C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DF288075-9E10-490A-8350-CDACC7E16C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DF288075-9E10-490A-8350-CDACC7E16C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DF288075-9E10-490A-8350-CDACC7E16C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DF288075-9E10-490A-8350-CDACC7E16C05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A336AACF-F956-4E0E-AC3A-4BB4FBB3D91C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A336AACF-F956-4E0E-AC3A-4BB4FBB3D91C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A336AACF-F956-4E0E-AC3A-4BB4FBB3D91C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A336AACF-F956-4E0E-AC3A-4BB4FBB3D91C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{35F051AF-6597-49BA-B076-B6A6FDA9CBDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{35F051AF-6597-49BA-B076-B6A6FDA9CBDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{35F051AF-6597-49BA-B076-B6A6FDA9CBDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{35F051AF-6597-49BA-B076-B6A6FDA9CBDF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{287AB6C5-775E-45AD-962B-293338AD341C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{287AB6C5-775E-45AD-962B-293338AD341C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{287AB6C5-775E-45AD-962B-293338AD341C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{287AB6C5-775E-45AD-962B-293338AD341C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5CF2D911-E223-4C13-9D6F-6CDD28312591}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
16
BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj
Normal file
16
BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc" Version="1.50.5147" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
55
BeautySalonBusinessLogic/BusinessLogics/CosmeticLogic.cs
Normal file
55
BeautySalonBusinessLogic/BusinessLogics/CosmeticLogic.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CosmeticLogic : ICosmeticLogic
|
||||
{
|
||||
private readonly ICosmeticStorage _cosmeticStorage;
|
||||
public CosmeticLogic(ICosmeticStorage cosmeticStorage)
|
||||
{
|
||||
_cosmeticStorage = cosmeticStorage;
|
||||
}
|
||||
public List<CosmeticViewModel> Read(CosmeticBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _cosmeticStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<CosmeticViewModel> { _cosmeticStorage.GetElement(model) };
|
||||
}
|
||||
return _cosmeticStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(CosmeticBindingModel model)
|
||||
{
|
||||
var element = _cosmeticStorage.GetElement(new CosmeticBindingModel { CosmeticName = model.CosmeticName });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть косметика с таким названием");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_cosmeticStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_cosmeticStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(CosmeticBindingModel model)
|
||||
{
|
||||
var element = _cosmeticStorage.GetElement(new CosmeticBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Косметика не найдена");
|
||||
}
|
||||
_cosmeticStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
BeautySalonBusinessLogic/BusinessLogics/DistributionLogic.cs
Normal file
55
BeautySalonBusinessLogic/BusinessLogics/DistributionLogic.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class DistributionLogic : IDistributionLogic
|
||||
{
|
||||
private readonly IDistributionStorage _distributionStorage;
|
||||
public DistributionLogic(IDistributionStorage distributionStorage, IVisitStorage visitStorage)
|
||||
{
|
||||
_distributionStorage = distributionStorage;
|
||||
}
|
||||
public List<DistributionViewModel> Read(DistributionBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _distributionStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<DistributionViewModel> { _distributionStorage.GetElement(model) };
|
||||
}
|
||||
return _distributionStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(DistributionBindingModel model)
|
||||
{
|
||||
var element = _distributionStorage.GetElement(new DistributionBindingModel { IssueDate = model.IssueDate });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже произведена выдача в данное время");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_distributionStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_distributionStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(DistributionBindingModel model)
|
||||
{
|
||||
var element = _distributionStorage.GetElement(new DistributionBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Выдача не найдена");
|
||||
}
|
||||
_distributionStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
BeautySalonBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
59
BeautySalonBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
public EmployeeLogic(IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
public List<EmployeeViewModel> Read(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _employeeStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<EmployeeViewModel> { _employeeStorage.GetElement(model) };
|
||||
}
|
||||
return _employeeStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel
|
||||
{
|
||||
Login = model.Login,
|
||||
Email = model.Email,
|
||||
Id = model.Id
|
||||
});
|
||||
if (element != null) {
|
||||
throw new Exception("Уже есть сотрудник с такими данными (логин или e-mail уже заняты).");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_employeeStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_employeeStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
_employeeStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
BeautySalonBusinessLogic/BusinessLogics/ProcedureLogic.cs
Normal file
55
BeautySalonBusinessLogic/BusinessLogics/ProcedureLogic.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ProcedureLogic : IProcedureLogic
|
||||
{
|
||||
private readonly IProcedureStorage _procedureStorage;
|
||||
public ProcedureLogic(IProcedureStorage procedureStorage)
|
||||
{
|
||||
_procedureStorage = procedureStorage;
|
||||
}
|
||||
public List<ProcedureViewModel> Read(ProcedureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _procedureStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<ProcedureViewModel> { _procedureStorage.GetElement(model) };
|
||||
}
|
||||
return _procedureStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(ProcedureBindingModel model)
|
||||
{
|
||||
var element = _procedureStorage.GetElement(new ProcedureBindingModel { ProcedureName = model.ProcedureName });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть процедура с таким названием");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_procedureStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_procedureStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(ProcedureBindingModel model)
|
||||
{
|
||||
var element = _procedureStorage.GetElement(new ProcedureBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Процедура не найдена");
|
||||
}
|
||||
_procedureStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
BeautySalonBusinessLogic/BusinessLogics/PurchaseLogic.cs
Normal file
58
BeautySalonBusinessLogic/BusinessLogics/PurchaseLogic.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class PurchaseLogic : IPurchaseLogic
|
||||
{
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
private readonly IReceiptStorage _receiptStorage;
|
||||
|
||||
public PurchaseLogic(IPurchaseStorage purchaseStorage, IReceiptStorage receiptStorage)
|
||||
{
|
||||
_purchaseStorage = purchaseStorage;
|
||||
_receiptStorage = receiptStorage;
|
||||
}
|
||||
public List<PurchaseViewModel> Read(PurchaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _purchaseStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<PurchaseViewModel> { _purchaseStorage.GetElement(model) };
|
||||
}
|
||||
return _purchaseStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(PurchaseBindingModel model)
|
||||
{
|
||||
var element = _purchaseStorage.GetElement(new PurchaseBindingModel { Date = model.Date });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть покупка на это время");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_purchaseStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_purchaseStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(PurchaseBindingModel model)
|
||||
{
|
||||
var element = _purchaseStorage.GetElement(new PurchaseBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Покупка не найдена");
|
||||
}
|
||||
_purchaseStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
96
BeautySalonBusinessLogic/BusinessLogics/ReceiptLogic.cs
Normal file
96
BeautySalonBusinessLogic/BusinessLogics/ReceiptLogic.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReceiptLogic : IReceiptLogic
|
||||
{
|
||||
private readonly IReceiptStorage _receiptStorage;
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
public ReceiptLogic(IReceiptStorage receiptStorage, IPurchaseStorage purchaseStorage)
|
||||
{
|
||||
_receiptStorage = receiptStorage;
|
||||
_purchaseStorage = purchaseStorage;
|
||||
}
|
||||
public List<ReceiptViewModel> Read(ReceiptBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _receiptStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<ReceiptViewModel> { _receiptStorage.GetElement(model) };
|
||||
}
|
||||
return _receiptStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(ReceiptBindingModel model)
|
||||
{
|
||||
var element = _receiptStorage.GetElement(new ReceiptBindingModel { Date = model.Date });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже пробит чек в данное время");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_receiptStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_receiptStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(ReceiptBindingModel model)
|
||||
{
|
||||
var element = _receiptStorage.GetElement(new ReceiptBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Чек не найден");
|
||||
}
|
||||
_receiptStorage.Delete(model);
|
||||
}
|
||||
|
||||
public void Linking(ReceiptLinkingBindingModel model)
|
||||
{
|
||||
var receipt = _receiptStorage.GetElement(new ReceiptBindingModel
|
||||
{
|
||||
Id = model.ReceiptId
|
||||
});
|
||||
|
||||
var purchase = _purchaseStorage.GetElement(new PurchaseBindingModel
|
||||
{
|
||||
Id = model.PurchaseId
|
||||
});
|
||||
|
||||
if (receipt == null)
|
||||
{
|
||||
throw new Exception("Не найдена выдача");
|
||||
}
|
||||
|
||||
if (purchase == null)
|
||||
{
|
||||
throw new Exception("Не найдено посещение");
|
||||
}
|
||||
|
||||
if (receipt.PurchaseId.HasValue)
|
||||
{
|
||||
throw new Exception("Данная выдача уже привязана к посещению");
|
||||
}
|
||||
|
||||
_receiptStorage.Update(new ReceiptBindingModel
|
||||
{
|
||||
Id = receipt.Id,
|
||||
EmployeeId = receipt.EmployeeId,
|
||||
PurchaseId = model.PurchaseId,
|
||||
TotalCost = receipt.TotalCost,
|
||||
ReceiptCosmetics = receipt.ReceiptCosmetics,
|
||||
Date = receipt.Date,
|
||||
ReceiptPurchases = receipt.ReceiptPurchases
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
128
BeautySalonBusinessLogic/BusinessLogics/ReportEmployeeLogic.cs
Normal file
128
BeautySalonBusinessLogic/BusinessLogics/ReportEmployeeLogic.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using BeautySalonBusinessLogic.OfficePackage.Implements;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportEmployeeLogic : IReportEmployeeLogic
|
||||
{
|
||||
private readonly IReceiptStorage _receiptStorage;
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
private readonly IDistributionStorage _distributionStorage;
|
||||
private readonly IReportStorage _reportStorage;
|
||||
private readonly AbstractSaveToExcelEmployee _saveToExcel;
|
||||
private readonly AbstractSaveToWordEmployee _saveToWord;
|
||||
private readonly AbstractSaveToPdfEmployee _saveToPdf;
|
||||
|
||||
public ReportEmployeeLogic(
|
||||
IReceiptStorage receiptStorage, IPurchaseStorage purchaseStorage, IDistributionStorage distributionStorage, IReportStorage reportStorage,
|
||||
AbstractSaveToExcelEmployee saveToExcel, AbstractSaveToWordEmployee saveToWord, AbstractSaveToPdfEmployee saveToPdf)
|
||||
{
|
||||
_receiptStorage = receiptStorage;
|
||||
_purchaseStorage = purchaseStorage;
|
||||
_distributionStorage = distributionStorage;
|
||||
_reportStorage = reportStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
// Получение списка косметики, связанной с чеками и выдачей
|
||||
public List<ReportCosmeticsViewModel> GetCosmetics(ReportEmployeeBindingModel model)
|
||||
{
|
||||
var listAll = new List<ReportCosmeticsViewModel>();
|
||||
|
||||
var listReceipts = _receiptStorage.GetFilteredList(new ReceiptBindingModel { EmployeeId = model.EmployeeId, DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
foreach (var receipt in listReceipts)
|
||||
{
|
||||
foreach (var rec in receipt.ReceiptCosmetics)
|
||||
{
|
||||
listAll.Add(new ReportCosmeticsViewModel
|
||||
{
|
||||
TypeOfService = "Чек",
|
||||
DateOfService = receipt.Date,
|
||||
CosmeticName = rec.Value.Item1,
|
||||
Count = rec.Value.Item2
|
||||
});
|
||||
}
|
||||
}
|
||||
var listDistributions = _distributionStorage.GetFilteredList(new DistributionBindingModel { EmployeeId = model.EmployeeId, DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
foreach (var distribution in listDistributions)
|
||||
{
|
||||
foreach (var dp in distribution.DistributionCosmetics)
|
||||
{
|
||||
listAll.Add(new ReportCosmeticsViewModel
|
||||
{
|
||||
TypeOfService = "Выдача",
|
||||
DateOfService = distribution.IssueDate,
|
||||
CosmeticName = dp.Value.Item1,
|
||||
Count = dp.Value.Item2
|
||||
});
|
||||
}
|
||||
}
|
||||
return listAll;
|
||||
}
|
||||
|
||||
// Получение списка выдач по выбранным процедурам
|
||||
public List<ReportPurchaseCosmeticViewModel> GetPurchaseList(ReportEmployeeBindingModel model)
|
||||
{
|
||||
var list = new List<ReportPurchaseCosmeticViewModel>();
|
||||
decimal totalCost = 0;
|
||||
|
||||
foreach (var cosmetic in model.purchaseCosmetics)
|
||||
{
|
||||
list.AddRange(_reportStorage.GetPurchaseList(cosmetic));
|
||||
}
|
||||
|
||||
foreach (var reportPurchaseCosmetic in list)
|
||||
{
|
||||
totalCost += reportPurchaseCosmetic.Price * reportPurchaseCosmetic.Count;
|
||||
}
|
||||
|
||||
list[0].TotalCost = totalCost;
|
||||
return list;
|
||||
}
|
||||
|
||||
// Сохранение покупок в файл-Word
|
||||
public void SavePurchaseListToWordFile(ReportEmployeeBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfoEmployee
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Сведения по покупкам",
|
||||
PurchasesCosmetic = GetPurchaseList(model)
|
||||
});
|
||||
}
|
||||
|
||||
// Сохранение покупок в файл-Excel
|
||||
public void SavePurchaseListToExcelFile(ReportEmployeeBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoEmployee
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Сведения по покупкам",
|
||||
PurchasesCosmetic = GetPurchaseList(model)
|
||||
});
|
||||
}
|
||||
|
||||
/// Сохранение выдач в файл-Pdf
|
||||
public void SaveCosmeticsToPdfFile(ReportEmployeeBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoEmployee
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список процедур",
|
||||
DateFrom = model.DateFrom.Value,
|
||||
DateTo = model.DateTo.Value,
|
||||
Cosmetics = GetCosmetics(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
90
BeautySalonBusinessLogic/BusinessLogics/VisitLogic.cs
Normal file
90
BeautySalonBusinessLogic/BusinessLogics/VisitLogic.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonContracts.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class VisitLogic : IVisitLogic
|
||||
{
|
||||
private readonly IVisitStorage _visitStorage;
|
||||
|
||||
public VisitLogic(IVisitStorage visitStorage)
|
||||
{
|
||||
_visitStorage = visitStorage;
|
||||
}
|
||||
public List<VisitViewModel> Read(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _visitStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<VisitViewModel> { _visitStorage.GetElement(model) };
|
||||
}
|
||||
return _visitStorage.GetFilteredList(model);
|
||||
}
|
||||
public void CreateOrUpdate(VisitBindingModel model)
|
||||
{
|
||||
var element = _visitStorage.GetElement(new VisitBindingModel
|
||||
{
|
||||
Date = model.Date
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть посещение на это время");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_visitStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_visitStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(VisitBindingModel model)
|
||||
{
|
||||
var element = _visitStorage.GetElement(new VisitBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Посещение не найдено");
|
||||
}
|
||||
_visitStorage.Delete(model);
|
||||
}
|
||||
public List<DateTime> GetPickDate(VisitBindingModel model)
|
||||
{
|
||||
var list = _visitStorage.GetFilteredList(model);
|
||||
|
||||
List<DateTime> dateOfDay = new List<DateTime>();
|
||||
bool end = false;
|
||||
TimeVisit time = TimeVisit.ten;
|
||||
while (!end) // создали список посещений на этот день (потом их будем удалять если они совпадают с эл-ми list)
|
||||
{
|
||||
DateTime date = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, Convert.ToInt32(time), 0, 0);
|
||||
dateOfDay.Add(date);
|
||||
time++;
|
||||
if (time > TimeVisit.fourteen)
|
||||
{
|
||||
end = true;
|
||||
}
|
||||
}
|
||||
foreach (var item in list)
|
||||
{
|
||||
DateTime date = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, item.Date.Hour, 0, 0);
|
||||
if (dateOfDay.Contains(date))
|
||||
{
|
||||
dateOfDay.Remove(date);
|
||||
}
|
||||
}
|
||||
return dateOfDay;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcelEmployee
|
||||
{
|
||||
/// Создание отчета
|
||||
public void CreateReport(ExcelInfoEmployee info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
|
||||
// Заголовок
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
MergeCells(new ExcelMergeParameters { CellFromName = "A1", CellToName = "D1" });
|
||||
|
||||
uint row = 2;
|
||||
|
||||
// Группируем по дате
|
||||
var groups = info.PurchasesCosmetic
|
||||
.GroupBy(p => p.Date.Date)
|
||||
.OrderBy(g => g.Key);
|
||||
|
||||
foreach (var grp in groups)
|
||||
{
|
||||
// Вывести дату покупки
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = row,
|
||||
Text = grp.Key.ToString("dd.MM.yyyy HH:mm:ss"),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
row++;
|
||||
|
||||
decimal totalCost = 0;
|
||||
|
||||
// По каждой косметике в этой дате
|
||||
foreach (var item in grp)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = row,
|
||||
Text = item.CosmeticName,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = row,
|
||||
Text = item.Price.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "D",
|
||||
RowIndex = row,
|
||||
Text = item.Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
totalCost += item.Price * item.Count;
|
||||
row++;
|
||||
}
|
||||
|
||||
// Итог по дате
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = row,
|
||||
Text = "Итого:",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "D",
|
||||
RowIndex = row,
|
||||
Text = totalCost.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
row++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
// Создание excel-файла
|
||||
protected abstract void CreateExcel(ExcelInfoEmployee info);
|
||||
|
||||
// Добавляем новую ячейку в лист
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
|
||||
// Объединение ячеек
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
||||
// Сохранение файла
|
||||
protected abstract void SaveExcel(ExcelInfoEmployee info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfEmployee
|
||||
{
|
||||
public void CreateDoc(PdfInfoEmployee info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle"
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }",
|
||||
Style = "Normal"
|
||||
});
|
||||
CreateTable(new List<string> { "3cm", "3cm", "4cm", "3cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата выдачи косметики", "Косметика", "Количество", "Поручитель" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var cosmetic in info.Cosmetics)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { cosmetic.DateOfService.ToShortDateString(), cosmetic.CosmeticName, cosmetic.Count.ToString(), cosmetic.TypeOfService },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
// Создание doc-файла
|
||||
protected abstract void CreatePdf(PdfInfoEmployee info);
|
||||
|
||||
// Создание параграфа с текстом
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
|
||||
// Создание таблицы
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
|
||||
/// Создание и заполнение строки
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// Сохранение файла
|
||||
protected abstract void SavePdf(PdfInfoEmployee info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWordEmployee
|
||||
{
|
||||
// Создание документа
|
||||
public void CreateDoc(WordInfoEmployee info)
|
||||
{
|
||||
CreateWord(info);
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
foreach (var cosmetic in info.PurchasesCosmetic)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { ("Дата покупки " + cosmetic.Date.ToString(), new WordTextProperties {Bold = true, Size = "24"}),
|
||||
("Название косметики" + cosmetic.CosmeticName, new WordTextProperties {Bold = false, Size = "24"}),
|
||||
("Стоимость " + cosmetic.Price.ToString(), new WordTextProperties {Bold = false, Size = "24"}),
|
||||
("Количество " + cosmetic.Count.ToString(), new WordTextProperties { Bold = false, Size = "24" })},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
// Создание doc-файла
|
||||
protected abstract void CreateWord(WordInfoEmployee info);
|
||||
|
||||
// Создание абзаца с текстом
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
|
||||
// Сохранение файла
|
||||
protected abstract void SaveWord(WordInfoEmployee info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public string ColumnName { get; set; }
|
||||
public uint RowIndex { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoEmployee
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public List<ReportPurchaseCosmeticViewModel> PurchasesCosmetic { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; }
|
||||
public string CellToName { get; set; }
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfoEmployee
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public List<ReportCosmeticsViewModel> Cosmetics { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string Style { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; }
|
||||
public string Style { get; set; }
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfoEmployee
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public List<ReportPurchaseCosmeticViewModel> PurchasesCosmetic { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; }
|
||||
public WordTextProperties TextProperties { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; }
|
||||
public bool Bold { get; set; }
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using BeautySalonBusinessLogic.OfficePackage;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcelEmployee : AbstractSaveToExcelEmployee
|
||||
{
|
||||
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 };
|
||||
|
||||
var tableStyles = new TableStyles()
|
||||
{
|
||||
Count = 0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
var stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5 - 95BD - 54CBDDF9020C}"
|
||||
};
|
||||
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||
});
|
||||
var stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{9260A510-F301- 46a8 - 8635 - F512D64BE5F5}"
|
||||
};
|
||||
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||
});
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
/// Получение номера стиля из типа
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfoEmployee info)
|
||||
{
|
||||
_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>();
|
||||
|
||||
// Создаем SharedStringTable, если его нет
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
// Создаем лист в книгу
|
||||
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)
|
||||
{
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
|
||||
// Ищем строку, либо добавляем ее
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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(ExcelInfoEmployee info)
|
||||
{
|
||||
_spreadsheetDocument.WorkbookPart.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfEmployee : AbstractSaveToPdfEmployee
|
||||
{
|
||||
private Document _document;
|
||||
private Section _section;
|
||||
private Table _table;
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
||||
// Создание стилей для документа
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfoEmployee info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = ParagraphAlignment.Center;
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// Создание и заполнение строки
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void SavePdf(PdfInfoEmployee info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BeautySalonBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace BeautySalonBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWordEmployee : AbstractSaveToWordEmployee
|
||||
{
|
||||
private WordprocessingDocument _wordDocument;
|
||||
private Body _docBody;
|
||||
|
||||
// Получение типа выравнивания
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
// Настройки страницы
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
properties.AppendChild(pageSize);
|
||||
return properties;
|
||||
}
|
||||
|
||||
// Задание форматирования для абзаца
|
||||
private static ParagraphProperties CreateParagraphProperties(WordTextProperties paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties != null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected override void CreateWord(WordInfoEmployee info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (paragraph != null)
|
||||
{
|
||||
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 SaveWord(WordInfoEmployee info)
|
||||
{
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
7
BeautySalonContracts/BeautySalonContracts.csproj
Normal file
7
BeautySalonContracts/BeautySalonContracts.csproj
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
19
BeautySalonContracts/BindingModels/CosmeticBindingModel.cs
Normal file
19
BeautySalonContracts/BindingModels/CosmeticBindingModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class CosmeticBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? EmployeeId { get; set; }
|
||||
|
||||
public string CosmeticName { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class DistributionBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int? VisitId { get; set; }
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public DateTime IssueDate { get; set; }
|
||||
public Dictionary<int, (string, int)> DistributionCosmetics { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
20
BeautySalonContracts/BindingModels/EmployeeBindingModel.cs
Normal file
20
BeautySalonContracts/BindingModels/EmployeeBindingModel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string EmployeeName { get; set; }
|
||||
public string EmployeeSurname { get; set; }
|
||||
public string Patronymic { get; set; }
|
||||
public string Login { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/BindingModels/ProcedureBindingModel.cs
Normal file
17
BeautySalonContracts/BindingModels/ProcedureBindingModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class ProcedureBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string ProcedureName { get; set; }
|
||||
public string FIO_Master { get; set; }
|
||||
public int Duration { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
14
BeautySalonContracts/BindingModels/PurchaseBindingModel.cs
Normal file
14
BeautySalonContracts/BindingModels/PurchaseBindingModel.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class PurchaseBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
21
BeautySalonContracts/BindingModels/ReceiptBindingModel.cs
Normal file
21
BeautySalonContracts/BindingModels/ReceiptBindingModel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class ReceiptBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int? PurchaseId { get; set; }
|
||||
public decimal TotalCost { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public Dictionary<int, (string, int)> ReceiptCosmetics { get; set; }
|
||||
public Dictionary<int, decimal> ReceiptPurchases { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class ReceiptLinkingBindingModel
|
||||
{
|
||||
public int PurchaseId { get; set; }
|
||||
public int ReceiptId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class ReportEmployeeBindingModel
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public List<int> purchaseCosmetics { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class ReportPurchaseCosmeticBindingModel
|
||||
{
|
||||
public string CosmeticName { set; get; }
|
||||
}
|
||||
}
|
||||
16
BeautySalonContracts/BindingModels/VisitBindingModel.cs
Normal file
16
BeautySalonContracts/BindingModels/VisitBindingModel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.BindingModels
|
||||
{
|
||||
public class VisitBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICosmeticLogic
|
||||
{
|
||||
List<CosmeticViewModel> Read(CosmeticBindingModel model);
|
||||
void CreateOrUpdate(CosmeticBindingModel model);
|
||||
void Delete(CosmeticBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IDistributionLogic
|
||||
{
|
||||
List<DistributionViewModel> Read(DistributionBindingModel model);
|
||||
void CreateOrUpdate(DistributionBindingModel model);
|
||||
void Delete(DistributionBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel> Read(EmployeeBindingModel model);
|
||||
void CreateOrUpdate(EmployeeBindingModel model);
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IProcedureLogic
|
||||
{
|
||||
List<ProcedureViewModel> Read(ProcedureBindingModel model);
|
||||
void CreateOrUpdate(ProcedureBindingModel model);
|
||||
void Delete(ProcedureBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IPurchaseLogic
|
||||
{
|
||||
List<PurchaseViewModel> Read(PurchaseBindingModel model);
|
||||
void CreateOrUpdate(PurchaseBindingModel model);
|
||||
void Delete(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReceiptLogic
|
||||
{
|
||||
List<ReceiptViewModel> Read(ReceiptBindingModel model);
|
||||
void CreateOrUpdate(ReceiptBindingModel model);
|
||||
void Delete(ReceiptBindingModel model);
|
||||
void Linking(ReceiptLinkingBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportEmployeeLogic
|
||||
{
|
||||
//=========== Получение списка косметики за определенный период =============
|
||||
List<ReportCosmeticsViewModel> GetCosmetics(ReportEmployeeBindingModel model);
|
||||
|
||||
|
||||
//=========== Получение списка покупок клиентов по выбранной косметике ================
|
||||
List<ReportPurchaseCosmeticViewModel> GetPurchaseList(ReportEmployeeBindingModel model);
|
||||
|
||||
|
||||
//=========== Сохранение списка выдач в файл-Word===========
|
||||
public void SavePurchaseListToWordFile(ReportEmployeeBindingModel model);
|
||||
|
||||
|
||||
//=========== Сохранение списка выдач в файл-Excel===========
|
||||
public void SavePurchaseListToExcelFile(ReportEmployeeBindingModel model);
|
||||
|
||||
|
||||
// =========== Сохранение списка косметики в файл-Pdf===========
|
||||
public void SaveCosmeticsToPdfFile(ReportEmployeeBindingModel model);
|
||||
}
|
||||
}
|
||||
15
BeautySalonContracts/BusinessLogicsContracts/IVisitLogic.cs
Normal file
15
BeautySalonContracts/BusinessLogicsContracts/IVisitLogic.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IVisitLogic
|
||||
{
|
||||
List<VisitViewModel> Read(VisitBindingModel model);
|
||||
void CreateOrUpdate(VisitBindingModel model);
|
||||
void Delete(VisitBindingModel model);
|
||||
List<DateTime> GetPickDate(VisitBindingModel model);
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/Enums/TimeVisit.cs
Normal file
17
BeautySalonContracts/Enums/TimeVisit.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.Enums
|
||||
{
|
||||
public enum TimeVisit
|
||||
{
|
||||
ten = 10,
|
||||
eleven = 11,
|
||||
twelve = 12,
|
||||
thirteen = 13,
|
||||
fourteen = 14
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs
Normal file
17
BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface ICosmeticStorage
|
||||
{
|
||||
List<CosmeticViewModel> GetFullList();
|
||||
List<CosmeticViewModel> GetFilteredList(CosmeticBindingModel model);
|
||||
CosmeticViewModel GetElement(CosmeticBindingModel model);
|
||||
void Insert(CosmeticBindingModel model);
|
||||
void Update(CosmeticBindingModel model);
|
||||
void Delete(CosmeticBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IDistributionStorage
|
||||
{
|
||||
List<DistributionViewModel> GetFullList();
|
||||
List<DistributionViewModel> GetFilteredList(DistributionBindingModel model);
|
||||
DistributionViewModel GetElement(DistributionBindingModel model);
|
||||
void Insert(DistributionBindingModel model);
|
||||
void Update(DistributionBindingModel model);
|
||||
void Delete(DistributionBindingModel model);
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/StoragesContracts/IEmployeeStorage.cs
Normal file
17
BeautySalonContracts/StoragesContracts/IEmployeeStorage.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model);
|
||||
EmployeeViewModel GetElement(EmployeeBindingModel model);
|
||||
void Insert(EmployeeBindingModel model);
|
||||
void Update(EmployeeBindingModel model);
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/StoragesContracts/IProcedureStorage.cs
Normal file
17
BeautySalonContracts/StoragesContracts/IProcedureStorage.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IProcedureStorage
|
||||
{
|
||||
List<ProcedureViewModel> GetFullList();
|
||||
List<ProcedureViewModel> GetFilteredList(ProcedureBindingModel model);
|
||||
ProcedureViewModel GetElement(ProcedureBindingModel model);
|
||||
void Insert(ProcedureBindingModel model);
|
||||
void Update(ProcedureBindingModel model);
|
||||
void Delete(ProcedureBindingModel model);
|
||||
}
|
||||
}
|
||||
25
BeautySalonContracts/StoragesContracts/IPurchaseStorage.cs
Normal file
25
BeautySalonContracts/StoragesContracts/IPurchaseStorage.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IPurchaseStorage
|
||||
{
|
||||
List<PurchaseViewModel> GetFullList();
|
||||
|
||||
List<PurchaseViewModel> GetFilteredList(PurchaseBindingModel model);
|
||||
|
||||
PurchaseViewModel GetElement(PurchaseBindingModel model);
|
||||
|
||||
void Insert(PurchaseBindingModel model);
|
||||
|
||||
void Update(PurchaseBindingModel model);
|
||||
|
||||
void Delete(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
16
BeautySalonContracts/StoragesContracts/IReceiptStorage.cs
Normal file
16
BeautySalonContracts/StoragesContracts/IReceiptStorage.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IReceiptStorage
|
||||
{
|
||||
List<ReceiptViewModel> GetFullList();
|
||||
List<ReceiptViewModel> GetFilteredList(ReceiptBindingModel model);
|
||||
ReceiptViewModel GetElement(ReceiptBindingModel model);
|
||||
void Insert(ReceiptBindingModel model);
|
||||
void Update(ReceiptBindingModel model);
|
||||
void Delete(ReceiptBindingModel model);
|
||||
}
|
||||
}
|
||||
13
BeautySalonContracts/StoragesContracts/IReportStorage.cs
Normal file
13
BeautySalonContracts/StoragesContracts/IReportStorage.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IReportStorage
|
||||
{
|
||||
List<ReportPurchaseCosmeticViewModel> GetPurchaseList(int cosmeticId);
|
||||
|
||||
List<ReportCosmeticsViewModel> GetCosmetics(ReportEmployeeBindingModel model);
|
||||
}
|
||||
}
|
||||
17
BeautySalonContracts/StoragesContracts/IVisitStorage.cs
Normal file
17
BeautySalonContracts/StoragesContracts/IVisitStorage.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.StoragesContracts
|
||||
{
|
||||
public interface IVisitStorage
|
||||
{
|
||||
List<VisitViewModel> GetFullList();
|
||||
List<VisitViewModel> GetFilteredList(VisitBindingModel model);
|
||||
VisitViewModel GetElement(VisitBindingModel model);
|
||||
void Insert(VisitBindingModel model);
|
||||
void Update(VisitBindingModel model);
|
||||
void Delete(VisitBindingModel model);
|
||||
}
|
||||
}
|
||||
15
BeautySalonContracts/ViewModels/CosmeticViewModel.cs
Normal file
15
BeautySalonContracts/ViewModels/CosmeticViewModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class CosmeticViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("Название косметики")]
|
||||
public string CosmeticName { get; set; }
|
||||
[DisplayName("Цена")]
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class DataGridDistributionItemViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Косметика")]
|
||||
public string CosmeticName { get; set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class DataGridPurchaseListItemViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Косметика")]
|
||||
public string CosmeticName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class DataGridReceiptItemViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Косметика")]
|
||||
public string CosmeticName { get; set; }
|
||||
|
||||
[DisplayName("Стоимость")]
|
||||
public decimal? Price { get; set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
20
BeautySalonContracts/ViewModels/DistributionViewModel.cs
Normal file
20
BeautySalonContracts/ViewModels/DistributionViewModel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class DistributionViewModel
|
||||
{
|
||||
[DisplayName("Номер выдачи")]
|
||||
public int Id { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int? VisitId { get; set; }
|
||||
|
||||
public DateTime? VisitDate { get; set; }
|
||||
|
||||
[DisplayName("Дата выдачи")]
|
||||
public DateTime IssueDate { get; set; }
|
||||
public Dictionary<int, (string, int)> DistributionCosmetics { get; set; }
|
||||
}
|
||||
}
|
||||
23
BeautySalonContracts/ViewModels/EmployeeViewModel.cs
Normal file
23
BeautySalonContracts/ViewModels/EmployeeViewModel.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя")]
|
||||
public string EmployeeName { get; set; }
|
||||
[DisplayName("Фамилия")]
|
||||
public string EmployeeSurname { get; set; }
|
||||
[DisplayName("Отчество")]
|
||||
public string Patronymic { get; set; }
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; }
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; }
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; }
|
||||
[DisplayName("Сотовый телефон")]
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
||||
18
BeautySalonContracts/ViewModels/ProcedureViewModel.cs
Normal file
18
BeautySalonContracts/ViewModels/ProcedureViewModel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class ProcedureViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Название процедуры")]
|
||||
public string ProcedureName { get; set; }
|
||||
[DisplayName("ФИО мастера")]
|
||||
public string FIO_Master { get; set; }
|
||||
[DisplayName("Продолжительность")]
|
||||
public int Duration { get; set; }
|
||||
[DisplayName("Цена")]
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
21
BeautySalonContracts/ViewModels/PurchaseViewModel.cs
Normal file
21
BeautySalonContracts/ViewModels/PurchaseViewModel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class PurchaseViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Дата покупки")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[DisplayName("Цена: ")]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
30
BeautySalonContracts/ViewModels/ReceiptViewModel.cs
Normal file
30
BeautySalonContracts/ViewModels/ReceiptViewModel.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
public class ReceiptViewModel
|
||||
{
|
||||
[DisplayName("Номер чека")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int? PurchaseId { get; set; }
|
||||
|
||||
[DisplayName("Дата покупки")]
|
||||
public DateTime? PurchaseDate { get; set; }
|
||||
|
||||
[DisplayName("Общая стоимость")]
|
||||
public decimal TotalCost { get; set; }
|
||||
|
||||
[DisplayName("Дата чека")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public Dictionary<int, (string, int)> ReceiptCosmetics { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public Dictionary<int, decimal> ReceiptPurchases { get; set; }
|
||||
}
|
||||
12
BeautySalonContracts/ViewModels/ReportCosmeticsViewModel.cs
Normal file
12
BeautySalonContracts/ViewModels/ReportCosmeticsViewModel.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class ReportCosmeticsViewModel
|
||||
{
|
||||
public string TypeOfService { get; set; }
|
||||
public DateTime DateOfService { get; set; }
|
||||
public string CosmeticName { get; set; }
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class ReportPurchaseCosmeticViewModel
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string CosmeticName { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal TotalCost { get; set; }
|
||||
}
|
||||
}
|
||||
12
BeautySalonContracts/ViewModels/VisitViewModel.cs
Normal file
12
BeautySalonContracts/ViewModels/VisitViewModel.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonContracts.ViewModels
|
||||
{
|
||||
public class VisitViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
}
|
||||
30
BeautySalonDatabaseImplement/BeautySalonDatabase.cs
Normal file
30
BeautySalonDatabaseImplement/BeautySalonDatabase.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BeautySalonDatabaseImplement
|
||||
{
|
||||
internal class BeautySalonDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=KOMPUTER\SQLEXPRESS;Initial Catalog=BeautySalon;Integrated Security=True;MultipleActiveResultSets=True;");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Cosmetic> Cosmetics { set; get; }
|
||||
public virtual DbSet<Distribution> Distributions { set; get; }
|
||||
public virtual DbSet<DistributionCosmetic> DistributionCosmetics { set; get; }
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
public virtual DbSet<Receipt> Receipts { set; get; }
|
||||
public virtual DbSet<ReceiptCosmetic> ReceiptCosmetics { set; get; }
|
||||
public virtual DbSet<Purchase> Purchases { set; get; }
|
||||
public virtual DbSet<Procedure> Procedures { get; set; }
|
||||
public virtual DbSet<ProcedurePurchase> ProcedurePurchase { get; set; }
|
||||
public virtual DbSet<Visit> Visits { set; get; }
|
||||
public virtual DbSet<ProcedureVisit> ProcedureVisit { get; set; }
|
||||
public virtual DbSet<PurchaseReceipt> PurchaseReceipts { set; get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
113
BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs
Normal file
113
BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class CosmeticStorage : ICosmeticStorage
|
||||
{
|
||||
public List<CosmeticViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Cosmetics
|
||||
.Include(rec => rec.Employee)
|
||||
.Select(rec => new CosmeticViewModel
|
||||
{
|
||||
Id = rec.Id,
|
||||
CosmeticName = rec.CosmeticName,
|
||||
Price = rec.Price,
|
||||
EmployeeId = rec.EmployeeId
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
public List<CosmeticViewModel> GetFilteredList(CosmeticBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Cosmetics
|
||||
.Include(rec => rec.Employee)
|
||||
.Where(rec => rec.EmployeeId == model.EmployeeId || rec.CosmeticName.Contains(model.CosmeticName))
|
||||
.Select(rec => new CosmeticViewModel
|
||||
{
|
||||
Id = rec.Id,
|
||||
CosmeticName = rec.CosmeticName,
|
||||
Price = rec.Price,
|
||||
EmployeeId = rec.EmployeeId
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
public CosmeticViewModel GetElement(CosmeticBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
var cosmetic = context.Cosmetics
|
||||
.Include(rec => rec.Employee)
|
||||
.FirstOrDefault(rec => rec.CosmeticName == model.CosmeticName || rec.Id == model.Id);
|
||||
return cosmetic != null ?
|
||||
new CosmeticViewModel
|
||||
{
|
||||
Id = cosmetic.Id,
|
||||
CosmeticName = cosmetic.CosmeticName,
|
||||
Price = cosmetic.Price,
|
||||
EmployeeId = cosmetic.EmployeeId
|
||||
} :
|
||||
null;
|
||||
}
|
||||
public void Insert(CosmeticBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Cosmetics.Add(CreateModel(model, new Cosmetic()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Update(CosmeticBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Cosmetics.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Косметика не найдена");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Delete(CosmeticBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
Cosmetic element = context.Cosmetics.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Cosmetics.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Косметика не найдена");
|
||||
}
|
||||
}
|
||||
private static Cosmetic CreateModel(CosmeticBindingModel model, Cosmetic cosmetic)
|
||||
{
|
||||
cosmetic.CosmeticName = model.CosmeticName;
|
||||
cosmetic.Price = model.Price;
|
||||
cosmetic.EmployeeId = (int)model.EmployeeId;
|
||||
return cosmetic;
|
||||
}
|
||||
private Cosmetic CreateModel(Cosmetic cosmetic, CosmeticBindingModel model)
|
||||
{
|
||||
cosmetic.CosmeticName = model.CosmeticName;
|
||||
cosmetic.Price = model.Price;
|
||||
cosmetic.EmployeeId = (int)model.EmployeeId;
|
||||
return cosmetic;
|
||||
}
|
||||
}
|
||||
}
|
||||
338
BeautySalonDatabaseImplement/Implements/DatabaseSeeder.cs
Normal file
338
BeautySalonDatabaseImplement/Implements/DatabaseSeeder.cs
Normal file
@@ -0,0 +1,338 @@
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public static class DatabaseSeeder
|
||||
{
|
||||
public static IEnumerable<Procedure> LoadProceduresFromCsv(string path)
|
||||
{
|
||||
var list = new List<Procedure>();
|
||||
if (!File.Exists(path))
|
||||
return list;
|
||||
|
||||
foreach (var line in File.ReadAllLines(path)
|
||||
.Skip(1) // пропустить заголовок
|
||||
.Where(l => !string.IsNullOrWhiteSpace(l)))
|
||||
{
|
||||
// ожидаем: Name;FIO;Duration;Price
|
||||
var parts = line.Split(';');
|
||||
if (parts.Length != 4) continue;
|
||||
|
||||
if (int.TryParse(parts[2], out var duration)
|
||||
&& decimal.TryParse(parts[3], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var price))
|
||||
{
|
||||
list.Add(new Procedure
|
||||
{
|
||||
ProcedureName = parts[0].Trim(),
|
||||
FIO_Master = parts[1].Trim(),
|
||||
Duration = duration,
|
||||
Price = price
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public static IEnumerable<Purchase> LoadPurchasesFromCsv(string path)
|
||||
{
|
||||
var list = new List<Purchase>();
|
||||
if (!File.Exists(path))
|
||||
return list;
|
||||
|
||||
foreach (var line in File.ReadAllLines(path)
|
||||
.Skip(1)
|
||||
.Where(l => !string.IsNullOrWhiteSpace(l)))
|
||||
{
|
||||
// ожидаем: 2025-04-29;1500.50
|
||||
var parts = line.Split(';');
|
||||
if (parts.Length < 2) continue;
|
||||
|
||||
if (DateTime.TryParse(parts[0].Trim(), out var date)
|
||||
&& decimal.TryParse(parts[1].Trim(),
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands,
|
||||
CultureInfo.InvariantCulture,
|
||||
out var price))
|
||||
{
|
||||
list.Add(new Purchase
|
||||
{
|
||||
Date = date,
|
||||
Price = price
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public static IEnumerable<(string ProcedureName, DateTime PurchaseDate)> LoadProcedurePurchasesFromCsv(string path)
|
||||
{
|
||||
var list = new List<(string, DateTime)>();
|
||||
if (!File.Exists(path)) return list;
|
||||
|
||||
foreach (var line in File.ReadAllLines(path)
|
||||
.Skip(1)
|
||||
.Where(l => !string.IsNullOrWhiteSpace(l)))
|
||||
{
|
||||
var parts = line.Split(';');
|
||||
if (parts.Length < 2) continue;
|
||||
|
||||
var name = parts[0].Trim();
|
||||
if (DateTime.TryParse(parts[1].Trim(), out var date))
|
||||
{
|
||||
list.Add((name, date.Date));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static IEnumerable<Visit> LoadVisitsFromCsv(string path)
|
||||
{
|
||||
var list = new List<Visit>();
|
||||
if (!File.Exists(path)) return list;
|
||||
|
||||
foreach (var line in File.ReadAllLines(path)
|
||||
.Skip(1)
|
||||
.Where(l => !string.IsNullOrWhiteSpace(l)))
|
||||
{
|
||||
// формат: Date; например "2025-04-01 10:00"
|
||||
var parts = line.Split(';');
|
||||
if (parts.Length < 1) continue;
|
||||
|
||||
if (DateTime.TryParse(parts[0].Trim(), out var dt))
|
||||
{
|
||||
list.Add(new Visit { Date = dt });
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static IEnumerable<(string ProcedureName, DateTime VisitDate)> LoadProcedureVisitsFromCsv(string path)
|
||||
{
|
||||
var list = new List<(string, DateTime)>();
|
||||
if (!File.Exists(path)) return list;
|
||||
|
||||
foreach (var line in File.ReadAllLines(path)
|
||||
.Skip(1)
|
||||
.Where(l => !string.IsNullOrWhiteSpace(l)))
|
||||
{
|
||||
// формат: ProcedureName;VisitDate
|
||||
var p = line.Split(';');
|
||||
if (p.Length < 2) continue;
|
||||
var name = p[0].Trim();
|
||||
if (DateTime.TryParse(p[1].Trim(), out var dt))
|
||||
list.Add((name, dt.Date));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void SeedProcedures()
|
||||
{
|
||||
var path = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory,
|
||||
"seed",
|
||||
"procedures.csv"
|
||||
);
|
||||
var procedures = LoadProceduresFromCsv(path);
|
||||
if (!procedures.Any()) return;
|
||||
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
using var tx = ctx.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
// 0) Удаляем все связи "процедура ↔ посещение"
|
||||
var allProcVisits = ctx.Set<ProcedureVisit>().ToList();
|
||||
if (allProcVisits.Any())
|
||||
{
|
||||
ctx.Set<ProcedureVisit>().RemoveRange(allProcVisits);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 1) Удаляем все связи "процедура ↔ покупка"
|
||||
var allProcPurchases = ctx.Set<ProcedurePurchase>().ToList();
|
||||
if (allProcPurchases.Any())
|
||||
{
|
||||
ctx.Set<ProcedurePurchase>().RemoveRange(allProcPurchases);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 2) Удаляем сами процедуры
|
||||
var allProcs = ctx.Procedures.ToList();
|
||||
if (allProcs.Any())
|
||||
{
|
||||
ctx.Procedures.RemoveRange(allProcs);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 3) Засеваем их заново
|
||||
ctx.Procedures.AddRange(
|
||||
procedures.Select(p => new Procedure
|
||||
{
|
||||
// вот тут — именно те свойства, что есть в вашей модели:
|
||||
ProcedureName = p.ProcedureName,
|
||||
FIO_Master = p.FIO_Master,
|
||||
Duration = p.Duration,
|
||||
Price = p.Price
|
||||
})
|
||||
);
|
||||
ctx.SaveChanges();
|
||||
|
||||
tx.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tx.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static void SeedPurchases()
|
||||
{
|
||||
// путь к CSV-файлу
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "seed", "purchases.csv");
|
||||
var purchases = LoadPurchasesFromCsv(path);
|
||||
// если в файле нет данных — выходим
|
||||
if (!purchases.Any())
|
||||
return;
|
||||
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
// если в БД уже есть хоть одна покупка — выходим
|
||||
if (ctx.Purchases.Any())
|
||||
return;
|
||||
|
||||
// иначе — засеиваем все покупки из CSV
|
||||
ctx.Purchases.AddRange(purchases);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
public static void SeedProcedurePurchases()
|
||||
{
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "seed", "procedure_purchases.csv");
|
||||
var lines = File.Exists(path)
|
||||
? File.ReadAllLines(path).Skip(1).Where(l => !string.IsNullOrWhiteSpace(l))
|
||||
: Enumerable.Empty<string>();
|
||||
|
||||
var mappings = lines
|
||||
.Select(line => line.Split(';'))
|
||||
.Where(p => p.Length == 2)
|
||||
.Select(p => (
|
||||
ProcedureName: p[0].Trim(),
|
||||
PurchaseDate: DateTime.ParseExact(p[1].Trim(), "yyyy-MM-dd", null)))
|
||||
.ToList();
|
||||
|
||||
if (!mappings.Any()) return;
|
||||
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
|
||||
// Если родительских данных нет — выходим
|
||||
if (!ctx.Procedures.Any() || !ctx.Purchases.Any()) return;
|
||||
|
||||
// 1) Очистка старых связей
|
||||
var existing = ctx.ProcedurePurchase.ToList();
|
||||
if (existing.Any())
|
||||
{
|
||||
ctx.ProcedurePurchase.RemoveRange(existing);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 2) Собираем новые
|
||||
var toInsert = new List<ProcedurePurchase>();
|
||||
foreach (var m in mappings)
|
||||
{
|
||||
var proc = ctx.Procedures
|
||||
.FirstOrDefault(x => x.ProcedureName == m.ProcedureName);
|
||||
var purch = ctx.Purchases
|
||||
// сравниваем только по дате без времени
|
||||
.FirstOrDefault(x => x.Date.Date == m.PurchaseDate.Date);
|
||||
|
||||
if (proc != null && purch != null)
|
||||
{
|
||||
toInsert.Add(new ProcedurePurchase
|
||||
{
|
||||
ProcedureId = proc.Id,
|
||||
PurchaseId = purch.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (toInsert.Any())
|
||||
{
|
||||
ctx.ProcedurePurchase.AddRange(toInsert);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
}
|
||||
public static void SeedVisits()
|
||||
{
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "seed", "visits.csv");
|
||||
var visits = LoadVisitsFromCsv(path).ToList();
|
||||
if (!visits.Any()) return;
|
||||
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
|
||||
// 1) очистить сами связи ProcedureVisit, чтобы не мешали FK
|
||||
var allProcVisits = ctx.ProcedureVisit.ToList();
|
||||
if (allProcVisits.Any())
|
||||
{
|
||||
ctx.ProcedureVisit.RemoveRange(allProcVisits);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 2) очистить Visits
|
||||
var allVisits = ctx.Visits.ToList();
|
||||
if (allVisits.Any())
|
||||
{
|
||||
ctx.Visits.RemoveRange(allVisits);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 3) засеять Visits
|
||||
ctx.Visits.AddRange(visits);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
public static void SeedProcedureVisits()
|
||||
{
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "seed", "procedure_visits.csv");
|
||||
var mappings = LoadProcedureVisitsFromCsv(path).ToList();
|
||||
if (!mappings.Any()) return;
|
||||
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
|
||||
// Проверяем, что есть посещения и процедуры
|
||||
if (!ctx.Visits.Any() || !ctx.Procedures.Any()) return;
|
||||
|
||||
// 1) очищаем старые связи
|
||||
var existing = ctx.ProcedureVisit.ToList();
|
||||
if (existing.Any())
|
||||
{
|
||||
ctx.ProcedureVisit.RemoveRange(existing);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// 2) собираем новые связи
|
||||
var toInsert = new List<ProcedureVisit>();
|
||||
foreach (var (procName, visitDate) in mappings)
|
||||
{
|
||||
var proc = ctx.Procedures.FirstOrDefault(p => p.ProcedureName == procName);
|
||||
var visit = ctx.Visits.FirstOrDefault(v => v.Date.Date == visitDate.Date);
|
||||
if (proc != null && visit != null)
|
||||
{
|
||||
toInsert.Add(new ProcedureVisit
|
||||
{
|
||||
ProcedureId = proc.Id,
|
||||
VisitId = visit.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (toInsert.Any())
|
||||
{
|
||||
ctx.ProcedureVisit.AddRange(toInsert);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
175
BeautySalonDatabaseImplement/Implements/DistributionStorage.cs
Normal file
175
BeautySalonDatabaseImplement/Implements/DistributionStorage.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class DistributionStorage : IDistributionStorage
|
||||
{
|
||||
public List<DistributionViewModel> GetFullList()
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Distributions
|
||||
.Include(rec => rec.Employee)
|
||||
.Include(rec => rec.DistributionCosmetics)
|
||||
.ThenInclude(rec => rec.Cosmetic)
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public List<DistributionViewModel> GetFilteredList(DistributionBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Distributions
|
||||
.Include(rec => rec.Employee)
|
||||
.Include(rec => rec.DistributionCosmetics)
|
||||
.ThenInclude(rec => rec.Cosmetic)
|
||||
.Where(rec => (!model.DateFrom.HasValue && !model.DateTo.HasValue && rec.EmployeeId == model.EmployeeId) ||
|
||||
(model.DateFrom.HasValue && model.DateTo.HasValue && rec.EmployeeId == model.EmployeeId && rec.IssueDate.Date >= model.DateFrom.Value.Date && rec.IssueDate.Date <= model.DateTo.Value.Date))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public DistributionViewModel GetElement(DistributionBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
var distribution = context.Distributions
|
||||
.Include(rec => rec.Employee)
|
||||
.Include(rec => rec.DistributionCosmetics)
|
||||
.ThenInclude(rec => rec.Cosmetic)
|
||||
.FirstOrDefault(rec => rec.IssueDate == model.IssueDate || rec.Id == model.Id);
|
||||
return distribution != null ? CreateModel(distribution) : null;
|
||||
}
|
||||
}
|
||||
public void Insert(DistributionBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
using (var transaction = context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
Distribution distribution = new Distribution()
|
||||
{
|
||||
IssueDate = model.IssueDate,
|
||||
EmployeeId = (int)model.EmployeeId,
|
||||
};
|
||||
context.Distributions.Add(distribution);
|
||||
context.SaveChanges();
|
||||
CreateModel(model, distribution, context);
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Update(DistributionBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
using (var transaction = context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = context.Distributions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Выдача не найдена");
|
||||
}
|
||||
CreateModel(model, element, context);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Delete(DistributionBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
Distribution element = context.Distributions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Distributions.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Выдача не найдена");
|
||||
}
|
||||
}
|
||||
}
|
||||
private Distribution CreateModel(DistributionBindingModel model, Distribution distribution, BeautySalonDatabase context)
|
||||
{
|
||||
distribution.IssueDate = model.IssueDate;
|
||||
distribution.EmployeeId = (int)model.EmployeeId;
|
||||
|
||||
if (distribution.Id == 0)
|
||||
{
|
||||
context.Distributions.Add(distribution);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var distributionCosmetics = context.DistributionCosmetics.Where(rec => rec.DistributionId == model.Id.Value).ToList();
|
||||
context.DistributionCosmetics.RemoveRange(distributionCosmetics.Where(rec => !model.DistributionCosmetics.ContainsKey(rec.CosmeticId)).ToList());
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateCosmetic in distributionCosmetics)
|
||||
{
|
||||
updateCosmetic.Count = model.DistributionCosmetics[updateCosmetic.CosmeticId].Item2;
|
||||
model.DistributionCosmetics.Remove(updateCosmetic.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
foreach (var dc in model.DistributionCosmetics)
|
||||
{
|
||||
context.DistributionCosmetics.Add(new DistributionCosmetic
|
||||
{
|
||||
DistributionId = distribution.Id,
|
||||
CosmeticId = dc.Key,
|
||||
Count = dc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
return distribution;
|
||||
}
|
||||
private DistributionViewModel CreateModel(Distribution distribution)
|
||||
{
|
||||
return new DistributionViewModel
|
||||
{
|
||||
Id = distribution.Id,
|
||||
IssueDate = distribution.IssueDate,
|
||||
DistributionCosmetics = distribution.DistributionCosmetics
|
||||
.ToDictionary(recDC => recDC.CosmeticId, recDC => (recDC.Cosmetic?.CosmeticName, recDC.Count)),
|
||||
EmployeeId = distribution.EmployeeId,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
110
BeautySalonDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
110
BeautySalonDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Employees.Select(CreateModel).ToList();
|
||||
}
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Employees
|
||||
.Where(rec => rec.Login.Contains(model.Login) && rec.Password == model.Password)
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public EmployeeViewModel GetElement(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
using var context = new BeautySalonDatabase();
|
||||
// если пришёл только Id — ищем по Id
|
||||
if (model.Id.HasValue &&
|
||||
string.IsNullOrWhiteSpace(model.Login) &&
|
||||
string.IsNullOrWhiteSpace(model.Email))
|
||||
{
|
||||
var emp = context.Employees.FirstOrDefault(e => e.Id == model.Id.Value);
|
||||
return emp == null ? null : CreateModel(emp);
|
||||
}
|
||||
// иначе старая логика по Login/Email/Id для проверки дубликатов
|
||||
var employee = context.Employees
|
||||
.FirstOrDefault(e =>
|
||||
((model.Login != null && e.Login == model.Login)
|
||||
|| (model.Email != null && e.Email == model.Email))
|
||||
&& e.Id != model.Id);
|
||||
return employee == null ? null : CreateModel(employee);
|
||||
}
|
||||
|
||||
|
||||
public void Insert(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Employees.Add(CreateModel(model, new Employee()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
Employee element = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Employees.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
}
|
||||
private Employee CreateModel(EmployeeBindingModel model, Employee employee)
|
||||
{
|
||||
employee.EmployeeName = model.EmployeeName;
|
||||
employee.EmployeeSurname = model.EmployeeSurname;
|
||||
employee.Patronymic = model.Patronymic;
|
||||
employee.Login = model.Login;
|
||||
employee.Password = model.Password;
|
||||
employee.Email = model.Email;
|
||||
employee.Phone = model.Phone;
|
||||
return employee;
|
||||
}
|
||||
private static EmployeeViewModel CreateModel(Employee employee)
|
||||
{
|
||||
return new EmployeeViewModel
|
||||
{
|
||||
Id = employee.Id,
|
||||
EmployeeName = employee.EmployeeName,
|
||||
EmployeeSurname = employee.EmployeeSurname,
|
||||
Patronymic = employee.Patronymic,
|
||||
Login = employee.Login,
|
||||
Password = employee.Password,
|
||||
Email = employee.Email,
|
||||
Phone = employee.Phone
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
107
BeautySalonDatabaseImplement/Implements/ProcedureStorage.cs
Normal file
107
BeautySalonDatabaseImplement/Implements/ProcedureStorage.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class ProcedureStorage : IProcedureStorage
|
||||
{
|
||||
public List<ProcedureViewModel> GetFullList()
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Procedures
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public List<ProcedureViewModel> GetFilteredList(ProcedureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Procedures
|
||||
.Where(rec => rec.ProcedureName.Contains(model.ProcedureName))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public ProcedureViewModel GetElement(ProcedureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
var procedure = context.Procedures
|
||||
.Include(rec => rec.ProcedurePurchase)
|
||||
.ThenInclude(rec => rec.Purchase)
|
||||
.FirstOrDefault(rec => rec.ProcedureName == model.ProcedureName || rec.Id == model.Id);
|
||||
return procedure != null ? CreateModel(procedure) : null;
|
||||
}
|
||||
public void Insert(ProcedureBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
context.Procedures.Add(CreateModel(model, new Procedure()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
public void Update(ProcedureBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
var element = context.Procedures.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Процедура не найдена");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
public void Delete(ProcedureBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
Procedure element = context.Procedures.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Procedures.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Процедура не найдена");
|
||||
}
|
||||
}
|
||||
}
|
||||
private ProcedureViewModel CreateModel(Procedure procedure)
|
||||
{
|
||||
return new ProcedureViewModel
|
||||
{
|
||||
Id = procedure.Id,
|
||||
ProcedureName = procedure.ProcedureName,
|
||||
FIO_Master = procedure.FIO_Master,
|
||||
Duration = procedure.Duration,
|
||||
Price = procedure.Price,
|
||||
};
|
||||
}
|
||||
private Procedure CreateModel(ProcedureBindingModel model, Procedure procedure)
|
||||
{
|
||||
procedure.ProcedureName = model.ProcedureName;
|
||||
procedure.FIO_Master = model.FIO_Master;
|
||||
procedure.Price = model.Price;
|
||||
procedure.Duration = model.Duration;
|
||||
return procedure;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
BeautySalonDatabaseImplement/Implements/PurchaseStorage.cs
Normal file
109
BeautySalonDatabaseImplement/Implements/PurchaseStorage.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class PurchaseStorage : IPurchaseStorage
|
||||
{
|
||||
public List<PurchaseViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Purchases
|
||||
.Select(p => new PurchaseViewModel
|
||||
{
|
||||
Id = p.Id,
|
||||
Date = p.Date,
|
||||
Price = p.Price
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
using var context = new BeautySalonDatabase();
|
||||
var query = context.Purchases.AsQueryable();
|
||||
|
||||
if (model.Date != default)
|
||||
{
|
||||
// если пользователь указал конкретную дату
|
||||
query = query.Where(p => p.Date.Date == model.Date.Date);
|
||||
}
|
||||
else if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
// если указан диапазон
|
||||
query = query.Where(p =>
|
||||
p.Date.Date >= model.DateFrom.Value.Date &&
|
||||
p.Date.Date <= model.DateTo.Value.Date);
|
||||
}
|
||||
|
||||
return query
|
||||
.Select(p => new PurchaseViewModel
|
||||
{
|
||||
Id = p.Id,
|
||||
Date = p.Date,
|
||||
Price = p.Price
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PurchaseViewModel GetElement(PurchaseBindingModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
using var context = new BeautySalonDatabase();
|
||||
var p = context.Purchases.FirstOrDefault(x => x.Id == model.Id.Value);
|
||||
if (p == null) return null;
|
||||
|
||||
return new PurchaseViewModel
|
||||
{
|
||||
Id = p.Id,
|
||||
Date = p.Date,
|
||||
Price = p.Price
|
||||
};
|
||||
}
|
||||
|
||||
public void Insert(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var entity = new Purchase
|
||||
{
|
||||
Date = model.Date,
|
||||
Price = model.Price
|
||||
};
|
||||
context.Purchases.Add(entity);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Update(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var entity = context.Purchases.Find(model.Id.Value);
|
||||
if (entity == null)
|
||||
throw new Exception("Покупка не найдена");
|
||||
|
||||
entity.Date = model.Date;
|
||||
entity.Price = model.Price;
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Delete(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var entity = context.Purchases.Find(model.Id.Value);
|
||||
if (entity == null)
|
||||
throw new Exception("Покупка не найдена");
|
||||
|
||||
context.Purchases.Remove(entity);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
210
BeautySalonDatabaseImplement/Implements/ReceiptStorage.cs
Normal file
210
BeautySalonDatabaseImplement/Implements/ReceiptStorage.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class ReceiptStorage : IReceiptStorage
|
||||
{
|
||||
public List<ReceiptViewModel> GetFullList()
|
||||
{
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
|
||||
// 1) сначала получаем чистые EF-модели в память
|
||||
var receipts = ctx.Receipts
|
||||
.Include(r => r.Employee)
|
||||
.Include(r => r.Purchase)
|
||||
.Include(r => r.ReceiptCosmetics)
|
||||
.ThenInclude(rc => rc.Cosmetic)
|
||||
.ToList(); // <--- вот тут мы вынимаем всё из SQL
|
||||
|
||||
// 2) теперь мапим их уже чисто на C#-стороне
|
||||
return receipts
|
||||
.Select(r => MapToViewModel(r))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ReceiptViewModel> GetFilteredList(ReceiptBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
|
||||
var query = ctx.Receipts
|
||||
.Include(r => r.Employee)
|
||||
.Include(r => r.Purchase)
|
||||
.Include(r => r.ReceiptCosmetics)
|
||||
.ThenInclude(rc => rc.Cosmetic)
|
||||
.AsQueryable();
|
||||
|
||||
query = query.Where(r =>
|
||||
r.EmployeeId == model.EmployeeId &&
|
||||
(
|
||||
!model.DateFrom.HasValue && !model.DateTo.HasValue
|
||||
? true
|
||||
: r.Date.Date >= model.DateFrom.Value.Date && r.Date.Date <= model.DateTo.Value.Date
|
||||
)
|
||||
);
|
||||
|
||||
// 1) сначала materialize
|
||||
var filtered = query.ToList();
|
||||
|
||||
// 2) уже на C# мапим в VM
|
||||
return filtered
|
||||
.Select(r => MapToViewModel(r))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
public ReceiptViewModel GetElement(ReceiptBindingModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue) return null;
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
var r = ctx.Receipts
|
||||
.Include(r => r.Employee)
|
||||
.Include(r => r.Purchase)
|
||||
.Include(r => r.ReceiptCosmetics)
|
||||
.ThenInclude(rc => rc.Cosmetic)
|
||||
.FirstOrDefault(r => r.Id == model.Id.Value);
|
||||
return r == null ? null : MapToViewModel(r);
|
||||
}
|
||||
|
||||
public void Insert(ReceiptBindingModel model)
|
||||
{
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
using var tx = ctx.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
// 1) создаём сам чек
|
||||
var receipt = new Receipt
|
||||
{
|
||||
EmployeeId = (int)model.EmployeeId,
|
||||
PurchaseId = model.PurchaseId,
|
||||
TotalCost = model.TotalCost,
|
||||
Date = model.Date
|
||||
};
|
||||
ctx.Receipts.Add(receipt);
|
||||
ctx.SaveChanges();
|
||||
|
||||
// 2) привязываем косметику
|
||||
if (model.ReceiptCosmetics != null)
|
||||
{
|
||||
foreach (var kv in model.ReceiptCosmetics)
|
||||
{
|
||||
ctx.ReceiptCosmetics.Add(new ReceiptCosmetic
|
||||
{
|
||||
ReceiptId = receipt.Id,
|
||||
CosmeticId = kv.Key,
|
||||
Count = kv.Value.Item2
|
||||
});
|
||||
}
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
tx.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tx.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(ReceiptBindingModel model)
|
||||
{
|
||||
if (!model.Id.HasValue) throw new ArgumentException("Укажите Id для обновления");
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
using var tx = ctx.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var receipt = ctx.Receipts
|
||||
.Include(r => r.ReceiptCosmetics)
|
||||
.FirstOrDefault(r => r.Id == model.Id.Value);
|
||||
if (receipt == null)
|
||||
throw new Exception("Чек не найден");
|
||||
|
||||
// обновляем сам чек
|
||||
receipt.EmployeeId = (int)model.EmployeeId;
|
||||
receipt.PurchaseId = model.PurchaseId;
|
||||
receipt.TotalCost = model.TotalCost;
|
||||
receipt.Date = model.Date;
|
||||
ctx.SaveChanges();
|
||||
|
||||
// удаляем старые косметики, которых нет в модели
|
||||
var toRemove = receipt.ReceiptCosmetics
|
||||
.Where(rc => !model.ReceiptCosmetics.ContainsKey(rc.CosmeticId))
|
||||
.ToList();
|
||||
ctx.ReceiptCosmetics.RemoveRange(toRemove);
|
||||
ctx.SaveChanges();
|
||||
|
||||
// обновляем существующие
|
||||
foreach (var rc in receipt.ReceiptCosmetics)
|
||||
rc.Count = model.ReceiptCosmetics[rc.CosmeticId].Item2;
|
||||
ctx.SaveChanges();
|
||||
|
||||
// добавляем новые
|
||||
var existIds = receipt.ReceiptCosmetics.Select(rc => rc.CosmeticId).ToHashSet();
|
||||
var toAdd = model.ReceiptCosmetics
|
||||
.Where(kv => !existIds.Contains(kv.Key))
|
||||
.Select(kv => new ReceiptCosmetic
|
||||
{
|
||||
ReceiptId = receipt.Id,
|
||||
CosmeticId = kv.Key,
|
||||
Count = kv.Value.Item2
|
||||
});
|
||||
ctx.ReceiptCosmetics.AddRange(toAdd);
|
||||
ctx.SaveChanges();
|
||||
|
||||
tx.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tx.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(ReceiptBindingModel model)
|
||||
{
|
||||
if (!model.Id.HasValue) throw new ArgumentException("Укажите Id для удаления");
|
||||
using var ctx = new BeautySalonDatabase();
|
||||
var receipt = ctx.Receipts
|
||||
.Include(r => r.ReceiptCosmetics)
|
||||
.FirstOrDefault(r => r.Id == model.Id.Value);
|
||||
if (receipt == null)
|
||||
throw new Exception("Чек не найден");
|
||||
|
||||
// удаляем косметики
|
||||
ctx.ReceiptCosmetics.RemoveRange(receipt.ReceiptCosmetics);
|
||||
ctx.SaveChanges();
|
||||
|
||||
// удаляем чек
|
||||
ctx.Receipts.Remove(receipt);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
// вспомогательный маппер
|
||||
private ReceiptViewModel MapToViewModel(Receipt r)
|
||||
{
|
||||
return new ReceiptViewModel
|
||||
{
|
||||
Id = r.Id,
|
||||
EmployeeId = r.EmployeeId,
|
||||
PurchaseId = r.PurchaseId,
|
||||
|
||||
PurchaseDate = r.Purchase?.Date,
|
||||
|
||||
TotalCost = r.TotalCost,
|
||||
Date = r.Date,
|
||||
ReceiptCosmetics = r.ReceiptCosmetics
|
||||
.ToDictionary(rc => rc.CosmeticId,
|
||||
rc => (rc.Cosmetic?.CosmeticName, rc.Count))
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
80
BeautySalonDatabaseImplement/Implements/ReportStorage.cs
Normal file
80
BeautySalonDatabaseImplement/Implements/ReportStorage.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class ReportStorage : IReportStorage
|
||||
{
|
||||
public List<ReportCosmeticsViewModel> GetCosmetics(ReportEmployeeBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return (
|
||||
from c in context.Cosmetics
|
||||
join rc in context.ReceiptCosmetics on c.Id equals rc.CosmeticId
|
||||
join r in context.Receipts on rc.ReceiptId equals r.Id
|
||||
where r.EmployeeId == model.EmployeeId
|
||||
where r.Date >= model.DateFrom
|
||||
where r.Date <= model.DateTo
|
||||
select new ReportCosmeticsViewModel
|
||||
{
|
||||
TypeOfService = "Чек",
|
||||
DateOfService = r.Date,
|
||||
CosmeticName = c.CosmeticName,
|
||||
Count = rc.Count
|
||||
})
|
||||
.Union(
|
||||
from c in context.Cosmetics
|
||||
join dc in context.DistributionCosmetics on c.Id equals dc.CosmeticId
|
||||
join d in context.Distributions on dc.DistributionId equals d.Id
|
||||
where d.EmployeeId == model.EmployeeId
|
||||
where d.IssueDate >= model.DateFrom
|
||||
where d.IssueDate <= model.DateTo
|
||||
select new ReportCosmeticsViewModel
|
||||
{
|
||||
TypeOfService = "Выдача",
|
||||
DateOfService = d.IssueDate,
|
||||
CosmeticName = c.CosmeticName,
|
||||
Count = dc.Count
|
||||
})
|
||||
.OrderBy(x => x.DateOfService)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ReportPurchaseCosmeticViewModel> GetPurchaseList(int cosmeticId)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
// Для каждой записи ReceiptCosmetic находим чек (r),
|
||||
// у чека берём связанную покупку (r.Purchase),
|
||||
// и формируем отчётную строку.
|
||||
var query =
|
||||
from rc in context.ReceiptCosmetics
|
||||
where rc.CosmeticId == cosmeticId
|
||||
let r = rc.Receipt
|
||||
let p = r.Purchase
|
||||
where p != null // на всякий случай
|
||||
select new ReportPurchaseCosmeticViewModel
|
||||
{
|
||||
CosmeticName = rc.Cosmetic.CosmeticName,
|
||||
Price = rc.Cosmetic.Price, // оставляем цену косметики
|
||||
Date = p.Date, // теперь дата именно из Purchase
|
||||
Count = rc.Count
|
||||
};
|
||||
|
||||
return query
|
||||
.OrderBy(x => x.Date)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
140
BeautySalonDatabaseImplement/Implements/VisitStorage.cs
Normal file
140
BeautySalonDatabaseImplement/Implements/VisitStorage.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class VisitStorage : IVisitStorage
|
||||
{
|
||||
public List<VisitViewModel> GetFullList()
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Visits
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredList(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
return context.Visits
|
||||
.Where(rec => (!model.DateFrom.HasValue && !model.DateTo.HasValue && rec.Date == model.Date) ||
|
||||
(model.DateFrom.HasValue && model.DateTo.HasValue && (rec.Date.Date >= model.DateFrom.Value.Date && rec.Date.Date <= model.DateTo.Value.Date)))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public VisitViewModel GetElement(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
var visit = context.Visits
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
return visit != null ? CreateModel(visit) : null;
|
||||
}
|
||||
}
|
||||
public void Insert(VisitBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
Visit visit = new Visit()
|
||||
{
|
||||
Date = model.Date,
|
||||
};
|
||||
context.Visits.Add(visit);
|
||||
context.SaveChanges();
|
||||
context.Visits.Add(CreateModel(model, visit, context));
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(VisitBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
using (var transaction = context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = context.Visits.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Посещение не найдено");
|
||||
}
|
||||
CreateModel(model, element, context);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Delete(VisitBindingModel model)
|
||||
{
|
||||
using (var context = new BeautySalonDatabase())
|
||||
{
|
||||
Visit element = context.Visits.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Visits.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Посещение не найдено");
|
||||
}
|
||||
}
|
||||
}
|
||||
private Visit CreateModel(VisitBindingModel model, Visit visit, BeautySalonDatabase context)
|
||||
{
|
||||
visit.Date = model.Date;
|
||||
|
||||
if (model.Id.HasValue && visit.Id != 0)
|
||||
{
|
||||
context.Visits.Update(visit);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Visits.Add(visit);
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
return visit;
|
||||
}
|
||||
|
||||
private VisitViewModel CreateModel(Visit visit)
|
||||
{
|
||||
return new VisitViewModel
|
||||
{
|
||||
Id = visit.Id,
|
||||
Date = visit.Date,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
383
BeautySalonDatabaseImplement/Migrations/20250429081548_InitialCreate.Designer.cs
generated
Normal file
383
BeautySalonDatabaseImplement/Migrations/20250429081548_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,383 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20250429081548_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int?>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Distributions")
|
||||
.HasForeignKey("VisitId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ReceiptId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Distributions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EmployeeName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
EmployeeSurname = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Patronymic = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EmployeeId = table.Column<int>(type: "int", nullable: false),
|
||||
CosmeticName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cosmetics_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Receipts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EmployeeId = table.Column<int>(type: "int", nullable: false),
|
||||
TotalCost = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Receipts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Receipts_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Distributions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EmployeeId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(type: "int", nullable: true),
|
||||
IssueDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Distributions", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Distributions_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Distributions_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ReceiptId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Receipts_ReceiptId",
|
||||
column: x => x.ReceiptId,
|
||||
principalTable: "Receipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ReceiptCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ReceiptId = table.Column<int>(type: "int", nullable: false),
|
||||
CosmeticId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ReceiptCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ReceiptCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ReceiptCosmetics_Receipts_ReceiptId",
|
||||
column: x => x.ReceiptId,
|
||||
principalTable: "Receipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DistributionCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DistributionId = table.Column<int>(type: "int", nullable: false),
|
||||
CosmeticId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DistributionCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_DistributionCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_DistributionCosmetics_Distributions_DistributionId",
|
||||
column: x => x.DistributionId,
|
||||
principalTable: "Distributions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseReceipts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PurchaseId = table.Column<int>(type: "int", nullable: false),
|
||||
ReceiptId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseReceipts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseReceipts_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseReceipts_Receipts_ReceiptId",
|
||||
column: x => x.ReceiptId,
|
||||
principalTable: "Receipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cosmetics_EmployeeId",
|
||||
table: "Cosmetics",
|
||||
column: "EmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DistributionCosmetics_CosmeticId",
|
||||
table: "DistributionCosmetics",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DistributionCosmetics_DistributionId",
|
||||
table: "DistributionCosmetics",
|
||||
column: "DistributionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Distributions_EmployeeId",
|
||||
table: "Distributions",
|
||||
column: "EmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Distributions_VisitId",
|
||||
table: "Distributions",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseReceipts_PurchaseId",
|
||||
table: "PurchaseReceipts",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseReceipts_ReceiptId",
|
||||
table: "PurchaseReceipts",
|
||||
column: "ReceiptId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ReceiptId",
|
||||
table: "Purchases",
|
||||
column: "ReceiptId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ReceiptCosmetics_CosmeticId",
|
||||
table: "ReceiptCosmetics",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ReceiptCosmetics_ReceiptId",
|
||||
table: "ReceiptCosmetics",
|
||||
column: "ReceiptId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Receipts_EmployeeId",
|
||||
table: "Receipts",
|
||||
column: "EmployeeId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "DistributionCosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseReceipts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ReceiptCosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Distributions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Receipts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
}
|
||||
}
|
||||
}
|
||||
501
BeautySalonDatabaseImplement/Migrations/20250429124343_AddProcedures.Designer.cs
generated
Normal file
501
BeautySalonDatabaseImplement/Migrations/20250429124343_AddProcedures.Designer.cs
generated
Normal file
@@ -0,0 +1,501 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20250429124343_AddProcedures")]
|
||||
partial class AddProcedures
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FIO_Master")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("ProcedureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("ProcedurePurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int?>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Distributions")
|
||||
.HasForeignKey("VisitId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedurePurchase")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedureVisit")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ReceiptId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("ProcedurePurchase");
|
||||
|
||||
b.Navigation("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Distributions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class AddProcedures : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Procedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ProcedureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
FIO_Master = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Duration = table.Column<int>(type: "int", nullable: false),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProcedurePurchase",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProcedureId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProcedurePurchase", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedurePurchase_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedurePurchase_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProcedureVisit",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProcedureId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProcedureVisit", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureVisit_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureVisit_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedurePurchase_ProcedureId",
|
||||
table: "ProcedurePurchase",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedurePurchase_PurchaseId",
|
||||
table: "ProcedurePurchase",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureVisit_ProcedureId",
|
||||
table: "ProcedureVisit",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureVisit_VisitId",
|
||||
table: "ProcedureVisit",
|
||||
column: "VisitId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProcedurePurchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProcedureVisit");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Procedures");
|
||||
}
|
||||
}
|
||||
}
|
||||
498
BeautySalonDatabaseImplement/Migrations/20250429130528_RemoveClientIdFromProcedures.Designer.cs
generated
Normal file
498
BeautySalonDatabaseImplement/Migrations/20250429130528_RemoveClientIdFromProcedures.Designer.cs
generated
Normal file
@@ -0,0 +1,498 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20250429130528_RemoveClientIdFromProcedures")]
|
||||
partial class RemoveClientIdFromProcedures
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FIO_Master")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("ProcedureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("ProcedurePurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int?>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Distributions")
|
||||
.HasForeignKey("VisitId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedurePurchase")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedureVisit")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ReceiptId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("ProcedurePurchase");
|
||||
|
||||
b.Navigation("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Distributions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class RemoveClientIdFromProcedures : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Procedures");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Procedures",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
482
BeautySalonDatabaseImplement/Migrations/20250429165230_RemoveVisitDistribution.Designer.cs
generated
Normal file
482
BeautySalonDatabaseImplement/Migrations/20250429165230_RemoveVisitDistribution.Designer.cs
generated
Normal file
@@ -0,0 +1,482 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20250429165230_RemoveVisitDistribution")]
|
||||
partial class RemoveVisitDistribution
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FIO_Master")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("ProcedureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("ProcedurePurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int?>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedurePurchase")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedureVisit")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ReceiptId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("ProcedurePurchase");
|
||||
|
||||
b.Navigation("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class RemoveVisitDistribution : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Distributions_Visits_VisitId",
|
||||
table: "Distributions");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Distributions_VisitId",
|
||||
table: "Distributions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VisitId",
|
||||
table: "Distributions");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "VisitId",
|
||||
table: "Distributions",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Distributions_VisitId",
|
||||
table: "Distributions",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Distributions_Visits_VisitId",
|
||||
table: "Distributions",
|
||||
column: "VisitId",
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
||||
479
BeautySalonDatabaseImplement/Migrations/20250429173330_AddPurchaseIdToReceipt.Designer.cs
generated
Normal file
479
BeautySalonDatabaseImplement/Migrations/20250429173330_AddPurchaseIdToReceipt.Designer.cs
generated
Normal file
@@ -0,0 +1,479 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20250429173330_AddPurchaseIdToReceipt")]
|
||||
partial class AddPurchaseIdToReceipt
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FIO_Master")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("ProcedureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("ProcedurePurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedurePurchase")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedureVisit")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("ProcedurePurchase");
|
||||
|
||||
b.Navigation("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class AddPurchaseIdToReceipt : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Purchases_Receipts_ReceiptId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Purchases_ReceiptId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ReceiptId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PurchaseId",
|
||||
table: "Receipts",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Receipts_PurchaseId",
|
||||
table: "Receipts",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Receipts_Purchases_PurchaseId",
|
||||
table: "Receipts",
|
||||
column: "PurchaseId",
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Receipts_Purchases_PurchaseId",
|
||||
table: "Receipts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Receipts_PurchaseId",
|
||||
table: "Receipts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PurchaseId",
|
||||
table: "Receipts");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ReceiptId",
|
||||
table: "Purchases",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ReceiptId",
|
||||
table: "Purchases",
|
||||
column: "ReceiptId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Purchases_Receipts_ReceiptId",
|
||||
table: "Purchases",
|
||||
column: "ReceiptId",
|
||||
principalTable: "Receipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
partial class BeautySalonDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseIdentityColumns()
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.0");
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("CosmeticName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("IssueDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Distributions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DistributionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("DistributionId");
|
||||
|
||||
b.ToTable("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EmployeeSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FIO_Master")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("ProcedureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("ProcedurePurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("PurchaseReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotalCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.UseIdentityColumn();
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Cosmetic")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Distribution")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.DistributionCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Distribution", "Distribution")
|
||||
.WithMany("DistributionCosmetics")
|
||||
.HasForeignKey("DistributionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedurePurchase", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedurePurchase")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureVisit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("ProcedureVisit")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.PurchaseReceipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptPurcheses")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Purchase");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Receipt")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchaseId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ReceiptCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany("ReceiptCosmetics")
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Distribution", b =>
|
||||
{
|
||||
b.Navigation("DistributionCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Distribution");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("ProcedurePurchase");
|
||||
|
||||
b.Navigation("ProcedureVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Navigation("ReceiptCosmetics");
|
||||
|
||||
b.Navigation("ReceiptPurcheses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
28
BeautySalonDatabaseImplement/Models/Cosmetic.cs
Normal file
28
BeautySalonDatabaseImplement/Models/Cosmetic.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Cosmetic
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CosmeticName { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public virtual Employee Employee { get; set; }
|
||||
|
||||
[ForeignKey("CosmeticId")]
|
||||
public virtual List<ReceiptCosmetic> ReceiptCosmetics { get; set; }
|
||||
|
||||
[ForeignKey("CosmeticId")]
|
||||
public virtual List<DistributionCosmetic> DistributionCosmetics { get; set; }
|
||||
}
|
||||
}
|
||||
20
BeautySalonDatabaseImplement/Models/Distribution.cs
Normal file
20
BeautySalonDatabaseImplement/Models/Distribution.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Distribution
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime IssueDate { get; set; }
|
||||
public virtual Employee Employee { get; set; }
|
||||
|
||||
[ForeignKey("DistributionId")]
|
||||
public virtual List<DistributionCosmetic> DistributionCosmetics { get; set; }
|
||||
}
|
||||
}
|
||||
18
BeautySalonDatabaseImplement/Models/DistributionCosmetic.cs
Normal file
18
BeautySalonDatabaseImplement/Models/DistributionCosmetic.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class DistributionCosmetic
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int DistributionId { get; set; }
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Distribution Distribution { get; set; }
|
||||
public virtual Cosmetic Cosmetic { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
37
BeautySalonDatabaseImplement/Models/Employee.cs
Normal file
37
BeautySalonDatabaseImplement/Models/Employee.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string EmployeeName { get; set; }
|
||||
|
||||
[Required]
|
||||
public string EmployeeSurname { get; set; }
|
||||
|
||||
public string Patronymic { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Login { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
|
||||
[ForeignKey("EmployeeId")]
|
||||
public virtual List<Cosmetic> Cosmetic { get; set; }
|
||||
|
||||
[ForeignKey("EmployeeId")]
|
||||
public virtual List<Distribution> Distribution { get; set; }
|
||||
|
||||
[ForeignKey("EmployeeId")]
|
||||
public virtual List<Receipt> Receipt { get; set; }
|
||||
}
|
||||
}
|
||||
30
BeautySalonDatabaseImplement/Models/Procedure.cs
Normal file
30
BeautySalonDatabaseImplement/Models/Procedure.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Procedure
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProcedureName { get; set; }
|
||||
|
||||
[Required]
|
||||
public string FIO_Master { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Duration { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<ProcedurePurchase> ProcedurePurchase { get; set; }
|
||||
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<ProcedureVisit> ProcedureVisit { get; set; }
|
||||
}
|
||||
}
|
||||
11
BeautySalonDatabaseImplement/Models/ProcedurePurchase.cs
Normal file
11
BeautySalonDatabaseImplement/Models/ProcedurePurchase.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class ProcedurePurchase
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ProcedureId { get; set; }
|
||||
public int PurchaseId { get; set; }
|
||||
public virtual Procedure Procedure { get; set; }
|
||||
public virtual Purchase Purchase { get; set; }
|
||||
}
|
||||
}
|
||||
11
BeautySalonDatabaseImplement/Models/ProcedureVisit.cs
Normal file
11
BeautySalonDatabaseImplement/Models/ProcedureVisit.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class ProcedureVisit
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ProcedureId { get; set; }
|
||||
public int VisitId { get; set; }
|
||||
public virtual Procedure Procedure { get; set; }
|
||||
public virtual Visit Visit { get; set; }
|
||||
}
|
||||
}
|
||||
18
BeautySalonDatabaseImplement/Models/Purchase.cs
Normal file
18
BeautySalonDatabaseImplement/Models/Purchase.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Purchase
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
17
BeautySalonDatabaseImplement/Models/PurchaseReceipt.cs
Normal file
17
BeautySalonDatabaseImplement/Models/PurchaseReceipt.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class PurchaseReceipt
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PurchaseId { get; set; }
|
||||
public int ReceiptId { get; set; }
|
||||
public virtual Purchase Purchase { get; set; }
|
||||
public virtual Receipt Receipt { get; set; }
|
||||
}
|
||||
}
|
||||
30
BeautySalonDatabaseImplement/Models/Receipt.cs
Normal file
30
BeautySalonDatabaseImplement/Models/Receipt.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Receipt
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public int? PurchaseId { get; set; }
|
||||
[Required]
|
||||
public decimal TotalCost { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public virtual Employee Employee { get; set; }
|
||||
|
||||
[ForeignKey(nameof(PurchaseId))]
|
||||
public virtual Purchase Purchase { get; set; }
|
||||
|
||||
|
||||
[ForeignKey("ReceiptId")]
|
||||
public virtual List<ReceiptCosmetic> ReceiptCosmetics { get; set; }
|
||||
[ForeignKey("ReceiptId")]
|
||||
public virtual List<PurchaseReceipt> ReceiptPurcheses { get; set; }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user