овер много фиксов...
This commit is contained in:
parent
267a137101
commit
7b7ced25dd
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioView", "BeautyStudioView\BeautyStudioView.csproj", "{DCC3ADED-6BBE-4B54-AADB-59237361F601}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioDataModels", "BeautyStudioDataModels\BeautyStudioDataModels.csproj", "{7C1604C6-4223-47A7-B651-687BBF19704B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioContracts", "BeautyStudioContracts\BeautyStudioContracts.csproj", "{BD48E4B8-A4A1-4A80-97AE-8599BDD41892}"
|
||||
@ -13,9 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioBusinessLogic",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioDatabaseImplement", "BeautyStudioDatabaseImplement\BeautyStudioDatabaseImplement.csproj", "{8BEBC76F-F7B5-46CB-A42B-28E133452D52}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautyStudioRestAPI", "BeautyStudioRestAPI\BeautyStudioRestAPI.csproj", "{F430F87B-4339-47E4-8C23-3FBED1F74867}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioRestAPI", "BeautyStudioRestAPI\BeautyStudioRestAPI.csproj", "{F430F87B-4339-47E4-8C23-3FBED1F74867}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreKeeperWebApp", "StoreKeeperWebApp\StoreKeeperWebApp.csproj", "{93AF7F9C-675F-444E-BD5D-11FA4D516561}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StoreKeeperWebApp", "StoreKeeperWebApp\StoreKeeperWebApp.csproj", "{93AF7F9C-675F-444E-BD5D-11FA4D516561}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -23,10 +21,6 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DCC3ADED-6BBE-4B54-AADB-59237361F601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCC3ADED-6BBE-4B54-AADB-59237361F601}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCC3ADED-6BBE-4B54-AADB-59237361F601}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCC3ADED-6BBE-4B54-AADB-59237361F601}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7C1604C6-4223-47A7-B651-687BBF19704B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C1604C6-4223-47A7-B651-687BBF19704B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7C1604C6-4223-47A7-B651-687BBF19704B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -102,6 +102,15 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException("Не указана сложность трудозатраты", nameof(model.Difficulty));
|
||||
}
|
||||
var element = _laborCostsStorage.GetElement(new LaborCostSearchModel
|
||||
{
|
||||
TimeSpent = model.TimeSpent,
|
||||
Difficulty = model.Difficulty,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такая трудозатрата уже уже есть");
|
||||
}
|
||||
_logger.LogInformation("LaborCost. TimeSpent: {TimeSpent}. Difficulty: {Difficulty}. Id: {Id}",
|
||||
model.TimeSpent, model.Difficulty, model.Id);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
@ -17,54 +18,63 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<StoreKeeperLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IStoreKeeperLogic _clientLogic;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IStoreKeeperLogic clientLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_mailWorker = mailWorker;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("Order. OrderID:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. DateCreate: {DateCreate}. DateComplete: {DateComplete}. Id: {Id}",
|
||||
model.DateCreate, model.DateComplete, model.Id);
|
||||
_logger.LogInformation("ReadElement. DateFrom:{DateFrom}. DateTo:{DateTo}. Id:{Id}", model.DateCreate, model.DateComplete, model.Id);
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public bool Create(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.Status = OrderStatus.Принято;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
public bool Update(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (order == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(order));
|
||||
}
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
@ -75,14 +85,61 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
|
||||
public bool Delete(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_orderStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
_logger.LogWarning("Delete order operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (viewModel.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Выполнено)
|
||||
{
|
||||
model.DateComplete = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateComplete = viewModel.DateComplete;
|
||||
}
|
||||
CheckModel(model, false);
|
||||
var result = _orderStorage.Update(model);
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
//Отсылка письма при изменении статуса
|
||||
SendOrderStatusMail(result.StoreKeeperId, $"Изменен статус заказа #{result.Id}", $"Заказ #{model.Id} изменен статус на {result.Status}");
|
||||
return true;
|
||||
}
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
model.DateComplete = DateTime.Now;
|
||||
return StatusUpdate(model, OrderStatus.Выполнено);
|
||||
}
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
@ -95,59 +152,29 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Cумма заказа должна быть больше 0",
|
||||
nameof(model.Sum));
|
||||
throw new ArgumentNullException("Стоимость должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
_logger.LogInformation("Order. Id: {Id}. Sum: {Sum}.", model.Id, model.Sum);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element != null && element.Id == model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Заказ с таким номером уже есть");
|
||||
}
|
||||
}
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
|
||||
private bool SendOrderStatusMail(int clientId, string subject, string text)
|
||||
{
|
||||
var vmodel = _orderStorage.GetElement(new() { Id = model.Id });
|
||||
|
||||
if (vmodel == null)
|
||||
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
||||
if (client == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if ((int)vmodel.Status + 1 != (int)newStatus)
|
||||
{
|
||||
throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " +
|
||||
$"Текущий статус: {vmodel.Status} \n" +
|
||||
$"Планируемый статус: {newStatus} \n" +
|
||||
$"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}");
|
||||
}
|
||||
|
||||
model.Status = newStatus;
|
||||
model.DateCreate = vmodel.DateCreate;
|
||||
|
||||
model.ServiceId = vmodel.ServiceId;
|
||||
model.Sum = vmodel.Sum;
|
||||
|
||||
var result = _orderStorage.Update(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
_mailWorker.MailSendAsync(new()
|
||||
{
|
||||
MailAddress = client.StoreKeeperEmail,
|
||||
Subject = subject,
|
||||
Text = text
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
//Перевод заказа в состояние принятого на выполнение
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Принято);
|
||||
}
|
||||
|
||||
//Перевод заказа в состояние выполнения заказа
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
//Перевод заказа в состояние выполненности (окончательное завершение)
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполнено);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ namespace BeautyStudioBusinessLogic.BusinessLogic
|
||||
{
|
||||
Id = x.Id,
|
||||
ServiceName = x.ServiceName,
|
||||
Cosmetics = x.ServiceCosmetic,
|
||||
Procedures = x.ServiceProcedure,
|
||||
ServicePrice = x.ServiceProcedure.Sum(kv => kv.Value.Item1.ProcedurePrice) +
|
||||
x.ServiceCosmetic.Sum(kv => kv.Value.Item1.CosmeticPrice)
|
||||
Cosmetics = x.ServiceCosmetics,
|
||||
Procedures = x.ServiceProcedures,
|
||||
ServicePrice = x.ServiceProcedures.Sum(kv => kv.Value.Item1.ProcedureCost) +
|
||||
x.ServiceCosmetics.Sum(kv => kv.Value.Item1.CosmeticPrice)
|
||||
}).ToList();
|
||||
return r;
|
||||
}
|
||||
|
@ -14,9 +14,7 @@ namespace BeautyStudioContracts.BindingModels
|
||||
public string CosmeticName { get; set; } = string.Empty;
|
||||
public double CosmeticPrice { get; set; }
|
||||
public int LaborCostId { get; set; }
|
||||
|
||||
public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
|
||||
public List<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
|
||||
public List<OrderServiceViewModel> OrderService { get; set; } = new();
|
||||
public int StoreKeeperId { get; set; }
|
||||
public Dictionary<int, IProcedureModel> CosmeticProcedure { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ namespace BeautyStudioContracts.BindingModels
|
||||
public class LaborCostBindingModel : ILaborCostModel
|
||||
{
|
||||
public int Id { get ; set; }
|
||||
|
||||
public int TimeSpent { get; set; }
|
||||
|
||||
public string Difficulty { get; set; } = string.Empty;
|
||||
public int StoreKeeperId { get; set; }
|
||||
}
|
||||
|
@ -16,11 +16,10 @@ namespace BeautyStudioContracts.BindingModels
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateComplete { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public int ServiceId { get; set; }
|
||||
public int CosmeticId { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public List<OrderServiceViewModel> OrderService { get; set; } = new();
|
||||
public List<OrderCosmeticViewModel> OrderCosmetic { get; set; } = new();
|
||||
public List<OrderProcedureViewModel> OrderProcedure { get; set; } = new();
|
||||
public Dictionary<int, (IServiceModel, int)> OrderServices { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> OrderCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,7 @@ namespace BeautyStudioContracts.BindingModels
|
||||
public string ProcedureName { get; set; } = string.Empty;
|
||||
public double ProcedureCost { get; set; }
|
||||
public string ProcedureDescription { get; set; } = string.Empty;
|
||||
|
||||
public List<CosmeticProcedureViewModel> ProcedureCosmetics { get; set; } = new();
|
||||
public List<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
|
||||
public List<OrderProcedureViewModel> OrderProcedure { get; set; } = new();
|
||||
public int StoreKeeperId { get; set; }
|
||||
public Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,9 @@ namespace BeautyStudioContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
public double ServicePrice { get; set; }
|
||||
public double ServicePrice { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
|
||||
public List<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
|
||||
public List<OrderServiceViewModel> OrderService { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace BeautyStudioContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? CosmeticName { get; set; }
|
||||
public int? LaborCostId { get; set; }
|
||||
public int? StoreKeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,10 @@ namespace BeautyStudioContracts.SearchModels
|
||||
public double? Sum { get; set; }
|
||||
public DateTime? DateCreate { get; set; }
|
||||
public DateTime? DateComplete { get; set; }
|
||||
public OrderStatus? Status { get; set; }
|
||||
public int? ServiceId { get; set; }
|
||||
public int? CosmeticId { get; set; }
|
||||
public List<OrderStatus>? Statuses { get; set; }
|
||||
public List<int>? CosmeticIds { get; set; }
|
||||
public List<int>? ProcedureIds { get; set; }
|
||||
public List<int>? ServiceIds { get; set; }
|
||||
public int? StoreKeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace BeautyStudioContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? ProcedureName { get; set; }
|
||||
public string? ProcedureDescription { get; set; }
|
||||
public int? StoreKeeperId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,7 @@ namespace BeautyStudioContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? ServiceName { get; set; }
|
||||
public int? StoreKeeperId { get; set; }
|
||||
public List<int>? CosmeticIds { get; set; }
|
||||
public List<int>? ProcedureIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,12 @@ namespace BeautyStudioContracts.ViewModels
|
||||
[DisplayName("Цена косметики")]
|
||||
public double CosmeticPrice { get; set; }
|
||||
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public int LaborCostId { get; set; }
|
||||
|
||||
//public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public string StoreKeeperName { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, IProcedureModel> CosmeticProcedure { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,11 @@ namespace BeautyStudioContracts.ViewModels
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateComplete { get; set; }
|
||||
|
||||
public List<OrderServiceViewModel> OrderService { get; set; } = new();
|
||||
public List<OrderCosmeticViewModel> OrderCosmetic { get; set; } = new();
|
||||
public List<OrderProcedureViewModel> OrderProcedure { get; set; } = new();
|
||||
[DisplayName("Клиент")]
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public Dictionary<int, (IServiceModel, int)> OrderServices { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> OrderCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioContracts.ViewModels
|
||||
{
|
||||
public class ProcedureCount
|
||||
{
|
||||
public ProcedureViewModel Procedure { get; set; }
|
||||
public int Count { get; set; } = new();
|
||||
}
|
||||
}
|
@ -18,9 +18,8 @@ namespace BeautyStudioContracts.ViewModels
|
||||
public double ProcedureCost { get; set; }
|
||||
[DisplayName("Описание процедуры")]
|
||||
public string ProcedureDescription { get; set; } = string.Empty;
|
||||
|
||||
public List<CosmeticProcedureViewModel> CosmeticProcedures { get; set; } = new();
|
||||
public List<OrderProcedureViewModel> OrderProcedures { get; set; } = new();
|
||||
public List<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
|
||||
public int StoreKeeperId { get; set; }
|
||||
public string StoreKeeperName { get; set; } = string.Empty;
|
||||
public Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,7 @@ namespace BeautyStudioContracts.ViewModels
|
||||
[DisplayName("Сотрудник")]
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public Dictionary<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
|
||||
public Dictionary<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
|
||||
public List<OrderServiceViewModel> OrderService { get; set; } = new();
|
||||
public Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics { get; set; } = new();
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace BeautyStudioDataModels.Enums
|
||||
Неизвестен = -1,
|
||||
Принято = 0,
|
||||
Выполняется = 1,
|
||||
Выполнено = 2
|
||||
Выполнено = 2,
|
||||
Выдан = 3
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,10 @@ namespace BeautyStudioDataModels.Models
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateComplete { get; }
|
||||
OrderStatus Status { get; }
|
||||
int ServiceId { get; }
|
||||
int CosmeticId { get; }
|
||||
Dictionary<int, (ICosmeticModel, int)> OrderCosmetic { get; }
|
||||
Dictionary<int, (IProcedureModel, int)> OrderProcedureCosmetic { get; }
|
||||
Dictionary<int, (IServiceModel, int)> OrderService { get; }
|
||||
int StoreKeeperId { get; }
|
||||
Dictionary<int, (ICosmeticModel, int)> OrderCosmetics { get; } // список косметики "участвующей" в заказе
|
||||
Dictionary<int, (IProcedureModel, int)> OrderProcedures { get; } // список процедур "участвующих" в заказе
|
||||
Dictionary<int, (IServiceModel, int)> OrderServices { get; } // список услуг "участвующих" в заказе
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace BeautyStudioDataModels.Models
|
||||
string ProcedureName { get; }
|
||||
double ProcedureCost { get; }
|
||||
string ProcedureDescription { get; }
|
||||
int StoreKeeperId { get; }
|
||||
Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics { get; }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace BeautyStudioDataModels.Models
|
||||
string ServiceName { get; }
|
||||
double ServicePrice { get; }
|
||||
int StoreKeeperId { get; set; }
|
||||
Dictionary<int, (ICosmeticModel, int)> ServiceCosmetic { get; }
|
||||
Dictionary<int, (IProcedureModel, int)> ServiceProcedure { get; }
|
||||
Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics { get; }
|
||||
Dictionary<int, (IProcedureModel, int)> ServiceProcedures { get; }
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace BeautyStudioDatabaseImplement
|
||||
public virtual DbSet<OrderService> OrderServices { set; get; }
|
||||
public virtual DbSet<OrderProcedure> OrderProcedures { set; get; }
|
||||
public virtual DbSet<CosmeticProcedure> CosmeticProcedures { set; get; }
|
||||
public virtual DbSet<ProcedureCosmetic> ProcedureCosmetics { set; get; }
|
||||
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
|
||||
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
|
||||
}
|
||||
|
@ -22,4 +22,8 @@
|
||||
<ProjectReference Include="..\BeautyStudioDataModels\BeautyStudioDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -16,6 +16,9 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.Cosmetics
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -25,14 +28,16 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Cosmetics
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.LaborCostId.HasValue)
|
||||
if (model.StoreKeeperId.HasValue)
|
||||
{
|
||||
return context.Cosmetics
|
||||
.Where(x => x.LaborCostId == model.LaborCostId)
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Where(x => x.StoreKeeperId == model.StoreKeeperId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -48,19 +53,22 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.Cosmetics
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CosmeticName) && x.CosmeticName == model.CosmeticName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CosmeticName) && x.CosmeticName == model.CosmeticName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public CosmeticViewModel? Insert(CosmeticBindingModel model)
|
||||
{
|
||||
var newCosmetic = Cosmetic.Create(model);
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var newCosmetic = Cosmetic.Create(context, model);
|
||||
if (newCosmetic == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
context.Cosmetics.Add(newCosmetic);
|
||||
context.SaveChanges();
|
||||
return newCosmetic.GetViewModel;
|
||||
@ -69,20 +77,25 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
public CosmeticViewModel? Update(CosmeticBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var сosmetic = context.Cosmetics.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (сosmetic == null)
|
||||
var element = context.Cosmetics
|
||||
.Include(x => x.LaborCost)
|
||||
.FirstOrDefault(x => x.Id.Equals(model.Id));
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
сosmetic.Update(model);
|
||||
|
||||
element.Update(context, model);
|
||||
context.SaveChanges();
|
||||
return сosmetic.GetViewModel;
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
public CosmeticViewModel? Delete(CosmeticBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var element = context.Cosmetics.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Cosmetics
|
||||
.Include(x => x.LaborCost)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Cosmetics.Remove(element);
|
||||
|
@ -3,11 +3,6 @@ using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -22,12 +17,16 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
public LaborCostViewModel? Delete(LaborCostBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
var element = context.LaborCost.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.LaborCost
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.LaborCost.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -36,12 +35,20 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.LaborCost
|
||||
.FirstOrDefault(x => x.TimeSpent == model.TimeSpent
|
||||
&& x.Difficulty == model.Difficulty
|
||||
&& x.StoreKeeperId == model.StoreKeeperId)
|
||||
?.GetViewModel;
|
||||
}
|
||||
else
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.LaborCost
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.LaborCost
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<LaborCostViewModel> GetFilteredList(LaborCostSearchModel model)
|
||||
@ -82,20 +89,24 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
using var context = new BeautyStudioDatabase();
|
||||
context.LaborCost.Add(newLaborCost);
|
||||
context.SaveChanges();
|
||||
return newLaborCost.GetViewModel;
|
||||
return context.LaborCost
|
||||
.FirstOrDefault(x => x.Id == newLaborCost.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public LaborCostViewModel? Update(LaborCostBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var laborCost = context.LaborCost.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (laborCost == null)
|
||||
var order = context.LaborCost.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
laborCost.Update(model);
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return laborCost.GetViewModel;
|
||||
return context.LaborCost
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -46,7 +45,7 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
@ -57,16 +56,31 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautyStudioDatabase();
|
||||
if (model.DateCreate.HasValue)
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.Where(x => x.DateCreate == model.DateCreate).ToList()
|
||||
.Where(x => x.Id == model.Id)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.StoreKeeperId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.Where(x => x.StoreKeeperId == model.StoreKeeperId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -77,13 +91,12 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Services)
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -114,9 +127,9 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
order.UpdateServices(context, model);
|
||||
order.UpdateProcedures(context, model);
|
||||
order.UpdateCosmetics(context, model);
|
||||
order.UpdateProcedures(context, model);
|
||||
order.UpdateServices(context, model);
|
||||
transaction.Commit();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
|
@ -14,21 +14,41 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
public class ProcedureStorage : IProcedureStorage
|
||||
{
|
||||
public ProcedureViewModel? Delete(ProcedureBindingModel model)
|
||||
public List<ProcedureViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var element = context.Procedures
|
||||
.Include(x => x.Cosmetics)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Procedures.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
return context.Procedures
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Procedures
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.StoreKeeperId.HasValue)
|
||||
{
|
||||
return context.Procedures
|
||||
.Include(x => x.StoreKeeper)
|
||||
.Where(x => x.StoreKeeperId == model.StoreKeeperId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
|
||||
public ProcedureViewModel? GetElement(ProcedureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ProcedureName) && !model.Id.HasValue)
|
||||
@ -44,29 +64,6 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Procedures
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ProcedureViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.Procedures
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ProcedureViewModel? Insert(ProcedureBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
@ -75,33 +72,40 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Procedures.Add(newProcedure);
|
||||
context.SaveChanges();
|
||||
return newProcedure.GetViewModel;
|
||||
}
|
||||
|
||||
|
||||
public ProcedureViewModel? Update(ProcedureBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
var element = context.Procedures
|
||||
.FirstOrDefault(x => x.Id.Equals(model.Id));
|
||||
if (element == null)
|
||||
{
|
||||
var procedure = context.Procedures.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (procedure == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
procedure.Update(model);
|
||||
return null;
|
||||
}
|
||||
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
public ProcedureViewModel? Delete(ProcedureBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var element = context.Procedures
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Procedures.Remove(element);
|
||||
context.SaveChanges();
|
||||
procedure.UpdateCosmetics(context, model);
|
||||
transaction.Commit();
|
||||
return procedure.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<CosmeticViewModel> GetProcedureCosmetics(ProcedureSearchModel model)
|
||||
@ -111,11 +115,12 @@ namespace BeautyStudioDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var cosmetics = context.CosmeticProcedures
|
||||
var cosmetics = context.ProcedureCosmetics
|
||||
.Where(x => x.ProcedureId == model.Id)
|
||||
.Select(x => x.Cosmetic.GetViewModel)
|
||||
.ToList();
|
||||
return cosmetics;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,97 +1,118 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Numerics;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Implements
|
||||
{
|
||||
public class StoreKeeperStorage : IStoreKeeperStorage
|
||||
{
|
||||
public StoreKeeperViewModel? Delete(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
var element = context.StoreKeepers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.StoreKeepers.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
if (model.Id.HasValue)
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.StoreKeeperPassword) &&
|
||||
!string.IsNullOrEmpty(model.StoreKeeperLogin))
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x =>
|
||||
x.StoreKeeperPassword.Equals(model.StoreKeeperPassword) &&
|
||||
x.StoreKeeperLogin.Equals(model.StoreKeeperLogin))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<StoreKeeperViewModel> GetFilteredList(StoreKeeperSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<StoreKeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
return context.StoreKeepers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<StoreKeeperViewModel> GetFilteredList(StoreKeeperSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
// Фильтрация по ФИО
|
||||
if (!string.IsNullOrEmpty(model.StoreKeeperFIO))
|
||||
{
|
||||
return context.StoreKeepers
|
||||
.Where(x => x.StoreKeeperFIO.Contains(model.StoreKeeperFIO))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
// Фильтрация по логину
|
||||
if (!string.IsNullOrEmpty(model.StoreKeeperLogin))
|
||||
{
|
||||
return context.StoreKeepers
|
||||
.Where(x => x.StoreKeeperLogin.Contains(model.StoreKeeperLogin))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
public StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
// Поиск по идентификатору
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x => x.Id.Equals(model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
// Поиск по логину и паролю
|
||||
if (!string.IsNullOrEmpty(model.StoreKeeperLogin) && !string.IsNullOrEmpty(model.StoreKeeperPassword))
|
||||
{
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x => x.StoreKeeperLogin.Equals(model.StoreKeeperLogin) && x.StoreKeeperPassword.Equals(model.StoreKeeperPassword))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
//// Поиск по логину
|
||||
if (!string.IsNullOrEmpty(model.StoreKeeperLogin))
|
||||
{
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x => x.StoreKeeperLogin.Equals(model.StoreKeeperLogin))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public StoreKeeperViewModel? Insert(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
var newStoreKeepers = StoreKeeper.Create(model);
|
||||
|
||||
if (newStoreKeepers == null)
|
||||
var newStoreKeeper = StoreKeeper.Create(model);
|
||||
if (newStoreKeeper == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.StoreKeepers.Add(newStoreKeepers);
|
||||
context.StoreKeepers.Add(newStoreKeeper);
|
||||
context.SaveChanges();
|
||||
|
||||
return newStoreKeepers.GetViewModel;
|
||||
return newStoreKeeper.GetViewModel;
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel? Update(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
|
||||
var StoreKeepers = context.StoreKeepers.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (StoreKeepers == null)
|
||||
var storekeeper = context.StoreKeepers
|
||||
.FirstOrDefault(x => x.Id.Equals(model.Id));
|
||||
if (storekeeper == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
StoreKeepers.Update(model);
|
||||
storekeeper.Update(model);
|
||||
context.SaveChanges();
|
||||
return storekeeper.GetViewModel;
|
||||
}
|
||||
public StoreKeeperViewModel? Delete(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new BeautyStudioDatabase();
|
||||
var storekeeper = context.StoreKeepers
|
||||
.FirstOrDefault(x => x.Id.Equals(model.Id));
|
||||
if (storekeeper == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return StoreKeepers.GetViewModel;
|
||||
context.StoreKeepers.Remove(storekeeper);
|
||||
context.SaveChanges();
|
||||
return storekeeper.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace BeautyStudioDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautyStudioDatabase))]
|
||||
[Migration("20240526191135_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20240827175011_SecondMig")]
|
||||
partial class SecondMig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -106,6 +106,36 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("LaborCost");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("MessageId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("MessageInfos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -114,23 +144,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("StoreKeeperId")
|
||||
.IsRequired()
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
@ -138,6 +161,8 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
@ -152,6 +177,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -235,11 +263,42 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.ToTable("ProcedureCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -358,13 +417,15 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", null)
|
||||
.WithMany("Cosmetics")
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LaborCost");
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b =>
|
||||
@ -397,10 +458,30 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "Storekeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StorekeeperId");
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -425,7 +506,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -444,7 +525,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -454,6 +535,36 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany()
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Procedure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
@ -487,7 +598,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("Services")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -505,8 +616,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Procedures");
|
||||
|
||||
b.Navigation("Services");
|
||||
@ -529,25 +638,14 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
@ -7,45 +7,11 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace BeautyStudioDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class SecondMig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateComplete = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Procedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProcedureName = table.Column<string>(type: "text", nullable: false),
|
||||
ProcedureCost = table.Column<double>(type: "double precision", nullable: false),
|
||||
ProcedureDescription = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StoreKeepers",
|
||||
columns: table => new
|
||||
@ -63,33 +29,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
table.PrimaryKey("PK_StoreKeepers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderProcedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderProcedureCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderProcedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProcedures_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProcedures_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LaborCost",
|
||||
columns: table => new
|
||||
@ -111,6 +50,72 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MessageInfos",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "text", nullable: false),
|
||||
StorekeeperId = table.Column<int>(type: "integer", nullable: true),
|
||||
SenderName = table.Column<string>(type: "text", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Subject = table.Column<string>(type: "text", nullable: false),
|
||||
Body = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MessageInfos", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_MessageInfos_StoreKeepers_StorekeeperId",
|
||||
column: x => x.StorekeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateComplete = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Procedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProcedureName = table.Column<string>(type: "text", nullable: false),
|
||||
ProcedureCost = table.Column<double>(type: "double precision", nullable: false),
|
||||
ProcedureDescription = table.Column<string>(type: "text", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Procedures_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
@ -160,6 +165,33 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderProcedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderProcedureCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderProcedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProcedures_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProcedures_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderServices",
|
||||
columns: table => new
|
||||
@ -248,7 +280,8 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false)
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -267,6 +300,33 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProcedureCosmetics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CosmeticId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProcedureCosmetics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureCosmetics_Cosmetics_CosmeticId",
|
||||
column: x => x.CosmeticId,
|
||||
principalTable: "Cosmetics",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureCosmetics_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceCosmetics",
|
||||
columns: table => new
|
||||
@ -319,6 +379,11 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
table: "LaborCost",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MessageInfos_StorekeeperId",
|
||||
table: "MessageInfos",
|
||||
column: "StorekeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderCosmetics_CosmeticId",
|
||||
table: "OrderCosmetics",
|
||||
@ -339,6 +404,11 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
table: "OrderProcedures",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_StoreKeeperId",
|
||||
table: "Orders",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderServices_OrderId",
|
||||
table: "OrderServices",
|
||||
@ -349,6 +419,21 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
table: "OrderServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureCosmetics_CosmeticId",
|
||||
table: "ProcedureCosmetics",
|
||||
column: "CosmeticId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureCosmetics_ProcedureId",
|
||||
table: "ProcedureCosmetics",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Procedures_StoreKeeperId",
|
||||
table: "Procedures",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceCosmetics_CosmeticId",
|
||||
table: "ServiceCosmetics",
|
||||
@ -381,6 +466,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "CosmeticProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MessageInfos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderCosmetics");
|
||||
|
||||
@ -390,6 +478,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProcedureCosmetics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceCosmetics");
|
||||
|
@ -103,6 +103,36 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.ToTable("LaborCost");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("MessageId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("MessageInfos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -111,23 +141,16 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("StoreKeeperId")
|
||||
.IsRequired()
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
@ -135,6 +158,8 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
@ -149,6 +174,9 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -232,11 +260,42 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CosmeticId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CosmeticId");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.ToTable("ProcedureCosmetics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -355,13 +414,15 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", null)
|
||||
.WithMany("Cosmetics")
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LaborCost");
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b =>
|
||||
@ -394,10 +455,30 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "Storekeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StorekeeperId");
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -422,7 +503,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -441,7 +522,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("Orders")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -451,6 +532,36 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
.WithMany()
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetic", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic")
|
||||
.WithMany()
|
||||
.HasForeignKey("CosmeticId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cosmetic");
|
||||
|
||||
b.Navigation("Procedure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper")
|
||||
@ -484,7 +595,7 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b =>
|
||||
{
|
||||
b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure")
|
||||
.WithMany("Services")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -502,8 +613,6 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Procedures");
|
||||
|
||||
b.Navigation("Services");
|
||||
@ -526,25 +635,14 @@ namespace BeautyStudioDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Navigation("Cosmetics");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
|
||||
[Required]
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
[Required]
|
||||
public int LaborCostId { get; set; }
|
||||
public virtual LaborCost LaborCost { get; set; } = new();
|
||||
@ -34,44 +34,86 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
|
||||
// связь многие-ко-многим косметики с процедурами
|
||||
[ForeignKey("CosmeticId")]
|
||||
private Dictionary<int, IProcedureModel>? _cosmeticProcedures = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IProcedureModel> CosmeticProcedure
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cosmeticProcedures == null)
|
||||
{
|
||||
_cosmeticProcedures = Procedures.ToDictionary(recPC => recPC.ProcedureId, recPC => (recPC.Procedure as IProcedureModel));
|
||||
}
|
||||
return _cosmeticProcedures;
|
||||
}
|
||||
}
|
||||
// список косметики в закаче
|
||||
public virtual List<CosmeticProcedure> Procedures { get; set; } = new();
|
||||
// связь многие-ко-многим косметики с процедурами
|
||||
[ForeignKey("CosmeticId")]
|
||||
public virtual List<ServiceCosmetic> Services { get; set; } = new();
|
||||
|
||||
public static Cosmetic Create(CosmeticBindingModel model)
|
||||
public static Cosmetic Create(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Cosmetic()
|
||||
var cosmetic = new Cosmetic()
|
||||
{
|
||||
Id = model.Id,
|
||||
CosmeticName = model.CosmeticName,
|
||||
CosmeticPrice = model.CosmeticPrice,
|
||||
LaborCostId = model.LaborCostId
|
||||
LaborCostId = model.LaborCostId,
|
||||
StoreKeeperId = model.StoreKeeperId
|
||||
};
|
||||
return cosmetic;
|
||||
}
|
||||
|
||||
public void Update(CosmeticBindingModel model)
|
||||
public void Update(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CosmeticName = model.CosmeticName;
|
||||
CosmeticPrice = model.CosmeticPrice;
|
||||
LaborCostId = model.LaborCostId;
|
||||
}
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
var cosmeticProcedures = context.CosmeticProcedures.Where(rec => rec.CosmeticId == model.Id).ToList();
|
||||
if (cosmeticProcedures != null && cosmeticProcedures.Count > 0)
|
||||
{
|
||||
context.CosmeticProcedures.RemoveRange(cosmeticProcedures.Where(rec => !model.CosmeticProcedure.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateProcedure in cosmeticProcedures)
|
||||
{
|
||||
model.CosmeticProcedure.Remove(updateProcedure.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var cosmetic = context.Cosmetics.First(x => x.Id == Id);
|
||||
foreach (var rp in model.CosmeticProcedure)
|
||||
{
|
||||
context.CosmeticProcedures.Add(new CosmeticProcedure
|
||||
{
|
||||
Cosmetic = cosmetic,
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_cosmeticProcedures = null;
|
||||
}
|
||||
|
||||
public CosmeticViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CosmeticName = CosmeticName,
|
||||
CosmeticPrice = CosmeticPrice,
|
||||
LaborCostId = LaborCostId
|
||||
LaborCostId = LaborCostId,
|
||||
CosmeticProcedure = CosmeticProcedure,
|
||||
StoreKeeperId = StoreKeeperId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
TimeSpent = model.TimeSpent
|
||||
TimeSpent = model.TimeSpent,
|
||||
Difficulty = model.Difficulty
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -28,91 +28,98 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public double Sum { get; set; }
|
||||
|
||||
[Required]
|
||||
public int? StoreKeeperId { get; set; }
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
private List<OrderServiceViewModel>? _orderServices = null;
|
||||
|
||||
private List<OrderCosmeticViewModel>? _orderCosmetics = null;
|
||||
|
||||
private List<OrderProcedureViewModel>? _orderProcedures = null;
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _orderCosmetics = null; // поле для
|
||||
[NotMapped]
|
||||
public List<OrderServiceViewModel> OrderServices
|
||||
public Dictionary<int, (ICosmeticModel?, int)>? OrderCosmetics
|
||||
{
|
||||
get
|
||||
{
|
||||
_orderServices ??= Services
|
||||
.Select(pc => new OrderServiceViewModel(pc.Service.GetViewModel, pc.OrderServiceCount))
|
||||
.ToList();
|
||||
return _orderServices;
|
||||
if (_orderCosmetics == null)
|
||||
{
|
||||
_orderCosmetics = Cosmetics.ToDictionary(recPC => recPC.CosmeticId, recPC => (recPC.Cosmetic as ICosmeticModel, recPC.Count));
|
||||
}
|
||||
return _orderCosmetics;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderCosmetic> Cosmetics { get; set; } = new(); // список косметических товаров для данного заказа.
|
||||
|
||||
private Dictionary<int, (IProcedureModel, int)>? _orderProcedures = null; // поле для хранения словаря OrderCosmetics.
|
||||
|
||||
[NotMapped]
|
||||
public List<OrderProcedureViewModel> OrderProcedures
|
||||
public Dictionary<int, (IProcedureModel, int)> OrderProcedures // список косметики используемых в заказе.
|
||||
{
|
||||
get
|
||||
{
|
||||
_orderProcedures ??= Procedures
|
||||
.Select(pc => new OrderProcedureViewModel(pc.Procedure.GetViewModel, pc.OrderProcedureCount))
|
||||
.ToList();
|
||||
if (_orderProcedures == null)
|
||||
{
|
||||
_orderProcedures = Procedures
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
(recPC.Procedure as IProcedureModel, recPC.OrderProcedureCount));
|
||||
}
|
||||
return _orderProcedures;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderProcedure> Procedures { get; set; } = new(); // представляет список процедур для данного заказа.
|
||||
|
||||
private Dictionary<int, (IServiceModel, int)>? _orderServices = null; // поле для хранения словаря OrderServices.
|
||||
[NotMapped]
|
||||
public List<OrderCosmeticViewModel> OrderCosmetics
|
||||
public Dictionary<int, (IServiceModel, int)> OrderServices
|
||||
{
|
||||
get
|
||||
{
|
||||
_orderCosmetics ??= Cosmetics
|
||||
.Select(pc => new OrderCosmeticViewModel(pc.Cosmetic.GetViewModel))
|
||||
.ToList();
|
||||
return _orderCosmetics;
|
||||
if (_orderServices == null)
|
||||
{
|
||||
_orderServices = Services.ToDictionary(recPC => recPC.ServiceId, recPC => (recPC.Service as IServiceModel, recPC.OrderServiceCount));
|
||||
}
|
||||
return _orderServices;
|
||||
}
|
||||
}
|
||||
|
||||
// связь услуги и заказов многие - ко - многим
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderService> Services { get; set; } = new();
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderCosmetic> Cosmetics { get; set; } = new();
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderProcedure> Procedures { get; set; } = new();
|
||||
|
||||
public static Order Create(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
return new Order()
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var order = new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
DateCreate = model.DateCreate,
|
||||
Sum = model.Sum,
|
||||
Services = model.OrderService.Select(x => new OrderService()
|
||||
DateCreate = model.DateCreate,
|
||||
DateComplete = model.DateComplete,
|
||||
Status = model.Status,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.OrderCosmetics.Select(x => new OrderCosmetic
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Service.Id),
|
||||
OrderServiceCount = x.Count
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Procedures = model.OrderProcedure.Select(x => new OrderProcedure()
|
||||
Procedures = model.OrderProcedures.Select(x => new OrderProcedure
|
||||
{
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Procedure.Id),
|
||||
OrderProcedureCount = x.Count
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Cosmetics = model.OrderCosmetic.Select(x => new OrderCosmetic()
|
||||
Services = model.OrderServices.Select(x => new OrderService
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id),
|
||||
Service = context.Services.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateComplete = model.DateComplete;
|
||||
}
|
||||
|
||||
@ -122,71 +129,88 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
DateCreate = DateCreate,
|
||||
DateComplete = DateComplete,
|
||||
Sum = Sum,
|
||||
OrderService = OrderServices,
|
||||
OrderProcedure = OrderProcedures,
|
||||
OrderCosmetic = OrderCosmetics
|
||||
Status = Status
|
||||
};
|
||||
|
||||
public void UpdateServices(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderServices = context.OrderServices
|
||||
.Where(x => x.OrderId == model.Id)
|
||||
.ToList();
|
||||
context.OrderServices
|
||||
.RemoveRange(orderServices);
|
||||
var orderCosmetics = context.OrderCosmetics.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderCosmetics != null && orderCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderCosmetics.RemoveRange(orderCosmetics.Where(rec => !model.OrderCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in orderCosmetics)
|
||||
{
|
||||
model.OrderCosmetics.Remove(updateCosmetic.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var record in model.OrderService)
|
||||
foreach (var rp in model.OrderCosmetics)
|
||||
{
|
||||
context.OrderServices.Add(new OrderService
|
||||
context.OrderCosmetics.Add(new OrderCosmetic
|
||||
{
|
||||
Order = order,
|
||||
Service = context.Services.First(x => x.Id == record.Service.Id),
|
||||
OrderServiceCount = record.Count
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderServices = null;
|
||||
_orderCosmetics = null;
|
||||
}
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderProcedures = context.OrderProcedures
|
||||
.Where(x => x.OrderId == model.Id)
|
||||
.ToList();
|
||||
context.OrderProcedures
|
||||
.RemoveRange(orderProcedures);
|
||||
var orderProcedures = context.OrderProcedures.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderProcedures != null && orderProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderProcedures.RemoveRange(orderProcedures.Where(rec => !model.OrderProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateProcedure in orderProcedures)
|
||||
{
|
||||
model.OrderProcedures.Remove(updateProcedure.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var record in model.OrderProcedure)
|
||||
foreach (var rp in model.OrderProcedures)
|
||||
{
|
||||
context.OrderProcedures.Add(new OrderProcedure
|
||||
{
|
||||
Order = order,
|
||||
Procedure = context.Procedures.First(x => x.Id == record.Procedure.Id),
|
||||
OrderProcedureCount = record.Count
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderProcedures = null;
|
||||
}
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
public void UpdateServices(BeautyStudioDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderCosmetic = context.OrderCosmetics
|
||||
.Where(x => x.OrderId == model.Id)
|
||||
.ToList();
|
||||
context.OrderCosmetics
|
||||
.RemoveRange(orderCosmetic);
|
||||
var orderServices = context.OrderServices.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderServices != null && orderServices.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.OrderServices.RemoveRange(orderServices.Where(rec => !model.OrderServices.ContainsKey(rec.ServiceId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateService in orderServices)
|
||||
{
|
||||
model.OrderServices.Remove(updateService.ServiceId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var record in model.OrderCosmetic)
|
||||
foreach (var rp in model.OrderServices)
|
||||
{
|
||||
context.OrderCosmetics.Add(new OrderCosmetic
|
||||
context.OrderServices.Add(new OrderService
|
||||
{
|
||||
Order = order,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id),
|
||||
Service = context.Services.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderCosmetics = null;
|
||||
_orderServices = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
|
@ -24,48 +24,50 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
[Required]
|
||||
public string ProcedureDescription { get; set; } = string.Empty;
|
||||
|
||||
// связь процедур и косметики многие - ко - многим
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<CosmeticProcedure> Cosmetics { get; set; } = new();
|
||||
|
||||
private List<CosmeticProcedureViewModel>? _cosmeticProcedures = null;
|
||||
[Required]
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _procedureCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
|
||||
[NotMapped]
|
||||
public List<CosmeticProcedureViewModel> CosmeticProcedures
|
||||
public Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics //представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
_cosmeticProcedures ??= Cosmetics
|
||||
.Select(pc => new CosmeticProcedureViewModel(pc.Cosmetic.GetViewModel, pc.Procedure.GetViewModel, pc.ProcedureCosmeticCount))
|
||||
.ToList();
|
||||
return _cosmeticProcedures;
|
||||
if (_procedureCosmetics == null)
|
||||
{
|
||||
_procedureCosmetics = Cosmetics
|
||||
.ToDictionary(recPC => recPC.CosmeticId, recPC => (recPC.Cosmetic as ICosmeticModel, recPC.ProcedureCosmeticCount));
|
||||
}
|
||||
return _procedureCosmetics;
|
||||
}
|
||||
}
|
||||
|
||||
// связь процедур и услуг многие - ко - многим
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<ServiceProcedure> Services { get; set; } = new();
|
||||
|
||||
// связь процедур и заказов многие - ко - многим
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<OrderProcedure> Orders { get; set; } = new();
|
||||
public virtual List<CosmeticProcedure> Cosmetics { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
|
||||
public static Procedure Create(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
return new Procedure()
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var procedure = new Procedure()
|
||||
{
|
||||
Id = model.Id,
|
||||
ProcedureName = model.ProcedureName,
|
||||
ProcedureCost = model.ProcedureCost,
|
||||
ProcedureDescription = model.ProcedureDescription,
|
||||
Cosmetics = model.ProcedureCosmetics.Select(x => new CosmeticProcedure()
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.ProcedureCosmetics.Select(x => new CosmeticProcedure
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id),
|
||||
ProcedureCosmeticCount = x.Count
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
|
||||
};
|
||||
|
||||
return procedure;
|
||||
}
|
||||
public void Update(ProcedureBindingModel model)
|
||||
{
|
||||
ProcedureName = model.ProcedureName;
|
||||
@ -79,28 +81,36 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
ProcedureName = ProcedureName,
|
||||
ProcedureCost = ProcedureCost,
|
||||
ProcedureDescription = ProcedureDescription,
|
||||
CosmeticProcedures = CosmeticProcedures
|
||||
ProcedureCosmetics = ProcedureCosmetics,
|
||||
StoreKeeperId = StoreKeeperId,
|
||||
StoreKeeperName = StoreKeeper.StoreKeeperFIO,
|
||||
};
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, ProcedureBindingModel model)
|
||||
{
|
||||
var procedureCosmetics = context.CosmeticProcedures
|
||||
.Where(x => x.ProcedureId == model.Id)
|
||||
.ToList();
|
||||
context.CosmeticProcedures
|
||||
.RemoveRange(procedureCosmetics);
|
||||
var procedureCosmetics = context.CosmeticProcedures.Where(rec => rec.ProcedureId == model.Id).ToList();
|
||||
if (procedureCosmetics != null && procedureCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.CosmeticProcedures.RemoveRange(procedureCosmetics.Where(rec => !model.ProcedureCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in procedureCosmetics)
|
||||
{
|
||||
model.ProcedureCosmetics.Remove(updateCosmetic.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var procedure = context.Procedures.First(x => x.Id == Id);
|
||||
foreach (var record in model.ProcedureCosmetics)
|
||||
foreach (var rp in model.ProcedureCosmetics)
|
||||
{
|
||||
context.CosmeticProcedures.Add(new CosmeticProcedure
|
||||
{
|
||||
Procedure = procedure,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id),
|
||||
ProcedureCosmeticCount = record.Count
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_cosmeticProcedures = null;
|
||||
_procedureCosmetics = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeautyStudioDatabaseImplement.Models
|
||||
{
|
||||
public class ProcedureCosmetic
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CosmeticId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Procedure Procedure { get; set; } = new();
|
||||
public virtual Cosmetic Cosmetic { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -27,66 +27,70 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
public int StoreKeeperId { get; set; }
|
||||
public virtual StoreKeeper StoreKeeper { get; set; }
|
||||
|
||||
// связь услуги и заказов многие - ко - многим
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<OrderService> Orders { get; set; } = new();
|
||||
|
||||
// связь услуги и косметки многие - ко - многим
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceCosmetic> Cosmetics { get; set; } = new();
|
||||
|
||||
// связь услуги и косметки многие - ко - многим
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceProcedure> Procedures { get; set; } = new();
|
||||
|
||||
private List<ServiceProcedureViewModel>? _serviceProcedures = null;
|
||||
|
||||
private Dictionary<int, (ICosmeticModel, int)>? _serviceCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
[NotMapped]
|
||||
public List<ServiceProcedureViewModel> ServiceProcedures
|
||||
public Dictionary<int, (ICosmeticModel, int)> ServiceCosmetics //представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
_serviceProcedures ??= Procedures
|
||||
.Select(pc => new ServiceProcedureViewModel(pc.Procedure.GetViewModel, pc.ServiceProcedureCount))
|
||||
.ToList();
|
||||
return _serviceProcedures;
|
||||
}
|
||||
}
|
||||
|
||||
private List<ServiceCosmeticViewModel>? _serviceCosmetics = null;
|
||||
[NotMapped]
|
||||
public List<ServiceCosmeticViewModel> ServiceCosmetics
|
||||
{
|
||||
get
|
||||
{
|
||||
_serviceCosmetics ??= Cosmetics
|
||||
.Select(pc => new ServiceCosmeticViewModel(pc.Cosmetic.GetViewModel, pc.Service.GetViewModel, pc.ServiceCosmeticCount))
|
||||
.ToList();
|
||||
if (_serviceCosmetics == null)
|
||||
{
|
||||
_serviceCosmetics = Cosmetics
|
||||
.ToDictionary(recPC => recPC.CosmeticId, recPC =>
|
||||
(recPC.Cosmetic as ICosmeticModel, recPC.ServiceCosmeticCount));
|
||||
}
|
||||
return _serviceCosmetics;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceCosmetic> Cosmetics { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
|
||||
|
||||
|
||||
private Dictionary<int, (IProcedureModel, int)>? _serviceProcedures = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IProcedureModel, int)> ServiceProcedures//представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_serviceProcedures == null)
|
||||
{
|
||||
_serviceProcedures = Procedures
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
(recPC.Procedure as IProcedureModel, recPC.ServiceProcedureCount));
|
||||
}
|
||||
return _serviceProcedures;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<ServiceProcedure> Procedures { get; set; } = new();//представляет список косметических товаров для данного заказа.
|
||||
|
||||
public static Service Create(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
{
|
||||
return new Service()
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var service = new Service()
|
||||
{
|
||||
Id = model.Id,
|
||||
ServiceName = model.ServiceName,
|
||||
ServicePrice = model.ServicePrice,
|
||||
Cosmetics = model.ServiceCosmetic.Select(x => new ServiceCosmetic()
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
Cosmetics = model.ServiceCosmetics.Select(x => new ServiceCosmetic
|
||||
{
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id),
|
||||
ServiceCosmeticCount = x.Count
|
||||
Cosmetic = context.Cosmetics.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Procedures = model.ServiceProcedure.Select(x => new ServiceProcedure()
|
||||
Procedures = model.ServiceProcedures.Select(x => new ServiceProcedure
|
||||
{
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Procedure.Id),
|
||||
ServiceProcedureCount = x.Count
|
||||
}).ToList(),
|
||||
StoreKeeperId = model.StoreKeeperId
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
public void Update(ServiceBindingModel model)
|
||||
{
|
||||
ServiceName = model.ServiceName;
|
||||
@ -99,47 +103,62 @@ namespace BeautyStudioDatabaseImplement.Models
|
||||
Id = Id,
|
||||
ServiceName = ServiceName,
|
||||
ServicePrice = ServicePrice,
|
||||
ServiceCosmetic = ServiceCosmetics,
|
||||
ServiceProcedure = ServiceProcedures,
|
||||
StoreKeeperId = StoreKeeperId
|
||||
ServiceCosmetics = ServiceCosmetics,
|
||||
ServiceProcedures = ServiceProcedures,
|
||||
StoreKeeperId = StoreKeeperId,
|
||||
};
|
||||
|
||||
|
||||
|
||||
public void UpdateCosmetics(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
{
|
||||
var serviceCosmetics = context.ServiceCosmetics
|
||||
.Where(x => x.ServiceId == model.Id)
|
||||
.ToList();
|
||||
context.ServiceCosmetics
|
||||
.RemoveRange(serviceCosmetics);
|
||||
var serviceCosmetics = context.ServiceCosmetics.Where(rec => rec.ServiceId == model.Id).ToList();
|
||||
if (serviceCosmetics != null && serviceCosmetics.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ServiceCosmetics.RemoveRange(serviceCosmetics.Where(rec => !model.ServiceCosmetics.ContainsKey(rec.CosmeticId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in serviceCosmetics)
|
||||
{
|
||||
model.ServiceCosmetics.Remove(updateCosmetic.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var service = context.Services.First(x => x.Id == Id);
|
||||
foreach (var record in model.ServiceCosmetic)
|
||||
foreach (var rp in model.ServiceCosmetics)
|
||||
{
|
||||
context.ServiceCosmetics.Add(new ServiceCosmetic
|
||||
{
|
||||
Service = service,
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id),
|
||||
ServiceCosmeticCount = record.Count
|
||||
Cosmetic = context.Cosmetics.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_serviceCosmetics = null;
|
||||
}
|
||||
|
||||
|
||||
public void UpdateProcedures(BeautyStudioDatabase context, ServiceBindingModel model)
|
||||
{
|
||||
var serviceProcedures = context.ServiceProcedures
|
||||
.Where(x => x.ServiceId == model.Id)
|
||||
.ToList();
|
||||
context.ServiceProcedures
|
||||
.RemoveRange(serviceProcedures);
|
||||
var serviceProcedures = context.ServiceProcedures.Where(rec => rec.ServiceId == model.Id).ToList();
|
||||
if (serviceProcedures != null && serviceProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ServiceProcedures.RemoveRange(serviceProcedures.Where(rec => !model.ServiceProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateCosmetic in serviceProcedures)
|
||||
{
|
||||
model.ServiceProcedures.Remove(updateCosmetic.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var service = context.Services.First(x => x.Id == Id);
|
||||
foreach (var record in model.ServiceProcedure)
|
||||
foreach (var rp in model.ServiceProcedures)
|
||||
{
|
||||
context.ServiceProcedures.Add(new ServiceProcedure
|
||||
{
|
||||
Service = service,
|
||||
Procedure = context.Procedures.First(x => x.Id == record.Procedure.Id),
|
||||
ServiceProcedureCount = record.Count
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ namespace BeautyStudioRestAPI.Controllers
|
||||
{
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
DateFrom = report.DateFrom,
|
||||
DateTo = report.DateTo,
|
||||
FileName = "C:\\reports\\pdfservicesreport.pdf",
|
||||
});
|
||||
}
|
||||
@ -70,8 +68,6 @@ namespace BeautyStudioRestAPI.Controllers
|
||||
{
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
DateFrom = report.DateFrom,
|
||||
DateTo = report.DateTo,
|
||||
FileName = report.FileName,
|
||||
StorekeeperId = report.StorekeeperId,
|
||||
Email = report.Email,
|
||||
|
161
BeautyStudio/StoreKeeperWebApp/Controllers/CosmeticController.cs
Normal file
161
BeautyStudio/StoreKeeperWebApp/Controllers/CosmeticController.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class CosmeticController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
private readonly ILaborCostLogic laborCost;
|
||||
private readonly IProcedureLogic procedure;
|
||||
|
||||
public CosmeticController(ILogger<CosmeticController> logger, ICosmeticLogic cosmetic, IProcedureLogic procedure, ILaborCostLogic laborCost)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
this.procedure = procedure;
|
||||
this.laborCost = laborCost;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CosmeticViewModel? GetCosmetic(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Cosmetics()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(cosmetic.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateCosmetics()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.LaborCost = laborCost.ReadList(new LaborCostSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCosmetics(string name, string brand, double price, int laborCost)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(brand) || price <= 0 || laborCost <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
cosmetic.Create(new CosmeticBindingModel
|
||||
{
|
||||
CosmeticName = name,
|
||||
CosmeticPrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
LaborCostId = laborCost
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateCosmetics(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.LaborCost = laborCost.ReadList(new LaborCostSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View(cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCosmetics(int id, string name, string brand, double price, int laborCost)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || laborCost <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
cosmetic.Update(new CosmeticBindingModel
|
||||
{
|
||||
Id = id,
|
||||
CosmeticName = name,
|
||||
CosmeticPrice = price,
|
||||
LaborCostId = laborCost
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить косметику
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public void DeleteCosmetics(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
cosmetic.Delete(new CosmeticBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Cosmetic/Cosmetics");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class LaborCostController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ILaborCostLogic laborCost;
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
|
||||
public LaborCostController(ILogger<LaborCostController> logger, ILaborCostLogic laborCost, ICosmeticLogic cosmetic)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.laborCost = laborCost;
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public LaborCostViewModel? GetLaborCost(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return laborCost.ReadElement(new LaborCostSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult LaborCost()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(laborCost.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateLaborCost()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateLaborCost(int hours, string difficulty, int cosmeticId)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (hours <= 0 || string.IsNullOrEmpty(difficulty) || cosmeticId <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
laborCost.Create(new LaborCostBindingModel
|
||||
{
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
var labor = laborCost.ReadElement(new LaborCostSearchModel {
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
var cosm = cosmetic.ReadElement(new CosmeticSearchModel{ Id = cosmeticId });
|
||||
if (cosm != null && labor != null)
|
||||
{
|
||||
cosm.LaborCostId = labor.Id; // Присваиваем айди трудозатраты к объекту косметики
|
||||
cosmetic.Update(new CosmeticBindingModel
|
||||
{
|
||||
Id = cosm.Id,
|
||||
CosmeticName = cosm.CosmeticName,
|
||||
CosmeticPrice = cosm.CosmeticPrice,
|
||||
LaborCostId = cosm.LaborCostId
|
||||
});
|
||||
}
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCost");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateLaborCost(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
});
|
||||
|
||||
return View(laborCost.ReadElement(new LaborCostSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateLaborCost(int hours, string difficulty)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(difficulty) || hours <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
laborCost.Update(new LaborCostBindingModel
|
||||
{
|
||||
TimeSpent = hours,
|
||||
Difficulty = difficulty,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCost");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить косметику
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public void DeleteLaborCost(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
laborCost.Delete(new LaborCostBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/LaborCost/LaborCost");
|
||||
}
|
||||
}
|
||||
}
|
164
BeautyStudio/StoreKeeperWebApp/Controllers/ServiceController.cs
Normal file
164
BeautyStudio/StoreKeeperWebApp/Controllers/ServiceController.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Контроллер для сущности "Рецепт"
|
||||
/// </summary>
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
private readonly ILogger<ServiceController> _logger;
|
||||
private readonly IServiceLogic _serviceLogic;
|
||||
private readonly ICosmeticLogic _cosmeticLogic;
|
||||
private readonly IProcedureLogic _procedureLogic;
|
||||
|
||||
public ServiceController(ILogger<ServiceController> logger, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic, IProcedureLogic procedurecLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceLogic = serviceLogic;
|
||||
_cosmeticLogic = cosmeticLogic;
|
||||
_procedureLogic = procedurecLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Services()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(_serviceLogic.ReadList(new ServiceSearchModel
|
||||
{
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateServices()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = _cosmeticLogic.ReadList(null);
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateServices(string name, double price, int count, List<int> cosmetics, List<int> procedures)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || price <= 0 || cosmetics == null || procedures == null)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, (ICosmeticModel, int)> serviceCosmetics = new Dictionary<int, (ICosmeticModel, int)>();
|
||||
foreach (var cosmeticId in cosmetics)
|
||||
{
|
||||
serviceCosmetics.Add(cosmeticId, (_cosmeticLogic.ReadElement(new CosmeticSearchModel { Id = cosmeticId })!, count));
|
||||
}
|
||||
|
||||
Dictionary<int, (IProcedureModel, int)> serviceProcedures = new Dictionary<int, (IProcedureModel, int)>();
|
||||
foreach (var procedureId in cosmetics)
|
||||
{
|
||||
serviceProcedures.Add(procedureId, (_procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!, count));
|
||||
}
|
||||
|
||||
_serviceLogic.Create(new ServiceBindingModel
|
||||
{
|
||||
ServiceName = name,
|
||||
ServicePrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
ServiceCosmetics = serviceCosmetics,
|
||||
ServiceProcedures = serviceProcedures
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateServices(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cosmetics = _cosmeticLogic.ReadList(null);
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
||||
|
||||
return View(_serviceLogic.ReadElement(new ServiceSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateServices(int id, string name, double price, List<int> cosmetics, List<int> procedures)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || price <= 0 || cosmetics == null || procedures == null)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
Dictionary<int, (ICosmeticModel, int)> serviceCosmetics = new Dictionary<int, (ICosmeticModel, int)>();
|
||||
foreach (var cosmeticId in cosmetics)
|
||||
{
|
||||
serviceCosmetics.Add(cosmeticId, (_cosmeticLogic.ReadElement(new CosmeticSearchModel { Id = cosmeticId })!, 1));
|
||||
}
|
||||
|
||||
Dictionary<int, (IProcedureModel, int)> serviceProcedures = new Dictionary<int, (IProcedureModel, int)>();
|
||||
foreach (var procedureId in cosmetics)
|
||||
{
|
||||
serviceProcedures.Add(procedureId, (_procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId })!, 1));
|
||||
}
|
||||
|
||||
_serviceLogic.Update(new ServiceBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ServiceName = name,
|
||||
ServicePrice = price,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
|
||||
ServiceCosmetics = serviceCosmetics,
|
||||
ServiceProcedures = serviceProcedures
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteService(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
_serviceLogic.Delete(new ServiceBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Service/Services");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,69 @@
|
||||
using BeautyStudioBusinessLogic.BusinessLogic;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.StoragesContracts;
|
||||
using BeautyStudioBusinessLogic.OfficePackage.Implements;
|
||||
using BeautyStudioBusinessLogic.OfficePackage;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using BeautyStudioDatabaseImplement.Implements;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
// Logger service
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<ILaborCostStorage, LaborCostStorage>();
|
||||
builder.Services.AddTransient<ICosmeticStorage, CosmeticStorage>();
|
||||
builder.Services.AddTransient<IStoreKeeperStorage, StoreKeeperStorage>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<ILaborCostLogic, LaborCostLogic>();
|
||||
builder.Services.AddTransient<ICosmeticLogic, CosmeticLogic>();
|
||||
builder.Services.AddTransient<IStoreKeeperLogic, StoreKeeperLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configuration for MailService
|
||||
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
||||
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
||||
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
||||
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
||||
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||
});
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.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.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();
|
||||
@ -21,7 +74,7 @@ app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
|
@ -0,0 +1,69 @@
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model List<CosmeticViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Косметика";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Косметика</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateCosmetics">Создать косметику</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Бренд</th>
|
||||
<th>Цена</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var cosmetics in Model)
|
||||
{
|
||||
<tr>
|
||||
<th>@cosmetics.Id</th>
|
||||
<td>@cosmetics.CosmeticName</td>
|
||||
<td>@cosmetics.CosmeticPrice</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateCosmetics", "/Cosmetic", new { id = cosmetics.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteCosmetic(@cosmetics.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteCosmetic(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить косметику?")) {
|
||||
$.post('@Url.Action("DeleteCosmetics", "/Cosmetic")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,41 @@
|
||||
@{
|
||||
ViewData["Title"] = "Косметика";
|
||||
ViewData["Title"] = "Создание косметики";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Создать косметику</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание косметики</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Cosmetic" asp-action="Create">
|
||||
<p class="mb-0">Бренд:</p>
|
||||
<input type="text" name="brand" class="form-control mb-3" />
|
||||
<p class="mb-0">Наименование косметики:</p>
|
||||
<input type="text" name="cosmeticName" class="form-control mb-3" />
|
||||
<p class="mb-0">Стоимость:</p>
|
||||
<input type="number" step="0.01" min="0.01" name="cosmeticPrice" class="form-control mb-3" />
|
||||
<p class="mb-0">Выбрать трудозатрату для привязки:</p>
|
||||
<select class="form-select mb-2" name="laborCostsId">
|
||||
@foreach (var laborCosts in @ViewBag.LaborCostsList)
|
||||
{
|
||||
<option value="@laborCosts.Id">
|
||||
часы: @(laborCosts.NumberHours), сложность: @(laborCosts.Difficulty)
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<button type="submit" class="btn button-primary">
|
||||
Создать
|
||||
</button>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Название -->
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Цена -->
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" id="price" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Трудозатрата -->
|
||||
<div class="row">
|
||||
<div class="col-4">Трудозатрата:</div>
|
||||
<div class="col-8">
|
||||
<select name="laborCost" id="laborCost" class="form-control">
|
||||
@foreach (var laborCost in ViewBag.LaborCosts)
|
||||
{
|
||||
<option value="@laborCost.Id">@laborCost.Id</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Создать" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -1,36 +1,45 @@
|
||||
@{
|
||||
ViewData["Title"] = "Косметика";
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model CosmeticViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование косметики";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Обновить косметику</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование косметики</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Cosmetic" asp-action="Update">
|
||||
<input name="id" value="@ViewBag.Cosmetic.Id" style="display: none;" />
|
||||
<p class="mb-0">Бренд:</p>
|
||||
<input type="text" value="@ViewBag.Cosmetic.Brand" name="brand" class="form-control mb-3" />
|
||||
<p class="mb-0">Наименование косметики:</p>
|
||||
<input type="text" value="@ViewBag.Cosmetic.CosmeticName" name="cosmeticName" class="form-control mb-3" />
|
||||
<p class="mb-0">Стоимость:</p>
|
||||
<input type="number" step="0.01" value="0.01" name="cosmeticPrice" class="form-control mb-3" />
|
||||
<p class="mb-0">Трудозатраты:</p>
|
||||
<select class="form-select mb-2" name="laborCostsId">
|
||||
@foreach (var laborCosts in @ViewBag.LaborCostsList)
|
||||
{
|
||||
@if (laborCosts.Id == ViewBag.Service.LaborCostsId)
|
||||
{
|
||||
<option value="@laborCosts.Id" selected>
|
||||
часы: @(laborCosts.NumberHours), специалисты: @(laborCosts.NumberSpecialists)
|
||||
</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@laborCosts.Id">
|
||||
часы: @(laborCosts.NumberHours), специалисты: @(laborCosts.NumberSpecialists)
|
||||
</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<button type="submit" class="button-primary">
|
||||
Обновить
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Название -->
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.CosmeticName" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Цена -->
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" value="@Model.CosmeticPrice" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Трудозатрата -->
|
||||
<div class="row">
|
||||
<div class="col-4">Трудозатрата:</div>
|
||||
<div class="col-8">
|
||||
<select name="laborCost" id="laborCost" class="form-control">
|
||||
@foreach (var laborCost in ViewBag.LaborCosts)
|
||||
{
|
||||
var isSelected = Model.LaborCostId.Equals(laborCost.Id);
|
||||
<option value="@laborCost.Id" selected="@isSelected">@laborCost.Id</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Сохранить" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,15 +1,38 @@
|
||||
@{
|
||||
ViewData["Title"] = "Трудозатраты";
|
||||
ViewData["Title"] = "Трудозатраты";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Создать трудозатрату</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание трудозатрат</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="LaborCost" asp-action="Create">
|
||||
<p class="mb-0">Количество часов:</p>
|
||||
<input type="number" name="TimeSpent" class="form-control mb-3" />
|
||||
<p class="mb-0">Сложность:</p>
|
||||
<input type="text" name="difficulty" class="form-control mb-3" />
|
||||
<button type="submit" class="btn button-primary">
|
||||
Создать
|
||||
</button>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<div class="row">
|
||||
<div class="col-4">Количество часов:</div>
|
||||
<div class="col-8"><input type="text" name="hours" id="hours" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Сложность:</div>
|
||||
<div class="col-8"><input type="text" name="difficulty" id="difficulty" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Косметика:</div>
|
||||
<div class="col-8">
|
||||
<select name="cosmeticId" id="cosmeticId" class="form-control">
|
||||
@foreach (var cosmetic in ViewBag.Cosmetics)
|
||||
{
|
||||
<option value="@cosmetic.Id">@cosmetic.Id</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Создать" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model List<LaborCostViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Трудозатраты";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Трудозатраты</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateLaborCosts">Создать Трудозатрату</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Количество часов</th>
|
||||
<th>Сложность</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var laborCosts in Model)
|
||||
{
|
||||
<tr>
|
||||
<th>@laborCosts.Id</th>
|
||||
<td>@laborCosts.TimeSpent</td>
|
||||
<td>@laborCosts.Difficulty</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateLaborCosts", "/LaborCost", new { id = laborCosts.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteLaborCost(@laborCosts.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteLaborCost(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить трудозатрату?")) {
|
||||
$.post('@Url.Action("DeleteLaborCosts", "/LaborCost")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "Трудозатраты";
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model LaborCostViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование трудозатраты";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Обновить трудозатраты</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование трудозатраты</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="LaborCost" asp-action="Update">
|
||||
<input name="id" value="@ViewBag.LaborCost.Id" style="display: none;" />
|
||||
<p class="mb-0">Количество часов:</p>
|
||||
<input type="number" value="@ViewBag.LaborCost.TimeSpent" name="timeSpent" class="form-control mb-3" />
|
||||
<p class="mb-0">Сложность:</p>
|
||||
<input type="text" value="@ViewBag.LaborCost.Difficulty" name="difficulty" class="form-control mb-3" />
|
||||
<button type="submit" class="btn button-primary">
|
||||
Обновить
|
||||
</button>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<div class="row">
|
||||
<div class="col-4">Количество часов:</div>
|
||||
<div class="col-8"><input type="text" name="hours" value="@Model.TimeSpent" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Сложность:</div>
|
||||
<div class="col-8"><input type="text" name="difficulty" value="@Model.Difficulty" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Сохранить" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,51 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Binding";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Связать услугу с косметикой</h4>
|
||||
|
||||
<p class="mb-0">
|
||||
<span>Id услуги: </span>
|
||||
<span id="id">@ViewBag.ServiceId</span>
|
||||
</p>
|
||||
<p>
|
||||
<span>Наименование услуги: </span>
|
||||
<span id="service-name-span"></span>
|
||||
</p>
|
||||
<p class="mb-0">Привязанная косметика:</p>
|
||||
<div class="table-shell mb-2 border">
|
||||
<table class="table mb-0">
|
||||
<thead class="table-head">
|
||||
<tr>
|
||||
<th>Наименование</th>
|
||||
<th>Стоимость</th>
|
||||
<th>Количество</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
<tr>
|
||||
<td>Не выбрано</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p class="mb-0">Добавить косметику:</p>
|
||||
<p class="mb-0">Наименование:</p>
|
||||
<select class="form-select mb-0" id="cosmetic-select"></select>
|
||||
<p class="mb-0">Количество:</p>
|
||||
<input type="number" min="1" value="1" id="count-input" class="form-control mb-2" />
|
||||
<button id="add-button" class="button-primary">
|
||||
Добавить
|
||||
</button>
|
||||
|
||||
<button id="bind-button" class="button-primary text-button">
|
||||
Привязать
|
||||
</button>
|
||||
|
||||
<script src="~/js/bind.js" asp-append-version="true"></script>
|
@ -1,15 +1,47 @@
|
||||
@{
|
||||
ViewData["Title"] = "Услуги";
|
||||
ViewData["Title"] = "Создание услуг";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Создать услугу</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание услуги</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Service" asp-action="Create">
|
||||
<p class="mb-0">Наименование услуги:</p>
|
||||
<input name="serviceName" class="form-control mb-2" />
|
||||
<p class="mb-0">Стоимость услуги:</p>
|
||||
<input type="number" step="0.01" name="servicePrice" class="form-control mb-2" />
|
||||
<button id="create-button" class="button-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" class="form-control" name="name" id="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" class="form-control" name="price" id="price" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Процедуры:</div>
|
||||
<div class="col-8">
|
||||
<select name="procedures" id="procedures" class="form-control" size="4" multiple>
|
||||
@foreach (var procedure in ViewBag.Procedures)
|
||||
{
|
||||
<option value="@procedure.Id">@procedure.ProcedureName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Косметика:</div>
|
||||
<div class="col-8">
|
||||
<select name="cosmetics" id="cosmetics" class="form-control" size="4" multiple>
|
||||
@foreach (var cosmetic in ViewBag.Cosmetics)
|
||||
{
|
||||
<option value="@cosmetic.Id">@cosmetic.CosmeticName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Создать" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
67
BeautyStudio/StoreKeeperWebApp/Views/Service/Services.cshtml
Normal file
67
BeautyStudio/StoreKeeperWebApp/Views/Service/Services.cshtml
Normal file
@ -0,0 +1,67 @@
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model List<ServiceViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Услуги";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Услуги</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateServices">Создать Услугу</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Цена</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var service in Model)
|
||||
{
|
||||
<tr>
|
||||
<th>@service.Id</th>
|
||||
<td>@service.ServiceName</td>
|
||||
<td>@service.ServicePrice</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateServices", "/Service", new { id = service.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteService(@service.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteService(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить услугу?")) {
|
||||
$.post('@Url.Action("deleteService", "/Service")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
@ -1,18 +1,54 @@
|
||||
@{
|
||||
ViewData["Title"] = "Услуга";
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model ServiceViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Создание услуги";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Обновить услугу</h4>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование услуги</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Service" asp-action="Update">
|
||||
<input name="id" value="@ViewBag.Service.Id" style="display: none;" />
|
||||
<p class="mb-0">Наименование услуги:</p>
|
||||
<input value="@ViewBag.Service.ServiceName" name="serviceName" class="form-control mb-2" />
|
||||
<p class="mb-0">Стоимость услуги:</p>
|
||||
<input value="@ViewBag.Service.ServicePrice.ToString("0.00").Replace(",", ".")"
|
||||
type="number" step="0.01" name="servicePrice" class="form-control mb-2" />
|
||||
<button class="button-primary">
|
||||
Обновить
|
||||
</button>
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" class="form-control" name="name" value="@Model.ServiceName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="date" class="form-control" name="name" value="@Model.ServicePrice" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Процедуры:</div>
|
||||
<div class="col-8">
|
||||
<select name="procedures" id="procedures" class="form-control" size="4" multiple>
|
||||
@foreach (var procedure in ViewBag.Procedures)
|
||||
{
|
||||
var isSelected = Model.ServiceProcedures.Any(x => x.Key.Equals(procedure.Id));
|
||||
<option value="@procedure.Id" selected="@isSelected">@procedure.ProcedureName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Косметика:</div>
|
||||
<div class="col-8">
|
||||
<select name="cosmetics" id="cosmetics" class="form-control" size="4" multiple>
|
||||
@foreach (var cosmetic in ViewBag.Cosmetics)
|
||||
{
|
||||
var isSelected = Model.ServiceCosmetics.Any(x => x.Key.Equals(cosmetic.Id));
|
||||
<option value="@cosmetic.Id" selected="@isSelected">@cosmetic.CosmeticName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Сохранить" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
5
BeautyStudio/StoreKeeperWebApp/libman.json
Normal file
5
BeautyStudio/StoreKeeperWebApp/libman.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"defaultProvider": "cdnjs",
|
||||
"libraries": []
|
||||
}
|
15
BeautyStudio/StoreKeeperWebApp/nlog.config
Normal file
15
BeautyStudio/StoreKeeperWebApp/nlog.config
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="С:\Logs/log-${shortdate}.log" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minLevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user