Лабораторная работа 6 (усложнёнка)
This commit is contained in:
parent
040c8b243c
commit
4ae9ece2f3
@ -13,13 +13,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplem
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyView", "FurnitureAssemblyView\FurnitureAssemblyView.csproj", "{77944C5A-53FC-437B-A563-E7C09C769859}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyView", "FurnitureAssemblyView\FurnitureAssemblyView.csproj", "{77944C5A-53FC-437B-A563-E7C09C769859}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyFileImplement", "FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj", "{2EF175D6-B6BD-442B-B81E-67E368553726}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyFileImplement", "FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj", "{C987B2B5-56C1-434F-BBCF-6453CF6E5193}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDatabaseImplement", "FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{C2302631-5038-4592-B75F-C03C3ABD510D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDatabaseImplement", "FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{D236EEDD-7AAE-40FF-BE52-B637EEA89FA6}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyRestApi", "FurnitureAssemblyRestApi\FurnitureAssemblyRestApi.csproj", "{8F808327-C893-4F7B-ACEC-A8F960D4C2F4}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyRestApi", "FurnitureAssemblyRestApi\FurnitureAssemblyRestApi.csproj", "{8622D3F5-AC1F-4D70-AA32-720447AB632F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyClientApp", "FurnitureAssemblyClientApp\FurnitureAssemblyClientApp.csproj", "{7125E0C7-C4DC-41D1-9365-06A8A7647302}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyClientApp", "FurnitureAssemblyClientApp\FurnitureAssemblyClientApp.csproj", "{14EBC846-F344-4D99-9594-43509A3C1861}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyShopApp", "FurnitureAssemblyShopApp\FurnitureAssemblyShopApp.csproj", "{9EC23C5C-03D2-4890-8FA0-7D42BE8802E2}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -47,22 +49,26 @@ Global
|
|||||||
{77944C5A-53FC-437B-A563-E7C09C769859}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{77944C5A-53FC-437B-A563-E7C09C769859}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{77944C5A-53FC-437B-A563-E7C09C769859}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{77944C5A-53FC-437B-A563-E7C09C769859}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{77944C5A-53FC-437B-A563-E7C09C769859}.Release|Any CPU.Build.0 = Release|Any CPU
|
{77944C5A-53FC-437B-A563-E7C09C769859}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2EF175D6-B6BD-442B-B81E-67E368553726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C987B2B5-56C1-434F-BBCF-6453CF6E5193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2EF175D6-B6BD-442B-B81E-67E368553726}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C987B2B5-56C1-434F-BBCF-6453CF6E5193}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2EF175D6-B6BD-442B-B81E-67E368553726}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C987B2B5-56C1-434F-BBCF-6453CF6E5193}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2EF175D6-B6BD-442B-B81E-67E368553726}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C987B2B5-56C1-434F-BBCF-6453CF6E5193}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{C2302631-5038-4592-B75F-C03C3ABD510D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D236EEDD-7AAE-40FF-BE52-B637EEA89FA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C2302631-5038-4592-B75F-C03C3ABD510D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D236EEDD-7AAE-40FF-BE52-B637EEA89FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C2302631-5038-4592-B75F-C03C3ABD510D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D236EEDD-7AAE-40FF-BE52-B637EEA89FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C2302631-5038-4592-B75F-C03C3ABD510D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D236EEDD-7AAE-40FF-BE52-B637EEA89FA6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{8F808327-C893-4F7B-ACEC-A8F960D4C2F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{8622D3F5-AC1F-4D70-AA32-720447AB632F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8F808327-C893-4F7B-ACEC-A8F960D4C2F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{8622D3F5-AC1F-4D70-AA32-720447AB632F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8F808327-C893-4F7B-ACEC-A8F960D4C2F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{8622D3F5-AC1F-4D70-AA32-720447AB632F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{8F808327-C893-4F7B-ACEC-A8F960D4C2F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
{8622D3F5-AC1F-4D70-AA32-720447AB632F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7125E0C7-C4DC-41D1-9365-06A8A7647302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{14EBC846-F344-4D99-9594-43509A3C1861}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{7125E0C7-C4DC-41D1-9365-06A8A7647302}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{14EBC846-F344-4D99-9594-43509A3C1861}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7125E0C7-C4DC-41D1-9365-06A8A7647302}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{14EBC846-F344-4D99-9594-43509A3C1861}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7125E0C7-C4DC-41D1-9365-06A8A7647302}.Release|Any CPU.Build.0 = Release|Any CPU
|
{14EBC846-F344-4D99-9594-43509A3C1861}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9EC23C5C-03D2-4890-8FA0-7D42BE8802E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9EC23C5C-03D2-4890-8FA0-7D42BE8802E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9EC23C5C-03D2-4890-8FA0-7D42BE8802E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9EC23C5C-03D2-4890-8FA0-7D42BE8802E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -19,7 +19,6 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
private readonly IClientStorage _clientStorage;
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
// Конструктор
|
|
||||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
@ -14,161 +14,155 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
{
|
{
|
||||||
// Класс, реализующий логику для исполнителей
|
// Класс, реализующий логику для исполнителей
|
||||||
public class ImplementerLogic : IImplementerLogic
|
public class ImplementerLogic : IImplementerLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IImplementerStorage _implementerStorage;
|
private readonly IImplementerStorage _implementerStorage;
|
||||||
|
|
||||||
// Конструктор
|
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
{
|
||||||
{
|
_logger = logger;
|
||||||
_logger = logger;
|
_implementerStorage = implementerStorage;
|
||||||
_implementerStorage = implementerStorage;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Вывод всего отфильтрованного списка
|
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
{
|
||||||
{
|
_logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model?.ImplementerFIO, model?.Id);
|
||||||
_logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model?.ImplementerFIO, model?.Id);
|
|
||||||
|
|
||||||
// list хранит весь список в случае, если model пришло со значением null на вход метода
|
// list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||||
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
||||||
|
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Вывод конкретного элемента
|
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
{
|
||||||
{
|
if (model == null)
|
||||||
if (model == null)
|
{
|
||||||
{
|
throw new ArgumentNullException(nameof(model));
|
||||||
throw new ArgumentNullException(nameof(model));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model.ImplementerFIO, model?.Id);
|
_logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model.ImplementerFIO, model?.Id);
|
||||||
|
|
||||||
var element = _implementerStorage.GetElement(model);
|
var element = _implementerStorage.GetElement(model);
|
||||||
|
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создание работника
|
public bool Create(ImplementerBindingModel model)
|
||||||
public bool Create(ImplementerBindingModel model)
|
{
|
||||||
{
|
CheckModel(model);
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (_implementerStorage.Insert(model) == null)
|
if (_implementerStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обновление данных о работнике
|
public bool Update(ImplementerBindingModel model)
|
||||||
public bool Update(ImplementerBindingModel model)
|
{
|
||||||
{
|
CheckModel(model);
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (_implementerStorage.Update(model) == null)
|
if (_implementerStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удаление работника
|
public bool Delete(ImplementerBindingModel model)
|
||||||
public bool Delete(ImplementerBindingModel model)
|
{
|
||||||
{
|
CheckModel(model, false);
|
||||||
CheckModel(model, false);
|
|
||||||
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
|
||||||
if (_implementerStorage.Delete(model) == null)
|
if (_implementerStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка входного аргумента для методов Insert, Update и Delete
|
// Проверка входного аргумента для методов Insert, Update и Delete
|
||||||
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Так как при удалении передаём как параметр false
|
// Так как при удалении передаём как параметр false
|
||||||
if (!withParams)
|
if (!withParams)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие ФИО
|
// Проверка на наличие ФИО
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Отсутствие ФИО в учётной записи", nameof(model.ImplementerFIO));
|
throw new ArgumentNullException("Отсутствие ФИО в учётной записи", nameof(model.ImplementerFIO));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие пароля
|
// Проверка на наличие пароля
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password));
|
throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие квалификации
|
// Проверка на наличие квалификации
|
||||||
if (model.Qualification <= 0)
|
if (model.Qualification <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Указана некорректная квалификация", nameof(model.Qualification));
|
throw new ArgumentNullException("Указана некорректная квалификация", nameof(model.Qualification));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие квалификации
|
// Проверка на наличие квалификации
|
||||||
if (model.WorkExperience < 0)
|
if (model.WorkExperience < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Указан некорректный стаж работы", nameof(model.WorkExperience));
|
throw new ArgumentNullException("Указан некоректный стаж работы", nameof(model.WorkExperience));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Password:{Password}. " +
|
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Password:{Password}. " +
|
||||||
"Qualification:{Qualification}. WorkExperience:{ WorkExperience}. Id:{Id}",
|
"Qualification:{Qualification}. WorkExperience:{ WorkExperience}. Id:{Id}",
|
||||||
model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience, model.Id);
|
model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience, model.Id);
|
||||||
|
|
||||||
// Для проверка на наличие такого же аккаунта
|
// Для проверка на наличие такого же аккаунта
|
||||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||||
{
|
{
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Если элемент найден и его Id не совпадает с Id переданного объекта
|
// Если элемент найден и его Id не совпадает с Id переданного объекта
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Исполнитель с таким именем уже есть");
|
throw new InvalidOperationException("Исполнитель с таким именем уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,17 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
static readonly object locker = new object();
|
private readonly IShopLogic _shopLogic;
|
||||||
|
|
||||||
|
private readonly IFurnitureStorage _furnitureStorage;
|
||||||
|
|
||||||
// Конструктор
|
// Конструктор
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, IFurnitureStorage furnitureStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
_furnitureStorage = furnitureStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Вывод отфильтрованного списка компонентов
|
// Вывод отфильтрованного списка компонентов
|
||||||
@ -49,36 +53,35 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Вывод конкретного чека
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
{
|
||||||
{
|
if (model == null)
|
||||||
if (model == null)
|
{
|
||||||
{
|
throw new ArgumentNullException(nameof(model));
|
||||||
throw new ArgumentNullException(nameof(model));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadElement. Id:{Id}", model?.Id);
|
_logger.LogInformation("ReadElement. Id:{Id}", model?.Id);
|
||||||
|
|
||||||
var element = _orderStorage.GetElement(model);
|
var element = _orderStorage.GetElement(model);
|
||||||
|
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создание чека
|
// Создание чека
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
|
||||||
if(model.Status != OrderStatus.Неизвестен)
|
if (model.Status != OrderStatus.Неизвестен)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed, incorrect order status");
|
_logger.LogWarning("Insert operation failed, incorrect order status");
|
||||||
return false;
|
return false;
|
||||||
@ -86,10 +89,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
|
|
||||||
if(_orderStorage.Insert(model) == null)
|
if (_orderStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
model.Status = OrderStatus.Неизвестен;
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +101,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
lock (locker)
|
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
@ -129,36 +129,36 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие товаров в заказе
|
// Проверка на наличие товаров в заказе
|
||||||
if(model.Count <= 0)
|
if (model.Count <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("В заказе не может быть 0 изделий", nameof(model.Count));
|
throw new ArgumentNullException("В заказе не может быть 0 изделий", nameof(model.Count));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на наличие нормальной суммарной стоимости чека
|
// Проверка на наличие нормальной суммарной стоимости чека
|
||||||
if(model.Sum <= 0)
|
if (model.Sum <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum));
|
throw new ArgumentNullException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка корректности id у изделий
|
// Проверка корректности id у изделий
|
||||||
if(model.FurnitureId < 0)
|
if (model.FurnitureId < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Некорректный id у изделия", nameof(model.FurnitureId));
|
throw new ArgumentNullException("Некорректный id у изделия", nameof(model.FurnitureId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка корректности дат
|
|
||||||
if(model.DateCreate > model.DateImplement)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Проверка на клиента
|
// Проверка на клиента
|
||||||
if (model.ClientId < 0)
|
if (model.ClientId < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId));
|
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}. ClientId:{ClientId}. FurnitureId:{Id}", model.Id, model.Sum, model.ClientId, model.FurnitureId);
|
// Проверка корректности дат
|
||||||
|
if (model.DateCreate > model.DateImplement)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения");
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Order. OrderId:{Id}, Sum:{Sum}. FurnitureId:{Id}. Sum:{Sum}", model.Id, model.Sum, model.FurnitureId, model.Sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обновление статуса заказа
|
// Обновление статуса заказа
|
||||||
@ -167,13 +167,13 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
|
|
||||||
// Если не смогли найти указанный заказ по его Id
|
// Если не смогли найти указанный заказ по его Id
|
||||||
if(viewModel == null)
|
if (viewModel == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка на возможность обновления статуса на следующий
|
// Проверка на возможность обновления статуса на следующий
|
||||||
if(viewModel.Status + 1 != newOrderStatus)
|
if (viewModel.Status + 1 != newOrderStatus && viewModel.Status != OrderStatus.Ожидание)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + "incorrect");
|
_logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + "incorrect");
|
||||||
return false;
|
return false;
|
||||||
@ -181,16 +181,27 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
model.Status = newOrderStatus;
|
model.Status = newOrderStatus;
|
||||||
|
|
||||||
// Помещаем id работника, не забываем про него...
|
// Проверка на выдачу
|
||||||
if (viewModel.ImplementerId.HasValue)
|
if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание)
|
||||||
{
|
|
||||||
model.ImplementerId = viewModel.ImplementerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Проверка на выдачу
|
|
||||||
if (model.Status == OrderStatus.Выдан)
|
|
||||||
{
|
{
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
|
|
||||||
|
var furniture = _furnitureStorage.GetElement(new() { Id = viewModel.FurnitureId });
|
||||||
|
|
||||||
|
if (furniture == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(furniture));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_shopLogic.AddFurnitures(furniture, viewModel.Count))
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Ожидание;
|
||||||
|
_logger.LogWarning($"Невозможно выдать изделия, магазины переполнены. AddFurnitures operation failed. Shop is full.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -200,10 +211,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
|
|
||||||
// Финальная проверка на возможность обновления
|
// Финальная проверка на возможность обновления
|
||||||
if(_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
|
||||||
|
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,6 +20,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
@ -27,12 +29,12 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
|
||||||
// Инициализируем поля класса через контейнер
|
// Инициализируем поля класса через контейнер
|
||||||
public ReportLogic(IFurnitureStorage furnitureStorage,
|
public ReportLogic(IFurnitureStorage furnitureStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||||
IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel,
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
|
||||||
{
|
{
|
||||||
_furnitureStorage = furnitureStorage;
|
_furnitureStorage = furnitureStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
@ -67,6 +69,34 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Получение списка изделий с указанием, в каких магазинах в наличии
|
||||||
|
public List<ReportShopFurnituresViewModel> GetShopFurnitures()
|
||||||
|
{
|
||||||
|
var shops = _shopStorage.GetFullList();
|
||||||
|
|
||||||
|
var list = new List<ReportShopFurnituresViewModel>();
|
||||||
|
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
var record = new ReportShopFurnituresViewModel
|
||||||
|
{
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Furnitures = new List<(string, int)>(),
|
||||||
|
TotalCount = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var furniture in shop.ShopFurnitures)
|
||||||
|
{
|
||||||
|
record.Furnitures.Add(new(furniture.Value.Item1.FurnitureName, furniture.Value.Item2));
|
||||||
|
record.TotalCount += furniture.Value.Item2;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
// Получение списка заказов за определённый период
|
// Получение списка заказов за определённый период
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
@ -81,6 +111,20 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Получение списка заказов за весь период
|
||||||
|
public List<ReportGroupedOrdersViewModel> GetGroupedOrders()
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFullList()
|
||||||
|
.GroupBy(x => x.DateCreate.Date)
|
||||||
|
.Select(x => new ReportGroupedOrdersViewModel
|
||||||
|
{
|
||||||
|
DateCreate = x.Key,
|
||||||
|
Count = x.Count(),
|
||||||
|
Sum = x.Sum(x => x.Sum)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
// Сохранение мебели в файл-Word
|
// Сохранение мебели в файл-Word
|
||||||
public void SaveFurnituresToWordFile(ReportBindingModel model)
|
public void SaveFurnituresToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
@ -92,6 +136,17 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Сохранение магазинов в файл-Word
|
||||||
|
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateTable(new WordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Таблица магазинов",
|
||||||
|
Shops = _shopStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Сохранение заготовок с указанием изделий в файл_Excel
|
// Сохранение заготовок с указанием изделий в файл_Excel
|
||||||
public void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model)
|
public void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
@ -103,6 +158,17 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Сохранение магазинов с указанием изделий в файл-Excel
|
||||||
|
public void SaveShopFurnituresToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateShopReport(new ExcelInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список магазинов",
|
||||||
|
ShopFurnitures = GetShopFurnitures()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Сохранение заказов в файл-Pdf
|
// Сохранение заказов в файл-Pdf
|
||||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
@ -115,5 +181,16 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
Orders = GetOrders(model)
|
Orders = GetOrders(model)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Сохранение заказов за весь период в файл-Pdf
|
||||||
|
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateGroupedDoc(new PdfInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов",
|
||||||
|
GroupedOrders = GetGroupedOrders()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,267 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||||
|
{
|
||||||
|
// Класс, реализующий логику для магазинов
|
||||||
|
public class ShopLogic : IShopLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
|
||||||
|
// Конструктор
|
||||||
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вывод конкретного магазина
|
||||||
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(model);
|
||||||
|
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вывод отфильтрованного списка компонентов
|
||||||
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||||
|
|
||||||
|
// list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||||
|
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Пополнение магазина
|
||||||
|
public bool AddFurniture(ShopSearchModel model, IFurnitureModel furniture, int count)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0", nameof(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("AddFurniture. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||||
|
var shop = _shopStorage.GetElement(model);
|
||||||
|
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Add Furniture operation failed");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shop.MaxCountFurnitures - shop.ShopFurnitures.Select(x => x.Value.Item2).Sum() < count)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Слишком много изделий для одного магазина", nameof(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shop.ShopFurnitures.ContainsKey(furniture.Id))
|
||||||
|
{
|
||||||
|
shop.ShopFurnitures[furniture.Id] = (furniture, count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.ShopFurnitures[furniture.Id] = (furniture, shop.ShopFurnitures[furniture.Id].Item2 + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopStorage.Update(new ShopBindingModel()
|
||||||
|
{
|
||||||
|
Id = shop.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Address = shop.Address,
|
||||||
|
DateOpen = shop.DateOpen,
|
||||||
|
MaxCountFurnitures = shop.MaxCountFurnitures,
|
||||||
|
ShopFurnitures = shop.ShopFurnitures
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание магазина
|
||||||
|
public bool Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (_shopStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обновление магазина
|
||||||
|
public bool Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (_shopStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Удаление магазина
|
||||||
|
public bool Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
|
||||||
|
if (_shopStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка входного аргумента для методов Insert, Update и Delete
|
||||||
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
// При удалении передаём как параметр false
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка на наличие названия магазина
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствует названия магазина", nameof(model.ShopName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка на наличие адреса у магазина
|
||||||
|
if (string.IsNullOrEmpty(model.Address))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствует адреса магазина", nameof(model.Address));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{Address}. Id: {Id}", model.ShopName, model.Address, model.Id);
|
||||||
|
|
||||||
|
// Проверка на наличие такого же магазина в списке
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName
|
||||||
|
});
|
||||||
|
|
||||||
|
// Если элемент найден и его Id не совпадает с Id переданного объекта
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool AddFurnitures(IFurnitureModel model, int count)
|
||||||
|
{
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0", nameof(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("AddFurnitures. Furniture: {Furniture}. Count: {Count}", model?.FurnitureName, count);
|
||||||
|
|
||||||
|
var capacity = _shopStorage.GetFullList().Select(x => x.MaxCountFurnitures - x.ShopFurnitures.Select(x => x.Value.Item2).Sum()).Sum() - count;
|
||||||
|
|
||||||
|
if (capacity < 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("AddFurnitures operation failed. Sell {count} Furnitures ", -capacity);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _shopStorage.GetFullList())
|
||||||
|
{
|
||||||
|
if (shop.MaxCountFurnitures - shop.ShopFurnitures.Select(x => x.Value.Item2).Sum() < count)
|
||||||
|
{
|
||||||
|
if (!AddFurniture(new() { Id = shop.Id }, model, shop.MaxCountFurnitures - shop.ShopFurnitures.Select(x => x.Value.Item2).Sum()))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("AddFurnitures operation failed.");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
count -= shop.MaxCountFurnitures - shop.ShopFurnitures.Select(x => x.Value.Item2).Sum();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!AddFurniture(new() { Id = shop.Id }, model, count))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("AddFurnitures operation failed.");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
count -= count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SellFurnitures(IFurnitureModel model, int count)
|
||||||
|
{
|
||||||
|
return _shopStorage.SellFurnitures(model, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,155 +12,183 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||||
{
|
{
|
||||||
public class WorkModeling : IWorkProcess
|
public class WorkModeling : IWorkProcess
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly Random _rnd;
|
private readonly Random _rnd;
|
||||||
|
|
||||||
private IOrderLogic? _orderLogic;
|
private IOrderLogic? _orderLogic;
|
||||||
|
|
||||||
// Конструктор
|
public WorkModeling(ILogger<WorkModeling> logger)
|
||||||
public WorkModeling(ILogger<WorkModeling> logger)
|
{
|
||||||
{
|
_logger = logger;
|
||||||
_logger = logger;
|
_rnd = new Random(1000);
|
||||||
_rnd = new Random(1000);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
||||||
{
|
{
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
var implementers = implementerLogic.ReadList(null);
|
var implementers = implementerLogic.ReadList(null);
|
||||||
|
|
||||||
if (implementers == null)
|
if (implementers == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("DoWork. Implementers is null");
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var orders = _orderLogic.ReadList(new OrderSearchModel
|
var orders = _orderLogic.ReadList(new() { Status = OrderStatus.Принят });
|
||||||
{
|
if (orders == null)
|
||||||
Status = OrderStatus.Принят
|
{
|
||||||
});
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (orders == null || orders.Count == 0)
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
{
|
|
||||||
_logger.LogWarning("Dowork. Orders is null or empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogDebug("DoWork for {count} orders", orders.Count);
|
foreach (var implementer in implementers)
|
||||||
|
{
|
||||||
|
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var implementer in implementers)
|
// Имитация работы исполнителя
|
||||||
{
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
{
|
||||||
}
|
if (_orderLogic == null || implementer == null)
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Имитация работы исполнителя
|
await Task.Run(() =>
|
||||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
{
|
||||||
{
|
try
|
||||||
if (_orderLogic == null || implementer == null)
|
{
|
||||||
{
|
var runOrder = _orderLogic.ReadList(new OrderSearchModel
|
||||||
return;
|
{
|
||||||
}
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Ожидание
|
||||||
|
});
|
||||||
|
|
||||||
await RunOrderInWork(implementer);
|
if (runOrder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await Task.Run(() =>
|
foreach (var order in runOrder)
|
||||||
{
|
{
|
||||||
foreach (var order in orders)
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||||
{
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
try
|
{
|
||||||
{
|
Id = order.Id
|
||||||
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// Может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Пытаемся назначить заказ на исполнителя
|
await RunOrderInWork(implementer);
|
||||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = order.Id,
|
|
||||||
ImplementerId = implementer.Id
|
|
||||||
});
|
|
||||||
|
|
||||||
// Работу работаем, делаем-делаем
|
await Task.Run(() =>
|
||||||
Thread.Sleep(implementer.WorkExperience * order.Count);
|
{
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
|
||||||
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
// Пытаемся назначить заказ на исполнителя
|
||||||
|
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id,
|
||||||
|
ImplementerId = implementer.Id
|
||||||
|
});
|
||||||
|
|
||||||
_orderLogic.FinishOrder(new OrderBindingModel
|
// делаем работу
|
||||||
{
|
Thread.Sleep(implementer.WorkExperience * order.Count);
|
||||||
Id = order.Id
|
|
||||||
});
|
|
||||||
|
|
||||||
// Усёёё отдыхаем
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||||
Thread.Sleep(implementer.Qualification);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Игнорируем ошибку, если с заказом что-то случится
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
catch (InvalidOperationException ex)
|
{
|
||||||
{
|
Id = order.Id,
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// В случае ошибки прервём выполнение имитации работы
|
// Отдыхаем
|
||||||
catch (Exception ex)
|
Thread.Sleep(implementer.Qualification);
|
||||||
{
|
}
|
||||||
_logger.LogError(ex, "Error while do work");
|
// Кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
throw;
|
catch (InvalidOperationException ex)
|
||||||
}
|
{
|
||||||
}
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
});
|
}
|
||||||
}
|
// Заканчиваем выполнение имитации в случае иной ошибки
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Ищем заказ, который уже во всю в работе (вдруг прервали исполнителя)
|
// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||||
{
|
{
|
||||||
if (_orderLogic == null || implementer == null)
|
if (_orderLogic == null || implementer == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||||
{
|
{
|
||||||
ImplementerId = implementer.Id,
|
ImplementerId = implementer.Id,
|
||||||
Status = OrderStatus.Выполняется
|
Status = OrderStatus.Выполняется
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (runOrder == null)
|
if (runOrder == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogDebug("DoWork {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
|
||||||
// Доделываем работу
|
// Доделываем работу
|
||||||
Thread.Sleep(implementer.WorkExperience * runOrder.Count);
|
Thread.Sleep(implementer.WorkExperience * runOrder.Count);
|
||||||
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
|
||||||
_orderLogic.FinishOrder(new OrderBindingModel
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = runOrder.Id
|
Id = runOrder.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
// Отдыхаем, хватит работы
|
// Отдыхаем
|
||||||
Thread.Sleep(implementer.Qualification);
|
Thread.Sleep(implementer.Qualification);
|
||||||
}
|
}
|
||||||
|
// Заказа может не быть, просто игнорируем ошибку
|
||||||
// Заказа может не быть, просто игнорируем ошибку
|
catch (InvalidOperationException ex)
|
||||||
catch (InvalidOperationException ex)
|
{
|
||||||
{
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
}
|
||||||
}
|
// Может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
// Просто возникнет тупая ошибка, тогда заканчиваем выполнение имитации
|
{
|
||||||
catch (Exception ex)
|
_logger.LogError(ex, "Error while do work");
|
||||||
{
|
throw;
|
||||||
_logger.LogError(ex, "Error while do work");
|
}
|
||||||
throw;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
<PackageReference Include="MigraDocCore.DocumentObjectModel" Version="1.3.63" />
|
||||||
</ItemGroup>
|
<PackageReference Include="MigraDocCore.Rendering" Version="1.3.63" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard.DocumentObjectModel" Version="1.51.15" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -31,19 +31,19 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
|||||||
|
|
||||||
uint rowIndex = 2;
|
uint rowIndex = 2;
|
||||||
|
|
||||||
foreach (var fwp in info.FurnitureWorkPieces)
|
foreach (var mwp in info.FurnitureWorkPieces)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = fwp.FurnitureName,
|
Text = mwp.FurnitureName,
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
|
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
|
|
||||||
foreach (var (WorkPiece, Count) in fwp.WorkPieces)
|
foreach (var (WorkPiece, Count) in mwp.WorkPieces)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
@ -76,7 +76,82 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = fwp.TotalCount.ToString(),
|
Text = mwp.TotalCount.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveExcel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateShopReport(ExcelInfo info)
|
||||||
|
{
|
||||||
|
CreateExcel(info);
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = 1,
|
||||||
|
Text = info.Title,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
|
});
|
||||||
|
|
||||||
|
MergeCells(new ExcelMergeParameters
|
||||||
|
{
|
||||||
|
CellFromName = "A1",
|
||||||
|
CellToName = "C1"
|
||||||
|
});
|
||||||
|
|
||||||
|
uint rowIndex = 2;
|
||||||
|
|
||||||
|
foreach (var sm in info.ShopFurnitures)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = sm.ShopName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var (Furniture, Count) in sm.Furnitures)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Furniture,
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Count.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = "Итого",
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = sm.TotalCount.ToString(),
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,6 +58,36 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
|||||||
SavePdf(info);
|
SavePdf(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateGroupedDoc(PdfInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "3cm", "3cm", "3cm" });
|
||||||
|
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Дата заказа", "Количество заказов", "Сумма" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var order in info.GroupedOrders)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
|
||||||
/// Создание Pdf-файла
|
/// Создание Pdf-файла
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
protected abstract void CreatePdf(PdfInfo info);
|
||||||
|
|
||||||
|
@ -44,12 +44,64 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
|||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateTable(WordInfo 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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<List<(string, WordTextProperties)>> rowList = new()
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
new("Название", new WordTextProperties { Bold = true, Size = "24" } ),
|
||||||
|
new("Адрес", new WordTextProperties { Bold = true, Size = "24" } ),
|
||||||
|
new("Дата открытия", new WordTextProperties { Bold = true, Size = "24" } )
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var shop in info.Shops)
|
||||||
|
{
|
||||||
|
List<(string, WordTextProperties)> cellList = new()
|
||||||
|
{
|
||||||
|
new(shop.ShopName, new WordTextProperties { Size = "24" }),
|
||||||
|
new(shop.Address, new WordTextProperties { Size = "24" }),
|
||||||
|
new(shop.DateOpen.ToShortDateString(), new WordTextProperties { Size = "24"})
|
||||||
|
};
|
||||||
|
|
||||||
|
rowList.Add(cellList);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateTable(new WordParagraph
|
||||||
|
{
|
||||||
|
RowTexts = rowList,
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
|
||||||
// Создание Doc-файла
|
// Создание Doc-файла
|
||||||
protected abstract void CreateWord(WordInfo info);
|
protected abstract void CreateWord(WordInfo info);
|
||||||
|
|
||||||
// Создание абзаца с текстом
|
// Создание абзаца с текстом
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
|
|
||||||
|
// Создание таблицы
|
||||||
|
protected abstract void CreateTable(WordParagraph paragraph);
|
||||||
|
|
||||||
// Сохранение файла
|
// Сохранение файла
|
||||||
protected abstract void SaveWord(WordInfo info);
|
protected abstract void SaveWord(WordInfo info);
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,8 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
// Список заготовок по изделиям
|
// Список заготовок по изделиям
|
||||||
public List<ReportFurnitureWorkPieceViewModel> FurnitureWorkPieces { get; set; } = new();
|
public List<ReportFurnitureWorkPieceViewModel> FurnitureWorkPieces { get; set; } = new();
|
||||||
|
|
||||||
|
// Список магазинов с изделиями
|
||||||
|
public List<ReportShopFurnituresViewModel> ShopFurnitures { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,8 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
// Перечень заказов за указанный период для вывода/сохранения
|
// Перечень заказов за указанный период для вывода/сохранения
|
||||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
// Перечень заказов за весь период для вывода и сохранения
|
||||||
|
public List<ReportGroupedOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,10 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
//список заготовок для вывода и сохранения
|
// Список заготовок для вывода и сохранения
|
||||||
public List<FurnitureViewModel> Furnitures { get; set; } = new();
|
public List<FurnitureViewModel> Furnitures { get; set; } = new();
|
||||||
|
|
||||||
|
// Список магазинов для вывода и сохранения
|
||||||
|
public List<ShopViewModel> Shops { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
// Модель параграфов, которые есть в тексте
|
// Модель параграфов, которые есть в тексте
|
||||||
public class WordParagraph
|
public class WordParagraph
|
||||||
{
|
{
|
||||||
// Набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
|
//набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
|
||||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||||
|
|
||||||
//свойства параграфа, если они есть
|
//свойства параграфа, если они есть
|
||||||
public WordTextProperties? TextProperties { get; set; }
|
public WordTextProperties? TextProperties { get; set; }
|
||||||
|
|
||||||
|
public List<List<(string, WordTextProperties)>> RowTexts { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,11 +184,8 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||||
var stylesheetExtension1 = new StylesheetExtension()
|
|
||||||
{
|
|
||||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
||||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||||
stylesheetExtension1.Append(new SlicerStyles()
|
stylesheetExtension1.Append(new SlicerStyles()
|
||||||
{
|
{
|
||||||
@ -313,7 +310,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Все ячейки должны быть последовательно друг за другом расположены
|
// Все ячейки должны быть последовательно друг за другом расположены
|
||||||
// Нужно определить, после какой вставлять
|
// нужно определить, после какой вставлять
|
||||||
Cell? refCell = null;
|
Cell? refCell = null;
|
||||||
|
|
||||||
foreach (Cell rowCell in row.Elements<Cell>())
|
foreach (Cell rowCell in row.Elements<Cell>())
|
||||||
@ -331,6 +328,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
row.InsertBefore(newCell, refCell);
|
row.InsertBefore(newCell, refCell);
|
||||||
|
|
||||||
cell = newCell;
|
cell = newCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +385,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||||
_spreadsheetDocument.Dispose();
|
_spreadsheetDocument.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||||
{
|
{
|
||||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||||
{
|
|
||||||
Val = paragraphProperties.Size
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.AppendChild(paragraphMarkRunProperties);
|
properties.AppendChild(paragraphMarkRunProperties);
|
||||||
@ -117,7 +114,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
var docRun = new Run();
|
var docRun = new Run();
|
||||||
var properties = new RunProperties();
|
var properties = new RunProperties();
|
||||||
|
|
||||||
// Задание свойств текста - размер и жирность
|
|
||||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
|
||||||
if (run.Item2.Bold)
|
if (run.Item2.Bold)
|
||||||
@ -127,11 +123,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
docRun.AppendChild(properties);
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
docRun.AppendChild(new Text
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
{
|
|
||||||
Text = run.Item1,
|
|
||||||
Space = SpaceProcessingModeValues.Preserve
|
|
||||||
});
|
|
||||||
|
|
||||||
docParagraph.AppendChild(docRun);
|
docParagraph.AppendChild(docRun);
|
||||||
}
|
}
|
||||||
@ -153,7 +145,77 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
|||||||
// Сохраняем документ
|
// Сохраняем документ
|
||||||
_wordDocument.MainDocumentPart!.Document.Save();
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
|
|
||||||
_wordDocument.Dispose();
|
_wordDocument.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateTable(WordParagraph paragraph)
|
||||||
|
{
|
||||||
|
if (_docBody == null || paragraph == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Table table = new Table();
|
||||||
|
|
||||||
|
var tableProp = new TableProperties();
|
||||||
|
|
||||||
|
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||||
|
tableProp.AppendChild(new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||||
|
));
|
||||||
|
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||||
|
|
||||||
|
table.AppendChild(tableProp);
|
||||||
|
|
||||||
|
TableGrid tableGrid = new TableGrid();
|
||||||
|
|
||||||
|
for (int j = 0; j < paragraph.RowTexts[0].Count; ++j)
|
||||||
|
{
|
||||||
|
tableGrid.AppendChild(new GridColumn() { Width = "3000" });
|
||||||
|
}
|
||||||
|
|
||||||
|
table.AppendChild(tableGrid);
|
||||||
|
|
||||||
|
for (int i = 0; i < paragraph.RowTexts.Count; ++i)
|
||||||
|
{
|
||||||
|
TableRow docRow = new TableRow();
|
||||||
|
|
||||||
|
for (int j = 0; j < paragraph.RowTexts[i].Count; ++j)
|
||||||
|
{
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.RowTexts[i][j].Item2));
|
||||||
|
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
|
||||||
|
properties.AppendChild(new FontSize { Val = paragraph.RowTexts[i][j].Item2.Size });
|
||||||
|
|
||||||
|
if (paragraph.RowTexts[i][j].Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = paragraph.RowTexts[i][j].Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
TableCell docCell = new TableCell();
|
||||||
|
docCell.AppendChild(docParagraph);
|
||||||
|
docRow.AppendChild(docCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
table.AppendChild(docRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
_docBody.AppendChild(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
|
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:24381",
|
"applicationUrl": "http://localhost:44103",
|
||||||
"sslPort": 44337
|
"sslPort": 44394
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profiles": {
|
"profiles": {
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"applicationUrl": "https://localhost:7046;http://localhost:5147",
|
"applicationUrl": "https://localhost:7218;http://localhost:5100",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ namespace FurnitureAssemblyContracts.BindingModels
|
|||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,15 @@ namespace FurnitureAssemblyContracts.BindingModels
|
|||||||
{
|
{
|
||||||
// Реализация сущности "Исполнитель"
|
// Реализация сущности "Исполнитель"
|
||||||
public class ImplementerBindingModel : IImplementerModel
|
public class ImplementerBindingModel : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ namespace FurnitureAssemblyContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int FurnitureId { get; set; }
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
public int FurnitureId { get; set; }
|
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.BindingModels
|
||||||
|
{
|
||||||
|
// Реализация сущности "Магазин"
|
||||||
|
public class ShopBindingModel : IShopModel
|
||||||
|
{
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> ShopFurnitures { get; set; } = new();
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int MaxCountFurnitures { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -11,15 +11,15 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
// Бизнес-логика для исполнителей
|
// Бизнес-логика для исполнителей
|
||||||
public interface IImplementerLogic
|
public interface IImplementerLogic
|
||||||
{
|
{
|
||||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||||
|
|
||||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||||
|
|
||||||
bool Create(ImplementerBindingModel model);
|
bool Create(ImplementerBindingModel model);
|
||||||
|
|
||||||
bool Update(ImplementerBindingModel model);
|
bool Update(ImplementerBindingModel model);
|
||||||
|
|
||||||
bool Delete(ImplementerBindingModel model);
|
bool Delete(ImplementerBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,31 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
|||||||
// Получение списка заготовок с указанием, в каких изделиях используются
|
// Получение списка заготовок с указанием, в каких изделиях используются
|
||||||
List<ReportFurnitureWorkPieceViewModel> GetFurnitureWorkPiece();
|
List<ReportFurnitureWorkPieceViewModel> GetFurnitureWorkPiece();
|
||||||
|
|
||||||
|
//Получение списка мороженых с указанием, в каких магазинах в наличии
|
||||||
|
List<ReportShopFurnituresViewModel> GetShopFurnitures();
|
||||||
|
|
||||||
// Получение списка заказов за определённый период
|
// Получение списка заказов за определённый период
|
||||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||||
|
|
||||||
|
//Получение списка заказов за весь период
|
||||||
|
List<ReportGroupedOrdersViewModel> GetGroupedOrders();
|
||||||
|
|
||||||
// Сохранение изделий в файл-Word
|
// Сохранение изделий в файл-Word
|
||||||
void SaveFurnituresToWordFile(ReportBindingModel model);
|
void SaveFurnituresToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
//Сохранение магазинов в виде таблицы в файл-Word
|
||||||
|
void SaveShopsToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
// Сохранение заготовок с указанием изделий в файл-Excel
|
// Сохранение заготовок с указанием изделий в файл-Excel
|
||||||
void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model);
|
void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
//Сохранение магазинов с указанием мороженых в файл-Excel
|
||||||
|
void SaveShopFurnituresToExcelFile(ReportBindingModel model);
|
||||||
|
|
||||||
// Сохранение заказов в файл-Pdf
|
// Сохранение заказов в файл-Pdf
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
//Сохранение заказов за весь период в файл-Pdf
|
||||||
|
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
// Бизнес-логика для магазина
|
||||||
|
public interface IShopLogic
|
||||||
|
{
|
||||||
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
|
|
||||||
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool AddFurniture(ShopSearchModel model, IFurnitureModel furniture, int count);
|
||||||
|
|
||||||
|
bool SellFurnitures(IFurnitureModel model, int count);
|
||||||
|
|
||||||
|
bool AddFurnitures(IFurnitureModel model, int count);
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
// Интерфейс для класса, имитирующего работу
|
// Интерфейс для класса, имитирующего работу
|
||||||
public interface IWorkProcess
|
public interface IWorkProcess
|
||||||
{
|
{
|
||||||
// Запуск работы
|
// Запуск работ
|
||||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@ namespace FurnitureAssemblyContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? Email { get; set; }
|
public string? ClientFIO { get; set; }
|
||||||
|
|
||||||
|
public string? Email { get; set; }
|
||||||
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,15 @@ namespace FurnitureAssemblyContracts.SearchModels
|
|||||||
{
|
{
|
||||||
// Модель для поиска исполнителя
|
// Модель для поиска исполнителя
|
||||||
public class ImplementerSearchModel
|
public class ImplementerSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? ImplementerFIO { get; set; }
|
public string? ImplementerFIO { get; set; }
|
||||||
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
public int? WorkExperience { get; set; }
|
public int? WorkExperience { get; set; }
|
||||||
|
|
||||||
public int? Qualification { get; set; }
|
public int? Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ namespace FurnitureAssemblyContracts.SearchModels
|
|||||||
// для поиска по клиенту
|
// для поиска по клиенту
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
// Для поиска по исполнителю
|
// для поиска по исполнителю
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
// Два поля для возможности производить выборку
|
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
|
||||||
// Для статуса заказа
|
|
||||||
public OrderStatus? Status { get; set; }
|
public OrderStatus? Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.SearchModels
|
||||||
|
{
|
||||||
|
// Для поиска сущности "Магазин"
|
||||||
|
public class ShopSearchModel
|
||||||
|
{
|
||||||
|
// Для поиска по идентификатору
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
// Для поиска по названию
|
||||||
|
public string? ShopName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -11,17 +11,17 @@ namespace FurnitureAssemblyContracts.StoragesContracts
|
|||||||
{
|
{
|
||||||
// Класс для хранилища исполнителей
|
// Класс для хранилища исполнителей
|
||||||
public interface IImplementerStorage
|
public interface IImplementerStorage
|
||||||
{
|
{
|
||||||
List<ImplementerViewModel> GetFullList();
|
List<ImplementerViewModel> GetFullList();
|
||||||
|
|
||||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||||
|
|
||||||
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||||
|
|
||||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||||
|
|
||||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||||
|
|
||||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
// Класс для хранилища магазинов
|
||||||
|
public interface IShopStorage
|
||||||
|
{
|
||||||
|
List<ShopViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
|
|
||||||
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool SellFurnitures(IFurnitureModel model, int count);
|
||||||
|
}
|
||||||
|
}
|
@ -10,19 +10,19 @@ namespace FurnitureAssemblyContracts.ViewModels
|
|||||||
{
|
{
|
||||||
// Класс для отображения информации об исполнителях
|
// Класс для отображения информации об исполнителях
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стаж")]
|
[DisplayName("Стаж")]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[DisplayName("Квалификация")]
|
[DisplayName("Квалификация")]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,11 @@ namespace FurnitureAssemblyContracts.ViewModels
|
|||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int FurnitureId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Изделие")]
|
||||||
|
public string FurnitureName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[DisplayName("ФИО клиента")]
|
||||||
@ -25,11 +30,6 @@ namespace FurnitureAssemblyContracts.ViewModels
|
|||||||
[DisplayName("ФИО исполнителя")]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int FurnitureId { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Изделие")]
|
|
||||||
public string FurnitureName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportGroupedOrdersViewModel
|
||||||
|
{
|
||||||
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public double Sum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,7 @@ namespace FurnitureAssemblyContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
public string FurnitureName { get; set; } = string.Empty;
|
public string FurnitureName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportShopFurnituresViewModel
|
||||||
|
{
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
|
||||||
|
public List<(string Furniture, int Count)> Furnitures { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.ViewModels
|
||||||
|
{
|
||||||
|
// Класс для отображения пользователю информации о магазинах
|
||||||
|
public class ShopViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название магазина")]
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Адрес магазина")]
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> ShopFurnitures { get; set; } = new();
|
||||||
|
|
||||||
|
[DisplayName("Вместимость магазина")]
|
||||||
|
public int MaxCountFurnitures { get; set; }
|
||||||
|
|
||||||
|
public List<Tuple<string, int>>? FurnitureCount { get; set; } = new ();
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,8 @@ namespace FurnitureAssemblyDataModels.Enums
|
|||||||
|
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
|
|
||||||
Выдан = 3
|
Выдан = 3,
|
||||||
|
|
||||||
|
Ожидание = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyDataModels.Models
|
namespace FurnitureAssemblyDataModels.Models
|
||||||
{
|
{
|
||||||
// Интерфейс, отвечающий за клиента
|
|
||||||
public interface IClientModel : IId
|
public interface IClientModel : IId
|
||||||
{
|
{
|
||||||
string ClientFIO { get; }
|
string ClientFIO { get; }
|
||||||
|
@ -6,15 +6,15 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyDataModels.Models
|
namespace FurnitureAssemblyDataModels.Models
|
||||||
{
|
{
|
||||||
// Интерфейс, отвечающий за исполнителя
|
// Модель исполнителя
|
||||||
public interface IImplementerModel : IId
|
public interface IImplementerModel : IId
|
||||||
{
|
{
|
||||||
string ImplementerFIO { get; }
|
string ImplementerFIO { get; }
|
||||||
|
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
|
|
||||||
int WorkExperience { get; }
|
int WorkExperience { get; }
|
||||||
|
|
||||||
int Qualification { get; }
|
int Qualification { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDataModels.Models
|
||||||
|
{
|
||||||
|
// Интерфейс сущности "Магазин"
|
||||||
|
public interface IShopModel : IId
|
||||||
|
{
|
||||||
|
// Название магазина
|
||||||
|
string ShopName { get; }
|
||||||
|
|
||||||
|
// Адрес магазина
|
||||||
|
string Address { get; }
|
||||||
|
|
||||||
|
// Дата открытия магазина
|
||||||
|
DateTime DateOpen { get; }
|
||||||
|
|
||||||
|
//максимальное кол-во изделий в магазине
|
||||||
|
int MaxCountFurnitures { get; }
|
||||||
|
|
||||||
|
// Изделия в магазине
|
||||||
|
Dictionary<int, (IFurnitureModel, int)> ShopFurnitures { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using FurnitureAssemblyDatabaseImplement.Models;
|
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -14,7 +15,7 @@ namespace FurnitureAssemblyDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
@ -28,6 +29,10 @@ namespace FurnitureAssemblyDatabaseImplement
|
|||||||
|
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<Shop> Shops { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<ShopFurniture> ShopFurnitures { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
|
@ -12,96 +12,120 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class ImplementerStorage : IImplementerStorage
|
public class ImplementerStorage : IImplementerStorage
|
||||||
{
|
{
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
if (model.Id.HasValue)
|
if (model.Id.HasValue)
|
||||||
return context.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
{
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
if (model.ImplementerFIO != null && model.Password != null)
|
return new();
|
||||||
return context.Implementers.FirstOrDefault(x => x.ImplementerFIO
|
}
|
||||||
.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
|
|
||||||
|
|
||||||
if (model.ImplementerFIO != null)
|
public List<ImplementerViewModel> GetFullList()
|
||||||
return context.Implementers.FirstOrDefault(x => x.ImplementerFIO
|
{
|
||||||
.Equals(model.ImplementerFIO))?.GetViewModel;
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
return null;
|
return context.Implementers
|
||||||
}
|
.Include(x => x.Orders)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ImplementerFIO != null)
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
{
|
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
|
||||||
|
|
||||||
return context.Implementers
|
return context.Implementers
|
||||||
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
.Include(x => x.Orders)
|
||||||
.Select(x => x.GetViewModel)
|
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
.ToList();
|
.Select(x => x.GetViewModel)
|
||||||
}
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
return new();
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
}
|
{
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFullList()
|
if (newImplementer == null)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
context.Implementers.Add(newImplementer);
|
||||||
{
|
context.SaveChanges();
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
|
||||||
|
|
||||||
var res = Implementer.Create(model);
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => x.Id == newImplementer.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
if (res != null)
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
context.Implementers.Add(res);
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
return res?.GetViewModel;
|
var order = context.Implementers
|
||||||
}
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
if (order == null)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
order.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
if (res != null)
|
return context.Implementers
|
||||||
{
|
.Include(x => x.Orders)
|
||||||
res.Update(model);
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
context.SaveChanges();
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res?.GetViewModel;
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
}
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
var element = context.Implementers
|
||||||
{
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
|
||||||
|
|
||||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
if (element != null)
|
||||||
|
{
|
||||||
|
// для отображения КОРРЕКТНОЙ ViewModel-и
|
||||||
|
var deletedElement = context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
|
||||||
if (res != null)
|
context.Implementers.Remove(element);
|
||||||
{
|
context.SaveChanges();
|
||||||
context.Implementers.Remove(res);
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
return res?.GetViewModel;
|
return deletedElement;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,45 +16,56 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
|
if (model.ImplementerId.HasValue && model.Status.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return context.Orders
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
return context.Orders.Include(x => x.Furniture)
|
}
|
||||||
.Include(x => x.Client).Include(x => x.Implementer)
|
|
||||||
.FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
|
|
||||||
(model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
|
||||||
|
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.Orders
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
|
||||||
x.ClientId == model.ClientId || model.Status.Equals(x.Status))
|
|
||||||
.Include(x => x.Furniture).Include(x => x.Client)
|
|
||||||
.Include(x => x.Implementer).Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
}
|
return context.Orders
|
||||||
|
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
||||||
|
x.ClientId == model.ClientId || model.Status.Equals(x.Status))
|
||||||
|
.Include(x => x.Furniture)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
return context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
||||||
.Include(x => x.Implementer)
|
.Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
|
||||||
.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -67,22 +78,17 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
return context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
||||||
.Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
.Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
var order = context.Orders
|
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
.Include(x => x.Furniture)
|
|
||||||
.Include(x => x.Client)
|
|
||||||
.Include(x => x.Implementer)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
@ -92,24 +98,23 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
|||||||
order.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
return context.Orders
|
return context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
||||||
.Include(x => x.Furniture)
|
.Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
.Include(x => x.Client)
|
|
||||||
.Include(x => x.Implementer)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new FurnitureAssemblyDatabase();
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
var element = context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
// для более корректного отображения модели
|
// для отображения корректной ViewModel-и
|
||||||
var deletedElement = context.Orders.Include(x => x.Furniture).Include(x => x.Client)
|
var deletedElement = context.Orders
|
||||||
.Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
.Include(x => x.Furniture)
|
||||||
|
.Include(x => x.Client).Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
@ -0,0 +1,179 @@
|
|||||||
|
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
|
return context.Shops
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.ThenInclude(x => x.Furniture)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
|
return context.Shops
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.ThenInclude(x => x.Furniture)
|
||||||
|
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
|
return context.Shops
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.ThenInclude(x => x.Furniture)
|
||||||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var newShop = Shop.Create(context, model);
|
||||||
|
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Shops.Add(newShop);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shop = context.Shops.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
shop.UpdateFurnitures(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
|
||||||
|
var element = context.Shops
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Shops.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SellFurnitures(IFurnitureModel model, int count)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shops = context.ShopFurnitures
|
||||||
|
.Include(x => x.Shop)
|
||||||
|
.ToList()
|
||||||
|
.Where(rec => rec.FurnitureId == model.Id);
|
||||||
|
|
||||||
|
if (shops == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
if (shop.Count < count)
|
||||||
|
{
|
||||||
|
count -= shop.Count;
|
||||||
|
shop.Count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.Count = shop.Count - count;
|
||||||
|
count -= count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Rollback();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,257 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FurnitureAssemblyDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
|
||||||
[Migration("20240511191901_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.16")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Client", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClientFIO")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Clients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("FurnitureName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Furnitures");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureWorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("FurnitureId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkPieceId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("FurnitureId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkPieceId");
|
|
||||||
|
|
||||||
b.ToTable("FurnitureWorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Implementer", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ImplementerFIO")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Qualification")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkExperience")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Implementers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("FurnitureId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("ImplementerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("FurnitureId");
|
|
||||||
|
|
||||||
b.HasIndex("ImplementerId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("WorkPieceName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("WorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureWorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
|
||||||
.WithMany("WorkPieces")
|
|
||||||
.HasForeignKey("FurnitureId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", "WorkPiece")
|
|
||||||
.WithMany("FurnitureWorkPieces")
|
|
||||||
.HasForeignKey("WorkPieceId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Furniture");
|
|
||||||
|
|
||||||
b.Navigation("WorkPiece");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Client", "Client")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("ClientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("FurnitureId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Implementer", "Implementer")
|
|
||||||
.WithMany("Order")
|
|
||||||
.HasForeignKey("ImplementerId");
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
|
||||||
|
|
||||||
b.Navigation("Furniture");
|
|
||||||
|
|
||||||
b.Navigation("Implementer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Client", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
|
||||||
|
|
||||||
b.Navigation("WorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Implementer", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Order");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("FurnitureWorkPieces");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Clients",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Furnitures",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
FurnitureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Furnitures", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Implementers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "WorkPieces",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
WorkPieceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Cost = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_WorkPieces", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
FurnitureId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
|
||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
column: x => x.ClientId,
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Furnitures_FurnitureId",
|
|
||||||
column: x => x.FurnitureId,
|
|
||||||
principalTable: "Furnitures",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Implementers_ImplementerId",
|
|
||||||
column: x => x.ImplementerId,
|
|
||||||
principalTable: "Implementers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "FurnitureWorkPieces",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
FurnitureId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
WorkPieceId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_FurnitureWorkPieces", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_FurnitureWorkPieces_Furnitures_FurnitureId",
|
|
||||||
column: x => x.FurnitureId,
|
|
||||||
principalTable: "Furnitures",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_FurnitureWorkPieces_WorkPieces_WorkPieceId",
|
|
||||||
column: x => x.WorkPieceId,
|
|
||||||
principalTable: "WorkPieces",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_FurnitureWorkPieces_FurnitureId",
|
|
||||||
table: "FurnitureWorkPieces",
|
|
||||||
column: "FurnitureId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_FurnitureWorkPieces_WorkPieceId",
|
|
||||||
table: "FurnitureWorkPieces",
|
|
||||||
column: "WorkPieceId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_FurnitureId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "FurnitureId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ImplementerId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ImplementerId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "FurnitureWorkPieces");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "WorkPieces");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Clients");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Furnitures");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Implementers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,254 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FurnitureAssemblyDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
|
||||||
partial class FurnitureAssemblyDatabaseModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.16")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Client", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClientFIO")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Clients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("FurnitureName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Furnitures");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureWorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("FurnitureId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkPieceId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("FurnitureId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkPieceId");
|
|
||||||
|
|
||||||
b.ToTable("FurnitureWorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Implementer", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ImplementerFIO")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Qualification")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkExperience")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Implementers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("FurnitureId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("ImplementerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("FurnitureId");
|
|
||||||
|
|
||||||
b.HasIndex("ImplementerId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("WorkPieceName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("WorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureWorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
|
||||||
.WithMany("WorkPieces")
|
|
||||||
.HasForeignKey("FurnitureId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", "WorkPiece")
|
|
||||||
.WithMany("FurnitureWorkPieces")
|
|
||||||
.HasForeignKey("WorkPieceId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Furniture");
|
|
||||||
|
|
||||||
b.Navigation("WorkPiece");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Client", "Client")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("ClientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("FurnitureId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Implementer", "Implementer")
|
|
||||||
.WithMany("Order")
|
|
||||||
.HasForeignKey("ImplementerId");
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
|
||||||
|
|
||||||
b.Navigation("Furniture");
|
|
||||||
|
|
||||||
b.Navigation("Implementer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Client", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
|
||||||
|
|
||||||
b.Navigation("WorkPieces");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Implementer", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Order");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.WorkPiece", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("FurnitureWorkPieces");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,8 +34,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return new()
|
||||||
return new Client()
|
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientFIO = model.ClientFIO,
|
ClientFIO = model.ClientFIO,
|
||||||
@ -50,7 +49,6 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientFIO = model.ClientFIO;
|
ClientFIO = model.ClientFIO;
|
||||||
Email = model.Email;
|
Email = model.Email;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
@ -61,7 +59,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
ClientFIO = ClientFIO,
|
ClientFIO = ClientFIO,
|
||||||
Email = Email,
|
Email = Email,
|
||||||
Password = Password
|
Password = Password,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
[ForeignKey("FurnitureId")]
|
[ForeignKey("FurnitureId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
[ForeignKey("FurnitureId")]
|
||||||
|
public virtual List<ShopFurniture> Shops { get; set; } = new();
|
||||||
|
|
||||||
public static Furniture Create(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
public static Furniture Create(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||||
{
|
{
|
||||||
return new Furniture()
|
return new Furniture()
|
||||||
@ -76,9 +79,6 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
FurnitureWorkPieces = FurnitureWorkPieces
|
FurnitureWorkPieces = FurnitureWorkPieces
|
||||||
};
|
};
|
||||||
|
|
||||||
Dictionary<int, (IWorkPieceModel, int)> IFurnitureModel.FurnitureWorkPieces => throw new NotImplementedException();
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateWorkPieces(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
public void UpdateWorkPieces(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||||
{
|
{
|
||||||
var furnitureWorkPieces = context.FurnitureWorkPieces.Where(rec => rec.FurnitureId == model.Id).ToList();
|
var furnitureWorkPieces = context.FurnitureWorkPieces.Where(rec => rec.FurnitureId == model.Id).ToList();
|
||||||
@ -101,13 +101,13 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
|||||||
|
|
||||||
var furniture = context.Furnitures.First(x => x.Id == Id);
|
var furniture = context.Furnitures.First(x => x.Id == Id);
|
||||||
|
|
||||||
foreach(var pc in model.FurnitureWorkPieces)
|
foreach(var mwp in model.FurnitureWorkPieces)
|
||||||
{
|
{
|
||||||
context.FurnitureWorkPieces.Add(new FurnitureWorkPiece
|
context.FurnitureWorkPieces.Add(new FurnitureWorkPiece
|
||||||
{
|
{
|
||||||
Furniture = furniture,
|
Furniture = furniture,
|
||||||
WorkPiece = context.WorkPieces.First(x => x.Id == pc.Key),
|
WorkPiece = context.WorkPieces.First(x => x.Id == mwp.Key),
|
||||||
Count = pc.Value.Item2
|
Count = mwp.Value.Item2
|
||||||
});
|
});
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
@ -11,76 +11,76 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
// Для реализации связи один ко многим с заказами
|
//для реализации связи один ко многим с заказами
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
public virtual List<Order> Order { get; set; } = new();
|
public virtual List<Order> Order { get; set; } = new();
|
||||||
|
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Implementer()
|
return new Implementer()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Password = model.Password,
|
Password = model.Password,
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
Qualification = model.Qualification,
|
Qualification = model.Qualification,
|
||||||
WorkExperience = model.WorkExperience
|
WorkExperience = model.WorkExperience
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Implementer Create(ImplementerViewModel model)
|
public static Implementer Create(ImplementerViewModel model)
|
||||||
{
|
{
|
||||||
return new Implementer
|
return new Implementer
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Password = model.Password,
|
Password = model.Password,
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
Qualification = model.Qualification,
|
Qualification = model.Qualification,
|
||||||
WorkExperience = model.WorkExperience
|
WorkExperience = model.WorkExperience
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(ImplementerBindingModel model)
|
public void Update(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id = model.Id;
|
Id = model.Id;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
ImplementerFIO = model.ImplementerFIO;
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
Qualification = model.Qualification;
|
Qualification = model.Qualification;
|
||||||
WorkExperience = model.WorkExperience;
|
WorkExperience = model.WorkExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel GetViewModel => new()
|
public ImplementerViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Password = Password,
|
Password = Password,
|
||||||
ImplementerFIO = ImplementerFIO,
|
ImplementerFIO = ImplementerFIO,
|
||||||
Qualification = Qualification,
|
Qualification = Qualification,
|
||||||
WorkExperience = WorkExperience
|
WorkExperience = WorkExperience
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDatabaseImplement;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime DateOpen { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int MaxCountFurnitures { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, (IFurnitureModel, int)>? _shopFurnitures = null;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> ShopFurnitures
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopFurnitures == null)
|
||||||
|
{
|
||||||
|
_shopFurnitures = new();
|
||||||
|
|
||||||
|
Furnitures.ForEach(x =>
|
||||||
|
{
|
||||||
|
if (_shopFurnitures.ContainsKey(x.FurnitureId))
|
||||||
|
{
|
||||||
|
_shopFurnitures[x.FurnitureId] = (x.Furniture as IFurnitureModel, _shopFurnitures[x.FurnitureId].Item2 + x.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_shopFurnitures[x.FurnitureId] = (x.Furniture as IFurnitureModel, x.Count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return _shopFurnitures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("ShopId")]
|
||||||
|
public virtual List<ShopFurniture> Furnitures { get; set; } = new();
|
||||||
|
|
||||||
|
public static Shop? Create(FurnitureAssemblyDatabase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Address = model.Address,
|
||||||
|
DateOpen = model.DateOpen,
|
||||||
|
Furnitures = model.ShopFurnitures.Select(x => new ShopFurniture
|
||||||
|
{
|
||||||
|
Furniture = context.Furnitures.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList(),
|
||||||
|
MaxCountFurnitures = model.MaxCountFurnitures
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
DateOpen = model.DateOpen;
|
||||||
|
MaxCountFurnitures = model.MaxCountFurnitures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
DateOpen = DateOpen,
|
||||||
|
MaxCountFurnitures = MaxCountFurnitures,
|
||||||
|
ShopFurnitures = ShopFurnitures
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateFurnitures(FurnitureAssemblyDatabase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shopFurnitures = context.ShopFurnitures.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
|
|
||||||
|
if (shopFurnitures != null && shopFurnitures.Count > 0)
|
||||||
|
{ // удалили те, которых нет в модели
|
||||||
|
context.ShopFurnitures.RemoveRange(shopFurnitures.Where(rec => !model.ShopFurnitures.ContainsKey(rec.FurnitureId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
// обновили количество у существующих записей
|
||||||
|
foreach (var _shopFurnitures in shopFurnitures)
|
||||||
|
{
|
||||||
|
_shopFurnitures.Count = model.ShopFurnitures[_shopFurnitures.FurnitureId].Item2;
|
||||||
|
model.ShopFurnitures.Remove(_shopFurnitures.FurnitureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
var shop = context.Shops.First(x => x.Id == Id);
|
||||||
|
|
||||||
|
foreach (var sm in model.ShopFurnitures)
|
||||||
|
{
|
||||||
|
context.ShopFurnitures.Add(new ShopFurniture
|
||||||
|
{
|
||||||
|
Shop = shop,
|
||||||
|
Furniture = context.Furnitures.First(x => x.Id == sm.Key),
|
||||||
|
Count = sm.Value.Item2
|
||||||
|
});
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopFurnitures = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ShopFurniture
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ShopId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int FurnitureId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public virtual Shop Shop { get; set; } = new();
|
||||||
|
|
||||||
|
public virtual Furniture Furniture { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,8 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
private readonly string FurnitureFileName = "Furniture.xml";
|
private readonly string FurnitureFileName = "Furniture.xml";
|
||||||
|
|
||||||
|
private readonly string ShopFileName = "Shop.xml";
|
||||||
|
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
|
||||||
private readonly string ImplementerFileName = "Implementer.xml";
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
@ -28,6 +30,8 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
public List<Furniture> Furnitures { get; private set; }
|
public List<Furniture> Furnitures { get; private set; }
|
||||||
|
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
|
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
|
||||||
public List<Implementer> Implementers { get; private set; }
|
public List<Implementer> Implementers { get; private set; }
|
||||||
@ -48,18 +52,21 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
|
||||||
|
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||||
|
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
|
|
||||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
public void SaveImplementers() => SaveData(Orders, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||||
|
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!;
|
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!;
|
||||||
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
|
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Impleneter", x => Implementer.Create(x)!)!;
|
||||||
|
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
@ -74,7 +81,7 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
||||||
{
|
{
|
||||||
if (data != null)
|
if(data != null)
|
||||||
{
|
{
|
||||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||||
}
|
}
|
||||||
|
@ -11,102 +11,74 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyFileImplement.Implements
|
namespace FurnitureAssemblyFileImplement.Implements
|
||||||
{
|
{
|
||||||
public class ImplementerStorage : IImplementerStorage
|
public class ImplementerStorage : IImplementerStorage
|
||||||
{
|
{
|
||||||
private readonly DataFileSingleton source;
|
private readonly DataFileSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue) return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null && model.Password != null) return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null) return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ImplementerStorage()
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
source = DataFileSingleton.GetInstance();
|
if (model == null)
|
||||||
}
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.ImplementerFIO != null)
|
||||||
|
{
|
||||||
|
return _source.Implementers
|
||||||
|
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
public List<ImplementerViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue)
|
return _source.Implementers.Select(x => x.GetViewModel).ToList();
|
||||||
return source.Implementers
|
}
|
||||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
|
||||||
|
|
||||||
if (model.ImplementerFIO != null && model.Password != null)
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
return source.Implementers.FirstOrDefault(x => x.ImplementerFIO
|
{
|
||||||
.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
|
model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1;
|
||||||
|
var res = Implementer.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Implementers.Add(res);
|
||||||
|
_source.SaveImplementers();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
if (model.ImplementerFIO != null)
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
return source.Implementers
|
{
|
||||||
.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
|
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Update(model);
|
||||||
|
_source.SaveImplementers();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
}
|
{
|
||||||
|
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
public List<ImplementerViewModel> GetFullList()
|
{
|
||||||
{
|
_source.Implementers.Remove(res);
|
||||||
return source.Implementers.Select(x => x.GetViewModel).ToList();
|
_source.SaveImplementers();
|
||||||
}
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
}
|
||||||
{
|
}
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.ImplementerFIO != null)
|
|
||||||
{
|
|
||||||
return source.Implementers
|
|
||||||
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x => x.Id) + 1 : 1;
|
|
||||||
|
|
||||||
var newImplementer = Implementer.Create(model);
|
|
||||||
|
|
||||||
if (newImplementer == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
source.Implementers.Add(newImplementer);
|
|
||||||
source.SaveImplementers();
|
|
||||||
|
|
||||||
return newImplementer.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (implementer == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
implementer.Update(model);
|
|
||||||
source.SaveImplementers();
|
|
||||||
|
|
||||||
return implementer.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Implementers.Remove(element);
|
|
||||||
source.SaveImplementers();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,21 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ImplementerId.HasValue && model.Status != null)
|
if (model.ImplementerId.HasValue && model.Status.HasValue)
|
||||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status
|
{
|
||||||
.Equals(x.Status))?.GetViewModel;
|
return source.Orders
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
return source.Orders
|
if (model.ImplementerId.HasValue)
|
||||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
{
|
||||||
|
return source.Orders
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -54,7 +63,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Для загрузки названий изделия и исполнителя в заказе
|
// Для загрузки названий изделия в заказе
|
||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var viewModel = order.GetViewModel;
|
var viewModel = order.GetViewModel;
|
||||||
@ -63,9 +72,9 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
|
|
||||||
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||||
|
|
||||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == order.ImplementerId);
|
var implementer = source.Implementers.FirstOrDefault(x => x.Id == order.ImplementerId);
|
||||||
|
|
||||||
if (furniture != null)
|
if (furniture != null)
|
||||||
{
|
{
|
||||||
viewModel.FurnitureName = furniture.FurnitureName;
|
viewModel.FurnitureName = furniture.FurnitureName;
|
||||||
}
|
}
|
||||||
@ -75,12 +84,12 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
viewModel.ClientFIO = client.ClientFIO;
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (implementer != null)
|
if (implementer != null)
|
||||||
{
|
{
|
||||||
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -104,7 +113,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
{
|
{
|
||||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
if(order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -119,7 +128,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
|||||||
{
|
{
|
||||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
if(order != null)
|
if (order != null)
|
||||||
{
|
{
|
||||||
source.Orders.Remove(order);
|
source.Orders.Remove(order);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
|
@ -0,0 +1,139 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using FurnitureAssemblyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Implements
|
||||||
|
{
|
||||||
|
// Реализация интерфейса хранилища магазинов
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.Shops.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _source.Shops.Where(x => x.ShopName.Contains(model.ShopName))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _source.Shops.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName)
|
||||||
|
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = _source.Shops.Count > 0 ? _source.Shops.Max(x => x.Id) + 1 : 1;
|
||||||
|
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_source.Shops.Add(newShop);
|
||||||
|
_source.SaveShops();
|
||||||
|
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = _source.Shops.FirstOrDefault(x => x.ShopName.Contains(model.ShopName) || x.Id == model.Id);
|
||||||
|
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.Update(model);
|
||||||
|
_source.SaveShops();
|
||||||
|
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
_source.Shops.Remove(element);
|
||||||
|
_source.SaveShops();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SellFurnitures(IFurnitureModel model, int count)
|
||||||
|
{
|
||||||
|
if (_source.Shops.Select(x => x.ShopFurnitures.FirstOrDefault(x => x.Key == model.Id).Value.Item2).Sum() < count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = _source.Shops.Where(x => x.ShopFurnitures.ContainsKey(model.Id));
|
||||||
|
|
||||||
|
foreach (var shop in list)
|
||||||
|
{
|
||||||
|
if (shop.ShopFurnitures[model.Id].Item2 < count)
|
||||||
|
{
|
||||||
|
count -= shop.ShopFurnitures[model.Id].Item2;
|
||||||
|
shop.ShopFurnitures[model.Id] = (shop.ShopFurnitures[model.Id].Item1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.ShopFurnitures[model.Id] = (shop.ShopFurnitures[model.Id].Item1, shop.ShopFurnitures[model.Id].Item2 - count);
|
||||||
|
count -= count;
|
||||||
|
}
|
||||||
|
|
||||||
|
Update(new()
|
||||||
|
{
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Address = shop.Address,
|
||||||
|
DateOpen = shop.DateOpen,
|
||||||
|
MaxCountFurnitures = shop.MaxCountFurnitures,
|
||||||
|
ShopFurnitures = shop.ShopFurnitures
|
||||||
|
});
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,80 +10,76 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyFileImplement.Models
|
namespace FurnitureAssemblyFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(XElement element)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ImplementerFIO = element.Element("FIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return new Implementer()
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
if (model == null)
|
||||||
Password = model.Password,
|
{
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
return null;
|
||||||
Qualification = model.Qualification,
|
}
|
||||||
WorkExperience = model.WorkExperience
|
return new()
|
||||||
};
|
{
|
||||||
}
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static Implementer? Create(XElement element)
|
public void Update(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
if (element == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
return new Implementer()
|
public ImplementerViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Id,
|
||||||
Password = element.Element("Password")!.Value,
|
ImplementerFIO = ImplementerFIO,
|
||||||
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
Password = Password,
|
||||||
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
Qualification = Qualification,
|
||||||
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(ImplementerBindingModel model)
|
public XElement GetXElement => new("Client",
|
||||||
{
|
new XAttribute("Id", Id),
|
||||||
if (model == null)
|
new XElement("FIO", ImplementerFIO),
|
||||||
{
|
new XElement("Password", Password),
|
||||||
return;
|
new XElement("Qualification", Qualification),
|
||||||
}
|
new XElement("WorkExperience", WorkExperience)
|
||||||
|
);
|
||||||
Id = model.Id;
|
}
|
||||||
Password = model.Password;
|
|
||||||
ImplementerFIO = model.ImplementerFIO;
|
|
||||||
Qualification = model.Qualification;
|
|
||||||
WorkExperience = model.WorkExperience;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
Password = Password,
|
|
||||||
ImplementerFIO = ImplementerFIO,
|
|
||||||
Qualification = Qualification,
|
|
||||||
WorkExperience = WorkExperience
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new("Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("Password", Password),
|
|
||||||
new XElement("ImplementerFIO", ImplementerFIO),
|
|
||||||
new XElement("Qualification", Qualification),
|
|
||||||
new XElement("WorkExperience", WorkExperience));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
|
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
||||||
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
@ -82,6 +82,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
}
|
}
|
||||||
@ -92,6 +93,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
|
ImplementerFIO = DataFileSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
@ -103,7 +105,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("FurnitureId", FurnitureId.ToString()),
|
new XElement("FurnitureId", FurnitureId.ToString()),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("ImplementerId", ImplementerId.ToString()),
|
new XElement("ImplementerId", ImplementerId),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
|
111
FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Shop.cs
Normal file
111
FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Models
|
||||||
|
{
|
||||||
|
// Класс, реализующий интерфейс модели магазина
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateOpen { get; set; }
|
||||||
|
|
||||||
|
public int MaxCountFurnitures { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, int> countFurniture { get; private set; } = new();
|
||||||
|
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> _furnitures = null;
|
||||||
|
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> ShopFurnitures
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_furnitures == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_furnitures = countFurniture.ToDictionary(x => x.Key, y => ((source.Furnitures.FirstOrDefault(z => z.Id == y.Key) as IFurnitureModel)!, y.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _furnitures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shop? Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Address = model.Address,
|
||||||
|
DateOpen = model.DateOpen,
|
||||||
|
MaxCountFurnitures = model.MaxCountFurnitures,
|
||||||
|
countFurniture = model.ShopFurnitures.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Shop? Create(XElement element)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ShopName = element.Element("ShopName")!.Value,
|
||||||
|
Address = element.Element("Address")!.Value,
|
||||||
|
DateOpen = Convert.ToDateTime(element.Element("DateOpen")!.Value),
|
||||||
|
MaxCountFurnitures = Convert.ToInt32(element.Element("MaxCountFurnitures")!.Value),
|
||||||
|
countFurniture = element.Element("Furnitures")!.Elements("Furnitures").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
DateOpen = model.DateOpen;
|
||||||
|
MaxCountFurnitures = model.MaxCountFurnitures;
|
||||||
|
countFurniture = model.ShopFurnitures.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_furnitures = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
DateOpen = DateOpen,
|
||||||
|
MaxCountFurnitures = MaxCountFurnitures,
|
||||||
|
ShopFurnitures = ShopFurnitures
|
||||||
|
};
|
||||||
|
public XElement GetXElement => new("Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ShopName", ShopName),
|
||||||
|
new XElement("Address", Address),
|
||||||
|
new XElement("DateOpen", DateOpen.ToString()),
|
||||||
|
new XElement("MaxCountFurnitures", MaxCountFurnitures.ToString()),
|
||||||
|
new XElement("Furnitures", countFurniture.Select(x => new XElement("Furnitures",
|
||||||
|
new XElement("Key", x.Key),
|
||||||
|
new XElement("Value", x.Value))).ToArray()));
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,10 @@ namespace FurnitureAssemblyListImplement
|
|||||||
// Список для хранения заказов
|
// Список для хранения заказов
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
|
|
||||||
// Список для хранения клиентов
|
// Список для хранения Магазинов
|
||||||
|
public List<Shop> Shops { get; set; }
|
||||||
|
|
||||||
|
// Список для хранения Клиентов
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
|
||||||
// Список для хранения исполнителей
|
// Список для хранения исполнителей
|
||||||
@ -32,13 +35,14 @@ namespace FurnitureAssemblyListImplement
|
|||||||
WorkPiece = new List<WorkPiece>();
|
WorkPiece = new List<WorkPiece>();
|
||||||
Furnitures = new List<Furniture>();
|
Furnitures = new List<Furniture>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
|
Shops = new List<Shop>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
Implementers = new List<Implementer>();
|
Implementers = new List<Implementer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (_instance == null)
|
if(_instance == null)
|
||||||
{
|
{
|
||||||
_instance = new DataListSingleton();
|
_instance = new DataListSingleton();
|
||||||
}
|
}
|
||||||
|
@ -11,120 +11,120 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyListImplement.Implements
|
namespace FurnitureAssemblyListImplement.Implements
|
||||||
{
|
{
|
||||||
public class ImplementerStorage : IImplementerStorage
|
public class ImplementerStorage : IImplementerStorage
|
||||||
{
|
{
|
||||||
// Поле для работы со списком исполнителей
|
// Поле для работы со списком исполнителей
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
public ImplementerStorage()
|
public ImplementerStorage()
|
||||||
{
|
{
|
||||||
_source = DataListSingleton.GetInstance();
|
_source = DataListSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFullList()
|
public List<ImplementerViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
var result = new List<ImplementerViewModel>();
|
var result = new List<ImplementerViewModel>();
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
result.Add(implementer.GetViewModel);
|
result.Add(implementer.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<ImplementerViewModel>();
|
var result = new List<ImplementerViewModel>();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
{
|
{
|
||||||
result.Add(implementer.GetViewModel);
|
result.Add(implementer.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
if ((!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO) ||
|
if ((!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO) ||
|
||||||
(model.Id.HasValue && implementer.Id == model.Id))
|
(model.Id.HasValue && implementer.Id == model.Id))
|
||||||
{
|
{
|
||||||
return implementer.GetViewModel;
|
return implementer.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = 1;
|
model.Id = 1;
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
if (model.Id <= implementer.Id)
|
if (model.Id <= implementer.Id)
|
||||||
{
|
{
|
||||||
model.Id = implementer.Id + 1;
|
model.Id = implementer.Id + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newImplementer = Implementer.Create(model);
|
var newImplementer = Implementer.Create(model);
|
||||||
|
|
||||||
if (newImplementer == null)
|
if (newImplementer == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_source.Implementers.Add(newImplementer);
|
_source.Implementers.Add(newImplementer);
|
||||||
|
|
||||||
return newImplementer.GetViewModel;
|
return newImplementer.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
if (implementer.Id == model.Id)
|
if (implementer.Id == model.Id)
|
||||||
{
|
{
|
||||||
implementer.Update(model);
|
implementer.Update(model);
|
||||||
|
|
||||||
return implementer.GetViewModel;
|
return implementer.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _source.Implementers.Count; ++i)
|
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_source.Implementers[i].Id == model.Id)
|
if (_source.Implementers[i].Id == model.Id)
|
||||||
{
|
{
|
||||||
var element = _source.Implementers[i];
|
var element = _source.Implementers[i];
|
||||||
_source.Implementers.RemoveAt(i);
|
_source.Implementers.RemoveAt(i);
|
||||||
|
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
|
|
||||||
foreach(var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(GetViewModel(order));
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
@ -41,12 +41,19 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
|
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else if (model.ClientId.HasValue)
|
||||||
if (model.ClientId.HasValue)
|
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
@ -55,17 +62,27 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
result.Add(GetViewModel(order));
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
return result;
|
||||||
|
}
|
||||||
|
else if (model.Status.HasValue)
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
if (order.Status == model.Status)
|
||||||
{
|
{
|
||||||
result.Add(GetViewModel(order));
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Id == model.Id)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -90,7 +107,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Метод для записи названия изделия на форме с заказами и исполнителя
|
// Метод для записи названия изделия на форме с заказами
|
||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var viewModel = order.GetViewModel;
|
var viewModel = order.GetViewModel;
|
||||||
@ -114,17 +131,18 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
foreach (var implementer in _source.Implementers)
|
||||||
{
|
{
|
||||||
if (implementer.Id == order.ImplementerId)
|
if (implementer.Id == order.ImplementerId)
|
||||||
{
|
{
|
||||||
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return viewModel;
|
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// При создании заказа определяем для него новый id: ищем max id и прибавляем к нему 1
|
// При создании заказа определяем для него новый id: ищем max id и прибавляем к нему 1
|
||||||
|
@ -0,0 +1,143 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using FurnitureAssemblyListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyListImplement.Implements
|
||||||
|
{
|
||||||
|
// Класс, реализующий интерфейс хранилища магазинов
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
// Поле для работы со списком магазинов
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
// Получение в конструкторе объекта DataListSingleton
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение элемента из списка заготовок
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
||||||
|
{
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение отфильтрованного списка заказов
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.ShopName.Contains(model.ShopName))
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение полного списка заготовок
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// При создании магазина определяем для него новый id: ищем max id и прибавляем к нему 1
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (model.Id <= shop.Id)
|
||||||
|
{
|
||||||
|
model.Id = shop.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_source.Shops.Add(newShop);
|
||||||
|
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обновление магазина
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.Id == model.Id)
|
||||||
|
{
|
||||||
|
shop.Update(model);
|
||||||
|
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Удаление магазина
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Shops[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Shops[i];
|
||||||
|
_source.Shops.RemoveAt(i);
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SellFurnitures(IFurnitureModel model, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,58 +9,58 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyListImplement.Models
|
namespace FurnitureAssemblyListImplement.Models
|
||||||
{
|
{
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
// Метод для создания объекта от класса-компонента на основе класса-BindingModel
|
// Метод для создания объекта от класса-компонента на основе класса-BindingModel
|
||||||
public static Implementer? Create(ImplementerBindingModel? model)
|
public static Implementer? Create(ImplementerBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Implementer()
|
return new Implementer()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Password = model.Password,
|
Password = model.Password,
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
Qualification = model.Qualification,
|
Qualification = model.Qualification,
|
||||||
WorkExperience = model.WorkExperience
|
WorkExperience = model.WorkExperience
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Метод изменения существующего объекта
|
// Метод изменения существующего объекта
|
||||||
public void Update(ImplementerBindingModel? model)
|
public void Update(ImplementerBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
ImplementerFIO = model.ImplementerFIO;
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
Qualification = model.Qualification;
|
Qualification = model.Qualification;
|
||||||
WorkExperience = model.WorkExperience;
|
WorkExperience = model.WorkExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
||||||
public ImplementerViewModel GetViewModel => new()
|
public ImplementerViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Password = Password,
|
Password = Password,
|
||||||
ImplementerFIO = ImplementerFIO,
|
ImplementerFIO = ImplementerFIO,
|
||||||
Qualification = Qualification,
|
Qualification = Qualification,
|
||||||
WorkExperience = WorkExperience
|
WorkExperience = WorkExperience
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyListImplement.Models
|
||||||
|
{
|
||||||
|
// Класс, реализующий интерфейс модели магазина
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
// Методы set сделали приватными, чтобы исключить неразрешённые манипуляции
|
||||||
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateOpen { get; private set; }
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int MaxCountFurnitures { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (IFurnitureModel, int)> ShopFurnitures { get; private set; } =
|
||||||
|
new Dictionary<int, (IFurnitureModel, int)>();
|
||||||
|
|
||||||
|
// Метод для создания объекта от класса-компонента на основе класса-BindingModel
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Address = model.Address,
|
||||||
|
DateOpen = model.DateOpen,
|
||||||
|
ShopFurnitures = model.ShopFurnitures
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Метод изменения существующего объекта
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
DateOpen = model.DateOpen;
|
||||||
|
ShopFurnitures = model.ShopFurnitures;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
DateOpen = DateOpen,
|
||||||
|
ShopFurnitures = ShopFurnitures
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -7,106 +7,106 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyRestApi.Controllers
|
namespace FurnitureAssemblyRestApi.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class ImplementerController : Controller
|
public class ImplementerController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IOrderLogic _order;
|
private readonly IOrderLogic _order;
|
||||||
|
|
||||||
private readonly IImplementerLogic _logic;
|
private readonly IImplementerLogic _logic;
|
||||||
|
|
||||||
public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger<ImplementerController> logger)
|
public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger<ImplementerController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_order = order;
|
_order = order;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ImplementerViewModel? Login(string login, string password)
|
public ImplementerViewModel? Login(string login, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _logic.ReadElement(new ImplementerSearchModel
|
return _logic.ReadElement(new ImplementerSearchModel
|
||||||
{
|
{
|
||||||
ImplementerFIO = login,
|
ImplementerFIO = login,
|
||||||
Password = password
|
Password = password
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<OrderViewModel>? GetNewOrders()
|
public List<OrderViewModel>? GetNewOrders()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _order.ReadList(new OrderSearchModel
|
return _order.ReadList(new OrderSearchModel
|
||||||
{
|
{
|
||||||
Status = OrderStatus.Принят
|
Status = OrderStatus.Принят
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения новых заказов");
|
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public OrderViewModel? GetImplementerOrder(int implementerId)
|
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _order.ReadElement(new OrderSearchModel
|
return _order.ReadElement(new OrderSearchModel
|
||||||
{
|
{
|
||||||
ImplementerId = implementerId
|
ImplementerId = implementerId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void TakeOrderInWork(OrderBindingModel model)
|
public void TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_order.TakeOrderInWork(model);
|
_order.TakeOrderInWork(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id);
|
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void FinishOrder(OrderBindingModel model)
|
public void FinishOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_order.FinishOrder(model);
|
_order.FinishOrder(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ShopController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IShopLogic _shop;
|
||||||
|
|
||||||
|
public ShopController(ILogger<ShopController> logger, IShopLogic shopLogic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shop = shopLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ShopViewModel>? GetShopList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<ShopViewModel> shops = _shop.ReadList(null);
|
||||||
|
for (int i = 0; i < shops.Count; i++)
|
||||||
|
shops[i].FurnitureCount = shops[i].ShopFurnitures.Values.ToList().Select(x => (x.Item1.FurnitureName, x.Item2).ToTuple()).ToList();
|
||||||
|
return shops;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ShopViewModel? GetShop(int shopId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _shop.ReadElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = shopId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения магазина по id={Id}", shopId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateShop(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shop.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateShop(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shop.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteShop(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shop.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SupplyFurnituresToShop(Tuple<ShopSearchModel, FurnitureBindingModel, int> shop_furniture)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shop.AddFurniture(shop_furniture.Item1, shop_furniture.Item2, shop_furniture.Item3);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка пополнения магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -16,11 +16,13 @@ builder.Logging.AddLog4Net("log4net.config");
|
|||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
builder.Services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
||||||
|
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
builder.Services.AddTransient<IFurnitureLogic, FurnitureLogic>();
|
builder.Services.AddTransient<IFurnitureLogic, FurnitureLogic>();
|
||||||
|
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"applicationUrl": "https://localhost:7159;http://localhost:5159"
|
"applicationUrl": "https://localhost:7199;http://localhost:5159"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -24,8 +24,8 @@
|
|||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:25080",
|
"applicationUrl": "http://localhost:46342",
|
||||||
"sslPort": 44382
|
"sslPort": 44378
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
66
FurnitureAssembly/FurnitureAssemblyShopApp/APIClient.cs
Normal file
66
FurnitureAssembly/FurnitureAssemblyShopApp/APIClient.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyShopApp
|
||||||
|
{
|
||||||
|
public static class APIClient
|
||||||
|
{
|
||||||
|
private static readonly HttpClient _client = new();
|
||||||
|
|
||||||
|
public static bool isAuth { get; private set; } = false;
|
||||||
|
|
||||||
|
public static string ConfigPassword { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static bool Login(string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
throw new Exception("Enter the password");
|
||||||
|
}
|
||||||
|
|
||||||
|
return isAuth = password.Equals(ConfigPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Connect(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
ConfigPassword = configuration["Password"];
|
||||||
|
|
||||||
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = _client.GetAsync(requestUrl);
|
||||||
|
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
|
if (response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = _client.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
|
if (!response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyShopApp.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyShopApp.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Privacy()
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Enter()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Enter(string password)
|
||||||
|
{
|
||||||
|
if (!APIClient.Login(password))
|
||||||
|
{
|
||||||
|
throw new Exception("Wrong password");
|
||||||
|
}
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Create()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Create(string shopname, string address, DateTime DateOpening, int count)
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
throw new Exception("Как вы сюда попали? Сюда могут входить только избранные");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Максимальное количество товаров должно быть больше либо равно 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/shop/createshop", new ShopBindingModel
|
||||||
|
{
|
||||||
|
ShopName = shopname,
|
||||||
|
MaxCountFurnitures = count,
|
||||||
|
Address = address,
|
||||||
|
DateOpen = DateOpening
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Delete()
|
||||||
|
{
|
||||||
|
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Delete(int shop)
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
throw new Exception("Как вы сюда попали? Сюда могут входить только авторизованные");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest($"api/shop/deleteshop", new ShopBindingModel { Id = shop });
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Update()
|
||||||
|
{
|
||||||
|
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Update(int shop, string shopname, string address, DateTime DateOpening, int count)
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
throw new Exception("Как вы сюда попали? Сюда могут входить только избранные");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest($"api/shop/updateshop", new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = shop,
|
||||||
|
ShopName = shopname,
|
||||||
|
Address = address,
|
||||||
|
DateOpen = DateOpening,
|
||||||
|
MaxCountFurnitures = count
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Supply()
|
||||||
|
{
|
||||||
|
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||||
|
ViewBag.Furnitures = APIClient.GetRequest<List<FurnitureViewModel>>("api/main/getfurniturelist");
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Supply(int shopId, int furnitureId, int count)
|
||||||
|
{
|
||||||
|
if (!APIClient.isAuth)
|
||||||
|
{
|
||||||
|
throw new Exception("Как вы сюда попали? Сюда могут входить только авторизованные");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest($"api/shop/supplyfurniturestoshop", (new ShopSearchModel { Id = shopId }, new FurnitureBindingModel { Id = furnitureId }, count));
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace FurnitureAssemblyShopApp.Models
|
||||||
|
{
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
|
}
|
31
FurnitureAssembly/FurnitureAssemblyShopApp/Program.cs
Normal file
31
FurnitureAssembly/FurnitureAssemblyShopApp/Program.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using FurnitureAssemblyShopApp;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.Run();
|
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:34897",
|
||||||
|
"sslPort": 44369
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"FurnitureAssemblyShopApp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7072;http://localhost:5171",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4 mb-5">Создание магазина</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Name:</div>
|
||||||
|
<div class="col-8"><input type="text" name="shopname" id="shopname" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Дата открытия:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="date" id="DateOpening" name="DateOpening" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Адрес:</div>
|
||||||
|
<div class="col-8"><input type="text" id="address" name="address" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Максимальное количество мебели:</div>
|
||||||
|
<div class="col-8"><input type="number" id="count" name="count" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-8">
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Создать" class="btn btn-success" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,17 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Delete";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление магазина</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Название:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Удалить" class="btn btn-danger" />
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,16 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Enter";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Вход в приложение</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Пароль:</div>
|
||||||
|
<div class="col-8"><input type="password" name="password" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Ввод" class="btn btnprimary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,67 @@
|
|||||||
|
@using FurnitureAssemblyContracts.ViewModels
|
||||||
|
@model List<ShopViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Home Page";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Магазины</h1>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Log in!</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
<p>
|
||||||
|
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать магазин</a>
|
||||||
|
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Обновить магазин</a>
|
||||||
|
<a class="text-decoration-none me-3 text-black h5" asp-action="Supply">Пополнить магазин</a>
|
||||||
|
<a class="text-decoration-none text-black h5" asp-action="Delete">Удаление магазина</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Название магазина
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Адресс
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Дата открытия
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Максимальное число мебели
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var shop in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => shop.Id)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => shop.ShopName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => shop.Address)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => shop.DateOpen)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => shop.MaxCountFurnitures)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
@ -0,0 +1,6 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Политика конфиденциальности";
|
||||||
|
}
|
||||||
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
|
<p>Используйте эту страницу для ознакомления с политикой конфиденциальности вашего сайтаy.</p>
|
@ -0,0 +1,29 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Supply";
|
||||||
|
}
|
||||||
|
<div class="text-center mb-5">
|
||||||
|
<h2 class="display-4">Пополнение магазина</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Магазин:</div>
|
||||||
|
<div class="col-8 ">
|
||||||
|
<select id="shopId" name="shopId" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Мебель:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="furnitureId" name="furnitureId" class="form-control" asp-items="@(new SelectList(@ViewBag.Furnitures,"Id", "FurnitureName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-4">Количество:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="text" name="count" id="count" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Пополнить" class="btn btn-success" />
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,79 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4 mb-5">Изменить магазин</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Магазин:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Название:</div>
|
||||||
|
<div class="col-8"><input type="text" id="shopname" name="shopname" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Адрес:</div>
|
||||||
|
<div class="col-8"><input type="text" id="address" name="address" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4"> Дата открытия:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="datetime-local" id="dateOpening" name="dateOpening" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Максимальная вместимость магазина:</div>
|
||||||
|
<div class="col-8"><input type="number" id="count" name="count" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Мебель в магазине:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Мебель</th>
|
||||||
|
<th>Количество</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="furnitureTable">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center ">
|
||||||
|
<input type="submit" value="Обновить" class="btn btn-success ps-5 pe-5" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#shop').on('change', function () {
|
||||||
|
getData();
|
||||||
|
});
|
||||||
|
|
||||||
|
function getData() {
|
||||||
|
var shopId = $('#shop').val();
|
||||||
|
var shopData = @Html.Raw(Json.Serialize(ViewBag.Shops));
|
||||||
|
var selectedShop = shopData.find(function (shop) {
|
||||||
|
return shop.id == shopId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedShop) {
|
||||||
|
$("#shopname").val(selectedShop.shopname);
|
||||||
|
$("#dateOpening").val(new Date(selectedShop.dateOpening).toISOString().substring(0, 16));
|
||||||
|
$("#address").val(selectedShop.address);
|
||||||
|
$("#count").val(selectedShop.count);
|
||||||
|
fillTable(selectedShop.furnitureCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillTable(shopFurnitures) {
|
||||||
|
$("#furnitureTable").empty();
|
||||||
|
|
||||||
|
for (var furniture in shopFurnitures)
|
||||||
|
$("#furnitureTable").append('<tr><td>' + shopFurnitures[furniture].item1 + '</td><td>' + shopFurnitures[furniture].item2 + '</td></tr>');
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - ShopApp</title>
|
||||||
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" />
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазины Сборки Мебели</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
|
<ul class="navbar-nav flex-grow-1">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Домашняя страница</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<div class="container">
|
||||||
|
<main role="main" class="pb-3">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="border-top footer text-muted">
|
||||||
|
<div class="container">
|
||||||
|
© 2024 - Магазины Сборки Мебели - <a asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,25 @@
|
|||||||
|
@model ErrorViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - FurnitureAssemblyShopApp</title>
|
||||||
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/FurnitureAssemblyShopApp.styles.css" asp-append-version="true" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">FurnitureAssemblyShopApp</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
|
<ul class="navbar-nav flex-grow-1">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<div class="container">
|
||||||
|
<main role="main" class="pb-3">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="border-top footer text-muted">
|
||||||
|
<div class="container">
|
||||||
|
© 2024 - FurnitureAssemblyShopApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,48 @@
|
|||||||
|
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
for details on configuring this project to bundle and minify static web assets. */
|
||||||
|
|
||||||
|
a.navbar-brand {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0077cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-top {
|
||||||
|
border-top: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-shadow {
|
||||||
|
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.accept-policy {
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 60px;
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||||
|
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
@ -0,0 +1,3 @@
|
|||||||
|
@using FurnitureAssemblyShopApp
|
||||||
|
@using FurnitureAssemblyShopApp.Models
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
FurnitureAssembly/FurnitureAssemblyShopApp/appsettings.json
Normal file
12
FurnitureAssembly/FurnitureAssemblyShopApp/appsettings.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
|
||||||
|
"IPAddress": "http://localhost:5159/",
|
||||||
|
"Password": "password"
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
html {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin-bottom: 60px;
|
||||||
|
}
|
BIN
FurnitureAssembly/FurnitureAssemblyShopApp/wwwroot/favicon.ico
Normal file
BIN
FurnitureAssembly/FurnitureAssemblyShopApp/wwwroot/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
// for details on configuring this project to bundle and minify static web assets.
|
||||||
|
|
||||||
|
// Write your JavaScript code.
|
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2011-2021 Twitter, Inc.
|
||||||
|
Copyright (c) 2011-2021 The Bootstrap Authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user