Compare commits
9 Commits
6ae8e7b62c
...
b68b8a75f2
Author | SHA1 | Date | |
---|---|---|---|
b68b8a75f2 | |||
5f9b1f4a2f | |||
c48da815bb | |||
ce896bda7e | |||
a2b722b517 | |||
81b5398465 | |||
a97287aaae | |||
b10e63f24f | |||
7e98fb81ef |
117
ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs
Normal file
117
ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ComputerShopBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class AssemblyLogic : IAssemblyLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IAssemblyStorage _assemblyStorage;
|
||||||
|
|
||||||
|
public AssemblyLogic(ILogger<AssemblyLogic> Logger, IAssemblyStorage AssemblyStorage)
|
||||||
|
{
|
||||||
|
_logger = Logger;
|
||||||
|
_assemblyStorage = AssemblyStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AssemblyViewModel>? ReadList(AssemblySearchModel? Model)
|
||||||
|
{
|
||||||
|
var List = (Model == null) ? _assemblyStorage.GetFullList() : _assemblyStorage.GetFilteredList(Model);
|
||||||
|
|
||||||
|
if (List == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", List.Count);
|
||||||
|
return List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel? ReadElement(AssemblySearchModel Model)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
var Element = _assemblyStorage.GetElement(Model);
|
||||||
|
if (Element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement Assembly not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement Assembly found. Id: {Id}", Element.Id);
|
||||||
|
return Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_assemblyStorage.Insert(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_assemblyStorage.Update(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", Model.Id);
|
||||||
|
|
||||||
|
if (_assemblyStorage.Delete(Model) is null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(AssemblyBindingModel Model, bool WithParams = true)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
if (!WithParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.AssemblyName))
|
||||||
|
throw new ArgumentException($"У сборки отсутствует название");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.Category))
|
||||||
|
throw new ArgumentException($"У сборки отсутствует категория");
|
||||||
|
|
||||||
|
if (Model.Price <= 0)
|
||||||
|
throw new ArgumentException("Цена сборки должна быть больше 0", nameof(Model.Price));
|
||||||
|
|
||||||
|
var Element = _assemblyStorage.GetElement(new AssemblySearchModel
|
||||||
|
{
|
||||||
|
AssemblyName = Model.AssemblyName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Element != null && Element.Id != Model.Id)
|
||||||
|
throw new InvalidOperationException("Товар с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs
Normal file
114
ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ComputerShopBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ComponentLogic : IComponentLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IComponentStorage _componentStorage;
|
||||||
|
|
||||||
|
public ComponentLogic(ILogger<ComponentLogic> Logger, IComponentStorage ComponentStorage)
|
||||||
|
{
|
||||||
|
_logger = Logger;
|
||||||
|
_componentStorage = ComponentStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel>? ReadList(ComponentSearchModel? Model)
|
||||||
|
{
|
||||||
|
var List = (Model == null) ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(Model);
|
||||||
|
|
||||||
|
if (List == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", List.Count);
|
||||||
|
return List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? ReadElement(ComponentSearchModel Model)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
var Element = _componentStorage.GetElement(Model);
|
||||||
|
if (Element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement component not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement component found. Id: {Id}", Element.Id);
|
||||||
|
return Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_componentStorage.Insert(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_componentStorage.Update(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", Model.Id);
|
||||||
|
|
||||||
|
if (_componentStorage.Delete(Model) is null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ComponentBindingModel Model, bool WithParams = true)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
if (!WithParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.ComponentName))
|
||||||
|
throw new ArgumentException($"У комплектующей отсутствует название");
|
||||||
|
|
||||||
|
if (Model.Cost <= 0)
|
||||||
|
throw new ArgumentException("Цена комплектующей должна быть больше 0", nameof(Model.Cost));
|
||||||
|
|
||||||
|
var Element = _componentStorage.GetElement(new ComponentSearchModel
|
||||||
|
{
|
||||||
|
ComponentName = Model.ComponentName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Element != null && Element.Id != Model.Id)
|
||||||
|
throw new InvalidOperationException("Комплектующая с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -84,7 +84,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
public bool Update(OrderBindingModel model)
|
public bool Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
@ -113,7 +112,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
|
private bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
@ -133,13 +131,8 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (order.Status + 1 != newStatus)
|
_logger.LogWarning("Change status operation failed. Incorrect new status: {newStatus}. Current status: {currStatus}", newStatus, order.Status);
|
||||||
{
|
return false;
|
||||||
_logger.LogWarning("Change status operation failed. Incorrect new status: {newStatus}. Current status: {currStatus}", newStatus, order.Status);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_logger.LogWarning("Changing status operation faled: current:{Status}: required:{newStatus}.", model.Status, newStatus);
|
|
||||||
throw new ArgumentException($"Невозможно присвоить статус {newStatus} заказу с текущим статусом {model.Status}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Перевод заказа в состояние выполнения
|
//Перевод заказа в состояние выполнения
|
||||||
|
117
ComputerShopBusinessLogic/BusinessLogics/ProductLogic.cs
Normal file
117
ComputerShopBusinessLogic/BusinessLogics/ProductLogic.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ComputerShopBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ProductLogic : IProductLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProductStorage _productStorage;
|
||||||
|
|
||||||
|
public ProductLogic(ILogger<ProductLogic> Logger, IProductStorage ProductStorage)
|
||||||
|
{
|
||||||
|
_logger = Logger;
|
||||||
|
_productStorage = ProductStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel>? ReadList(ProductSearchModel? Model)
|
||||||
|
{
|
||||||
|
var List = (Model == null) ? _productStorage.GetFullList() : _productStorage.GetFilteredList(Model);
|
||||||
|
|
||||||
|
if (List == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", List.Count);
|
||||||
|
return List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? ReadElement(ProductSearchModel Model)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
var Element = _productStorage.GetElement(Model);
|
||||||
|
if (Element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement Product not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement Product found. Id: {Id}", Element.Id);
|
||||||
|
return Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_productStorage.Insert(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_productStorage.Update(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
CheckModel(Model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", Model.Id);
|
||||||
|
|
||||||
|
if (_productStorage.Delete(Model) is null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ProductBindingModel Model, bool WithParams = true)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
if (!WithParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.ProductName))
|
||||||
|
throw new ArgumentException($"У товара отсутствует название");
|
||||||
|
|
||||||
|
if (Model.Price <= 0)
|
||||||
|
throw new ArgumentException("Цена товара должна быть больше 0", nameof(Model.Price));
|
||||||
|
|
||||||
|
if (Model.Warranty <= 0)
|
||||||
|
throw new ArgumentException("Гарантия на товар должна быть больше 0", nameof(Model.Warranty));
|
||||||
|
|
||||||
|
var Element = _productStorage.GetElement(new ProductSearchModel
|
||||||
|
{
|
||||||
|
ProductName = Model.ProductName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Element != null && Element.Id != Model.Id)
|
||||||
|
throw new InvalidOperationException("Товар с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -75,18 +75,10 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ConnectRequestAssembly(RequestBindingModel model)
|
||||||
//!!!мб УДАЛИТЬ
|
|
||||||
//public bool AddOrder(int requestId, int orderId)
|
|
||||||
//{
|
|
||||||
// return _requestStorage.ConnectRequestAssembly(requestId, assemblyId);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
public bool ConnectRequestAssembly(int requestId, int assemblyId)
|
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Connect Assembly {rId} with request {aId}", requestId, assemblyId);
|
_logger.LogInformation("Connect request {rId} with assembly {aId}", model.Id, model.AssemblyId);
|
||||||
return _requestStorage.ConnectRequestAssembly(requestId, assemblyId);
|
return _requestStorage.ConnectRequestAssembly(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(RequestBindingModel model)
|
public bool Delete(RequestBindingModel model)
|
||||||
@ -100,7 +92,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//!!!мб проверять, что есть userID
|
|
||||||
private void CheckModel(RequestBindingModel model, bool withParams = true)
|
private void CheckModel(RequestBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -24,8 +24,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
_shipmentStorage = shipmentStorage;
|
_shipmentStorage = shipmentStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ТУТ МБ ПО-ДРУГОМУ ПРИСВАИВАТЬ ЗНАЧЕНИЕ ДЛЯ list (через fulllist)
|
|
||||||
//!!!ИЛИ СОЗДАТЬ ОТДЕЛЬНЫЙ МЕТОД ReadListUser
|
|
||||||
public List<ShipmentViewModel> ReadList(ShipmentSearchModel? model)
|
public List<ShipmentViewModel> ReadList(ShipmentSearchModel? model)
|
||||||
{
|
{
|
||||||
//model.UserId = -1 для swagger, чтобы можно было считать все партии товаров всех пользователей
|
//model.UserId = -1 для swagger, чтобы можно было считать все партии товаров всех пользователей
|
||||||
|
@ -23,7 +23,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
_userStorage = userStorage;
|
_userStorage = userStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!мб поменять текст для логов
|
|
||||||
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("User ReadList. Login:{Login} Emain:{Email} Id:{Id}", model?.Login, model?.Email, model?.Id);
|
_logger.LogInformation("User ReadList. Login:{Login} Emain:{Email} Id:{Id}", model?.Login, model?.Email, model?.Id);
|
||||||
@ -88,7 +87,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!мб проверять, что есть userID
|
|
||||||
private void CheckModel(UserBindingModel model, bool withParams = true)
|
private void CheckModel(UserBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -111,8 +109,8 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет почты пользователя", nameof(model.Email));
|
throw new ArgumentNullException("Нет почты пользователя", nameof(model.Email));
|
||||||
}
|
}
|
||||||
//Проверка на уникальность. Проверить одной сущностью или 2-мя (один с таким же логином, второй с такой же почтой)?
|
|
||||||
|
|
||||||
|
//Проверки на уникальность
|
||||||
//проверка уникальности логина
|
//проверка уникальности логина
|
||||||
var user1 = _userStorage.GetElement(new UserSearchModel
|
var user1 = _userStorage.GetElement(new UserSearchModel
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
|
|
||||||
public string AssemblyName { get; set; } = string.Empty;
|
public string AssemblyName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public string Category { get; set; } = string.Empty;
|
public string Category { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
@ -14,12 +14,6 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
//!!!УДАЛИТЬ (после того, как нормально будут многие-ко-многим между заказами и заявками)
|
|
||||||
//public Dictionary<int, IRequestModel> OrderRequests { get; set; } = new();
|
|
||||||
|
|
||||||
//!!!УДАЛИТЬ (после того, как нормально будут многие-ко-многим между заказами и партиями)
|
|
||||||
//public Dictionary<int, IShipmentModel> OrderShipments { get; set; } = new();
|
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
@ -7,15 +7,15 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int? ShipmentId { get; set; }
|
||||||
|
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public int Warranty { get; set; }
|
public int Warranty { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
|
|
||||||
public int? ShipmentId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
|
|
||||||
public DateTime DateRequest { get; set; } = DateTime.Now;
|
public DateTime DateRequest { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
//!!!МБ НЕ НАДО string.Empty
|
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
||||||
|
@ -13,7 +13,6 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
//!!!МБ НЕ НАДО string.Empty
|
|
||||||
public string ProviderName { get; set; } = string.Empty;
|
public string ProviderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateShipment { get; set; } = DateTime.Now;
|
public DateTime DateShipment { get; set; } = DateTime.Now;
|
||||||
|
@ -11,13 +11,13 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
public class UserBindingModel : IUserModel
|
public class UserBindingModel : IUserModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
//!!!МБ НЕ НАДО string.Empty
|
|
||||||
public string Login { get; set; } = string.Empty;
|
public string Login { get; set; } = string.Empty;
|
||||||
//!!!МБ НЕ НАДО string.Empty
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
//!!!МБ НЕ НАДО string.Empty
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
//!!!МБ НЕ НАДО ПО УМОЛЧАНИЮ СТАВИТЬ "НЕИЗВЕСТНАЯ"
|
|
||||||
public UserRole Role { get; set; } = UserRole.Неизвестная;
|
public UserRole Role { get; set; } = UserRole.Неизвестная;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopContracts.BusinessLogicContracts
|
namespace ComputerShopContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО НЕ НУЖНЫ ДРУГИЕ МЕТОДЫ
|
|
||||||
public interface IOrderLogic
|
public interface IOrderLogic
|
||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopContracts.BusinessLogicContracts
|
namespace ComputerShopContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО НЕ НУЖНЫ ДРУГИЕ МЕТОДЫ
|
|
||||||
public interface IRequestLogic
|
public interface IRequestLogic
|
||||||
{
|
{
|
||||||
List<RequestViewModel>? ReadList(RequestSearchModel? model);
|
List<RequestViewModel>? ReadList(RequestSearchModel? model);
|
||||||
@ -17,6 +16,6 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
|||||||
bool Create(RequestBindingModel model);
|
bool Create(RequestBindingModel model);
|
||||||
bool Update(RequestBindingModel model);
|
bool Update(RequestBindingModel model);
|
||||||
bool Delete(RequestBindingModel model);
|
bool Delete(RequestBindingModel model);
|
||||||
bool ConnectRequestAssembly(int requestId, int assemblyId);
|
bool ConnectRequestAssembly(RequestBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopContracts.BusinessLogicContracts
|
namespace ComputerShopContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО НЕ НУЖНЫ ДРУГИЕ МЕТОДЫ
|
|
||||||
public interface IShipmentLogic
|
public interface IShipmentLogic
|
||||||
{
|
{
|
||||||
List<ShipmentViewModel>? ReadList(ShipmentSearchModel? model);
|
List<ShipmentViewModel>? ReadList(ShipmentSearchModel? model);
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
|
public string? AssemblyName { get; set; }
|
||||||
|
|
||||||
public string? Category { get; set; }
|
public string? Category { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,7 @@
|
|||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
|
public string? ComponentName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,7 @@
|
|||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
public int? ShipmentId { get; set; }
|
public int? ShipmentId { get; set; }
|
||||||
|
|
||||||
|
public string? ProductName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ namespace ComputerShopContracts.StorageContracts
|
|||||||
RequestViewModel? Insert(RequestBindingModel model);
|
RequestViewModel? Insert(RequestBindingModel model);
|
||||||
RequestViewModel? Update(RequestBindingModel model);
|
RequestViewModel? Update(RequestBindingModel model);
|
||||||
RequestViewModel? Delete(RequestBindingModel model);
|
RequestViewModel? Delete(RequestBindingModel model);
|
||||||
bool ConnectRequestAssembly(int requestId, int assemblyId);
|
bool ConnectRequestAssembly(RequestBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
public string AssemblyName { get; set; } = string.Empty;
|
public string AssemblyName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Стоимость")]
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[DisplayName("Категория")]
|
[DisplayName("Категория")]
|
||||||
public string Category { get; set; } = string.Empty;
|
public string Category { get; set; } = string.Empty;
|
||||||
|
@ -16,15 +16,6 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//!!!ТУТ МБ НАДО DisplayName (НО ВЯРД ЛИ)
|
|
||||||
|
|
||||||
//!!!УДАЛИТЬ (если нормально работает многие-ко-многим)
|
|
||||||
|
|
||||||
//public Dictionary<int, IRequestModel> OrderRequests { get; set; } = new();
|
|
||||||
//public Dictionary<int, IShipmentModel> OrderShipments { get; set; } = new();
|
|
||||||
|
|
||||||
//!!!МБ НЕ НУЖНО DateTime.Now
|
|
||||||
[DisplayName("Дата оформления")]
|
[DisplayName("Дата оформления")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
@ -33,6 +24,5 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Стоимость")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,20 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int? ShipmentId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Поставщик")]
|
||||||
|
public string? ProviderName { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название товара")]
|
[DisplayName("Название товара")]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Стоимость")]
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[DisplayName("Гарантия (мес.)")]
|
[DisplayName("Гарантия (мес.)")]
|
||||||
public int Warranty { get; set; }
|
public int Warranty { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
|
|
||||||
public int? ShipmentId { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Поставщик")]
|
|
||||||
public string ProviderName { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
//!!!ТУТ МБ НЕ НУЖЕН DisplayName
|
|
||||||
//[DisplayName("Номер пользователя")]
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
//id сборки
|
//id сборки
|
||||||
@ -26,11 +24,9 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
||||||
|
|
||||||
//!!!МБ НЕ НУЖНО DateTime.Now
|
|
||||||
[DisplayName("Дата оформления")]
|
[DisplayName("Дата оформления")]
|
||||||
public DateTime DateRequest { get; set; } = DateTime.Now;
|
public DateTime DateRequest { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
//!!!МБ НЕ НУЖЕН string.Empty
|
|
||||||
[DisplayName("ФИО клиента")]
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,18 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ShipmentViewModel : IShipmentModel
|
public class ShipmentViewModel : IShipmentModel
|
||||||
{
|
{
|
||||||
//!!!ТУТ МБ НЕ НУЖЕН DisplayName
|
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
//!!!ТУТ МБ НЕ НУЖЕН DisplayName
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, IOrderModel> ShipmentOrders { get; set; } = new();
|
public Dictionary<int, IOrderModel> ShipmentOrders { get; set; } = new();
|
||||||
|
|
||||||
//!!!МБ НЕ НУЖЕН string.Empty
|
|
||||||
[DisplayName("Поставщик")]
|
[DisplayName("Поставщик")]
|
||||||
public string ProviderName { get; set; } = string.Empty;
|
public string ProviderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
//!!!МБ НЕ НУЖНО DateTime.Now
|
|
||||||
[DisplayName("Дата поставки")]
|
[DisplayName("Дата поставки")]
|
||||||
public DateTime DateShipment { get; set; } = DateTime.Now;
|
public DateTime DateShipment { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
@ -11,10 +11,8 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class UserViewModel : IUserModel
|
public class UserViewModel : IUserModel
|
||||||
{
|
{
|
||||||
//!!!МБ ТУТ НАДО DisplayName (НО ВРЯД ЛИ)
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
//!!!МБ ТУТ НЕ НУЖНЫ string.Empty
|
|
||||||
[DisplayName("Логин")]
|
[DisplayName("Логин")]
|
||||||
public string Login { get; set; } = string.Empty;
|
public string Login { get; set; } = string.Empty;
|
||||||
|
|
||||||
@ -24,7 +22,6 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
[DisplayName("Почта")]
|
[DisplayName("Почта")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
//!!!МБ ТУТ НАДО DisplayName (НО ВРЯД ЛИ)
|
|
||||||
public UserRole Role { get; set; }
|
public UserRole Role { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стоимость
|
/// Стоимость
|
||||||
/// </summary>
|
/// </summary>
|
||||||
double Cost { get; }
|
double Price { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Категория
|
/// Категория
|
||||||
|
@ -12,21 +12,6 @@ namespace ComputerShopDataModels.Models
|
|||||||
//ID пользователя, который создал заказ
|
//ID пользователя, который создал заказ
|
||||||
int UserId { get; }
|
int UserId { get; }
|
||||||
|
|
||||||
//!!!УДАЛИТЬ (после того, как нормально будут многие-ко-многим между заказами и партиями)
|
|
||||||
/// <summary>
|
|
||||||
/// Заявки в заказе (может не быть)
|
|
||||||
/// </summary>
|
|
||||||
//Dictionary<int, IRequestModel>? OrderRequests { get; }
|
|
||||||
|
|
||||||
|
|
||||||
//!!!УДАЛИТЬ (после того, как нормально будут многие-ко-многим между заказами и партиями)
|
|
||||||
/// <summary>
|
|
||||||
/// Партии товаров в заказе (может не быть)
|
|
||||||
/// </summary>
|
|
||||||
//Dictionary<int, IShipmentModel>? OrderShipments { get; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата оформления заказа
|
/// Дата оформления заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стоимость товара
|
/// Стоимость товара
|
||||||
/// </summary>
|
/// </summary>
|
||||||
double Cost { get; }
|
double Price { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Гарантия
|
/// Гарантия
|
||||||
|
121
ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs
Normal file
121
ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class AssemblyStorage : IAssemblyStorage
|
||||||
|
{
|
||||||
|
public List<AssemblyViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
return Context.Assemblies
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Assembly)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AssemblyViewModel> GetFilteredList(AssemblySearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
// Optional search by Category name
|
||||||
|
if (!string.IsNullOrEmpty(Model.Category))
|
||||||
|
{
|
||||||
|
return Context.Assemblies
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Assembly)
|
||||||
|
.Where(x => x.UserId == Model.UserId && x.Category == Model.Category)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Context.Assemblies
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Assembly)
|
||||||
|
.Where(x => x.UserId == Model.UserId)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel? GetElement(AssemblySearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
// AssemblyName is unique
|
||||||
|
if (!string.IsNullOrEmpty(Model.AssemblyName))
|
||||||
|
{
|
||||||
|
return Context.Assemblies
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Assembly)
|
||||||
|
.FirstOrDefault(x => x.AssemblyName == Model.AssemblyName)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Context.Assemblies
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Assembly)
|
||||||
|
.FirstOrDefault(x => x.Id == Model.Id)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel? Insert(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var NewAssembly = Assembly.Create(Context, Model);
|
||||||
|
Context.Assemblies.Add(NewAssembly);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return NewAssembly.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel? Update(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
using var Transaction = Context.Database.BeginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ExistingAssembly = Context.Assemblies.FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingAssembly == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExistingAssembly.Update(Model);
|
||||||
|
Context.SaveChanges();
|
||||||
|
ExistingAssembly.UpdateComponents(Context, Model);
|
||||||
|
Transaction.Commit();
|
||||||
|
|
||||||
|
return ExistingAssembly.ViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel? Delete(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var ExistingAssembly = Context.Assemblies.Include(x => x.Components).FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingAssembly == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.Assemblies.Remove(ExistingAssembly);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return ExistingAssembly.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
ComputerShopDatabaseImplement/Implements/ComponentStorage.cs
Normal file
90
ComputerShopDatabaseImplement/Implements/ComponentStorage.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ComponentStorage : IComponentStorage
|
||||||
|
{
|
||||||
|
public List<ComponentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
return Context.Components
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
return Context.Components
|
||||||
|
.Where(x => x.UserId == Model.UserId)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? GetElement(ComponentSearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
// ComponentName is unique
|
||||||
|
if (!string.IsNullOrEmpty(Model.ComponentName))
|
||||||
|
{
|
||||||
|
return Context.Components
|
||||||
|
.FirstOrDefault(x => x.ComponentName == Model.ComponentName)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Context.Components
|
||||||
|
.FirstOrDefault(x => x.Id == Model.Id)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Insert(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var NewComponent = Component.Create(Model);
|
||||||
|
Context.Components.Add(NewComponent);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return NewComponent.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Update(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var ExistingComponent = Context.Components.FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExistingComponent.Update(Model);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return ExistingComponent.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Delete(ComponentBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var ExistingComponent = Context.Components.FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.Components.Remove(ExistingComponent);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return ExistingComponent.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,12 +13,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Implements
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
//!!!ПОДОБИЕ component
|
|
||||||
public class OrderStorage : IOrderStorage
|
public class OrderStorage : IOrderStorage
|
||||||
{
|
{
|
||||||
//!!!ТУТ СВЯЗЬ С НЕСКОЛЬКИМИ СУЩНОСТЯМИ
|
|
||||||
//!!!НЕ ФАКТ, ЧТО ПРАВИЛЬНО
|
|
||||||
//!!!мб присоединять user
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
@ -32,7 +28,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -75,7 +70,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
//Поиск только по id, потому что другие поля не уникальные - нет смысла искать 1 элемент
|
//Поиск только по id, потому что другие поля не уникальные - нет смысла искать 1 элемент
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -118,7 +112,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
return order.GetViewModel;
|
return order.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ ТУТ ДЕЛАТЬ .Include(x => x.Shipments) и .Include(x => x.Requests)
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
126
ComputerShopDatabaseImplement/Implements/ProductStorage.cs
Normal file
126
ComputerShopDatabaseImplement/Implements/ProductStorage.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ProductStorage : IProductStorage
|
||||||
|
{
|
||||||
|
public List<ProductViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
return Context.Products
|
||||||
|
.Include(x => x.Shipment)
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel> GetFilteredList(ProductSearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
// Optional search by Shipment
|
||||||
|
if (Model.ShipmentId.HasValue)
|
||||||
|
{
|
||||||
|
return Context.Products
|
||||||
|
.Include(x => x.Shipment)
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.Where(x => x.UserId == Model.UserId && x.ShipmentId == Model.ShipmentId)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Context.Products
|
||||||
|
.Include(x => x.Shipment)
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.Where(x => x.UserId == Model.UserId)
|
||||||
|
.Select(x => x.ViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? GetElement(ProductSearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
// ProductName is unique
|
||||||
|
if (!string.IsNullOrEmpty(Model.ProductName))
|
||||||
|
{
|
||||||
|
return Context.Products
|
||||||
|
.Include(x => x.Shipment)
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.FirstOrDefault(x => x.ProductName == Model.ProductName)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Context.Products
|
||||||
|
.Include(x => x.Shipment)
|
||||||
|
.Include(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.FirstOrDefault(x => x.Id == Model.Id)?
|
||||||
|
.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Insert(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var NewProduct = Product.Create(Context, Model);
|
||||||
|
Context.Products.Add(NewProduct);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return NewProduct.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Update(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
using var Transaction = Context.Database.BeginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ExistingProduct = Context.Products.FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingProduct == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExistingProduct.Update(Model);
|
||||||
|
Context.SaveChanges();
|
||||||
|
ExistingProduct.UpdateComponents(Context, Model);
|
||||||
|
Transaction.Commit();
|
||||||
|
|
||||||
|
return ExistingProduct.ViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Delete(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
var ExistingProduct = Context.Products.Include(x => x.Components).FirstOrDefault(x => x.Id == Model.Id);
|
||||||
|
if (ExistingProduct == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.Products.Remove(ExistingProduct);
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
return ExistingProduct.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,10 +12,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Implements
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
//!!!ПОДОБИЕ textile
|
|
||||||
public class RequestStorage : IRequestStorage
|
public class RequestStorage : IRequestStorage
|
||||||
{
|
{
|
||||||
//!!!Проверить, что правильно присоединяю сборку Assembly
|
|
||||||
public List<RequestViewModel> GetFullList()
|
public List<RequestViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
@ -28,7 +26,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!Проверить, что правильно присоединяю сборку Assembly
|
|
||||||
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
||||||
public List<RequestViewModel> GetFilteredList(RequestSearchModel model) {
|
public List<RequestViewModel> GetFilteredList(RequestSearchModel model) {
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
@ -79,8 +76,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!Проверить, что правильно присоединяю сборку Assembly
|
|
||||||
//!!!мб тут надо будет в FirstOrDefault добавить другие параметры
|
|
||||||
//Поиск только по id, потому что другие поля не уникальные - нет смысла искать 1 элемент
|
//Поиск только по id, потому что другие поля не уникальные - нет смысла искать 1 элемент
|
||||||
public RequestViewModel? GetElement(RequestSearchModel model)
|
public RequestViewModel? GetElement(RequestSearchModel model)
|
||||||
{
|
{
|
||||||
@ -149,17 +144,16 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
public bool ConnectRequestAssembly(RequestBindingModel model)
|
||||||
public bool ConnectRequestAssembly(int requestId, int assemblyId)
|
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
var request = context.Requests.FirstOrDefault(x => x.Id == requestId);
|
var request = context.Requests.FirstOrDefault(x => x.Id == model.Id);
|
||||||
var assembly = context.Assemblies.FirstOrDefault(x => x.Id == assemblyId);
|
var assembly = context.Assemblies.FirstOrDefault(x => x.Id == model.AssemblyId);
|
||||||
if (request == null || assembly == null)
|
if (request == null || assembly == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
request.ConnectAssembly(context, assemblyId);
|
request.ConnectAssembly(context, model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Implements
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
//!!!ПОДОБИЕ textile
|
|
||||||
public class ShipmentStorage : IShipmentStorage
|
public class ShipmentStorage : IShipmentStorage
|
||||||
{
|
{
|
||||||
public List<ShipmentViewModel> GetFullList()
|
public List<ShipmentViewModel> GetFullList()
|
||||||
@ -27,7 +26,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Учитывается id пользователя, создавшего заказ
|
//Учитывается id пользователя, создавшего заказ (везде получение списка только тех записей, что создал сам пользователь)
|
||||||
public List<ShipmentViewModel> GetFilteredList(ShipmentSearchModel model)
|
public List<ShipmentViewModel> GetFilteredList(ShipmentSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
@ -118,8 +117,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!мб по-другому присваивать значение shipment
|
|
||||||
//!!!мб возвращать не просто shipment.getviewmodel
|
|
||||||
public ShipmentViewModel? Delete(ShipmentBindingModel model)
|
public ShipmentViewModel? Delete(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Implements
|
namespace ComputerShopDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
//!!!МБ У USER ХРАНИТЬ СПИСКИ ВСЕХ СОЗДАННЫХ СУШНОСТЕЙ И ТОГДА ПРИ СОЗДАНИИ, УДАЛЕНИИ СУЩНОСТЕЙ ЕЩЁ СОЗДАВАТЬ И УДАЛЯТЬ ИЗ СПИСКА У ПОЛЬЗОВАТЕЛЯ
|
|
||||||
public class UserStorage : IUserStorage
|
public class UserStorage : IUserStorage
|
||||||
{
|
{
|
||||||
public List<UserViewModel> GetFullList()
|
public List<UserViewModel> GetFullList()
|
||||||
@ -32,33 +31,34 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
return context.Users.Where(x => x.Role == model.Role).Select(x => x.GetViewModel).ToList();
|
return context.Users.Where(x => x.Role == model.Role).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
//id, почта и логин уникальны, можно получать по ним (и получаем при проверке уникальности)
|
||||||
//id, почта и логин уникальны, можно получать по ним
|
|
||||||
public UserViewModel? GetElement(UserSearchModel model)
|
public UserViewModel? GetElement(UserSearchModel model)
|
||||||
{
|
{
|
||||||
//!!!МБ ЭТУ ПРОВЕРКУ УБРАТЬ
|
|
||||||
if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
|
||||||
//Поиск пользователя при входе в систему по логину, паролю и его роли (чтобы не могли войти в аккаунты другой роли)
|
//Получение пользователя при входе в систему по логину, паролю и его роли (чтобы не могли войти в аккаунты другой роли)
|
||||||
if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && model.Role.HasValue)
|
if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && model.Role.HasValue)
|
||||||
{
|
{
|
||||||
return context.Users.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password && x.Role == model.Role)?.GetViewModel;
|
return context.Users.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password && x.Role == model.Role)?.GetViewModel;
|
||||||
}
|
}
|
||||||
//!!!НИЖЕ МБ НЕ НАДО
|
|
||||||
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
||||||
if (!string.IsNullOrEmpty(model.Login))
|
if (!string.IsNullOrEmpty(model.Login))
|
||||||
{
|
{
|
||||||
return context.Users.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
return context.Users.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Получение по почте (пользователей с такой почтой будет 1 или 0)
|
//Получение по почте (пользователей с такой почтой будет 1 или 0)
|
||||||
else if (!string.IsNullOrEmpty(model.Email))
|
else if (!string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
return context.Users.FirstOrDefault(x => x.Email == model.Email)?.GetViewModel;
|
return context.Users.FirstOrDefault(x => x.Email == model.Email)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Получение по id
|
//Получение по id
|
||||||
return context.Users.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
return context.Users.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,6 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
return user.GetViewModel;
|
return user.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ И НЕ НУЖЕН
|
|
||||||
public UserViewModel? Delete(UserBindingModel model)
|
public UserViewModel? Delete(UserBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
522
ComputerShopDatabaseImplement/Migrations/20240430192040_Доп миграция (Гоша).Designer.cs
generated
Normal file
522
ComputerShopDatabaseImplement/Migrations/20240430192040_Доп миграция (Гоша).Designer.cs
generated
Normal file
@ -0,0 +1,522 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using ComputerShopDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ComputerShopDatabase))]
|
||||||
|
[Migration("20240430192040_Доп миграция (Гоша)")]
|
||||||
|
partial class ДопмиграцияГоша
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("AssemblyName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Category")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Assemblies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("AssemblyId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AssemblyId");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.ToTable("AssemblyComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("ShipmentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Warranty")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShipmentId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int?>("AssemblyId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateRequest")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AssemblyId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Requests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("OrderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("RequestId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("RequestId");
|
||||||
|
|
||||||
|
b.ToTable("RequestOrders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateShipment")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Shipments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("OrderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ShipmentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("ShipmentId");
|
||||||
|
|
||||||
|
b.ToTable("ShipmentOrders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Login")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Role")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Assemblies")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("AssemblyId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("AssemblyComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Assembly");
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", "Shipment")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("ShipmentId");
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Proucts")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Shipment");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("ProductComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("AssemblyId");
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Assembly");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Request", "Request")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("RequestId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("Request");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Shipments")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||||
|
.WithMany("Shipments")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", "Shipment")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ShipmentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("Shipment");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Requests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("AssemblyComponents");
|
||||||
|
|
||||||
|
b.Navigation("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Requests");
|
||||||
|
|
||||||
|
b.Navigation("Shipments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Assemblies");
|
||||||
|
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
|
||||||
|
b.Navigation("Proucts");
|
||||||
|
|
||||||
|
b.Navigation("Requests");
|
||||||
|
|
||||||
|
b.Navigation("Shipments");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ДопмиграцияГоша : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
522
ComputerShopDatabaseImplement/Migrations/20240501095656_Переименовал Price (Олег).Designer.cs
generated
Normal file
522
ComputerShopDatabaseImplement/Migrations/20240501095656_Переименовал Price (Олег).Designer.cs
generated
Normal file
@ -0,0 +1,522 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using ComputerShopDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ComputerShopDatabase))]
|
||||||
|
[Migration("20240501095656_Переименовал Price (Олег)")]
|
||||||
|
partial class ПереименовалPriceОлег
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("AssemblyName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Category")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Assemblies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("AssemblyId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AssemblyId");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.ToTable("AssemblyComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("ShipmentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Warranty")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShipmentId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int?>("AssemblyId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateRequest")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AssemblyId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Requests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("OrderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("RequestId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("RequestId");
|
||||||
|
|
||||||
|
b.ToTable("RequestOrders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateShipment")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Shipments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("OrderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ShipmentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("ShipmentId");
|
||||||
|
|
||||||
|
b.ToTable("ShipmentOrders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Login")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Role")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Assemblies")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("AssemblyId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("AssemblyComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Assembly");
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", "Shipment")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("ShipmentId");
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Proucts")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Shipment");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("ProductComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("AssemblyId");
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Assembly");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||||
|
.WithMany("Requests")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Request", "Request")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("RequestId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("Request");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
|
.WithMany("Shipments")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||||
|
.WithMany("Shipments")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", "Shipment")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ShipmentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("Shipment");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Requests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("AssemblyComponents");
|
||||||
|
|
||||||
|
b.Navigation("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Requests");
|
||||||
|
|
||||||
|
b.Navigation("Shipments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Assemblies");
|
||||||
|
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
|
||||||
|
b.Navigation("Proucts");
|
||||||
|
|
||||||
|
b.Navigation("Requests");
|
||||||
|
|
||||||
|
b.Navigation("Shipments");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ComputerShopDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ПереименовалPriceОлег : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Cost",
|
||||||
|
table: "Products",
|
||||||
|
newName: "Price");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Cost",
|
||||||
|
table: "Assemblies",
|
||||||
|
newName: "Price");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Price",
|
||||||
|
table: "Products",
|
||||||
|
newName: "Cost");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Price",
|
||||||
|
table: "Assemblies",
|
||||||
|
newName: "Cost");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
b.Property<double>("Price")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
@ -137,7 +137,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
b.Property<double>("Price")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.Property<string>("ProductName")
|
b.Property<string>("ProductName")
|
||||||
@ -435,13 +435,11 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
|
b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
|
||||||
.WithMany("Shipments")
|
.WithMany("Shipments")
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ComputerShopContracts.BindingModels;
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
using ComputerShopDataModels.Models;
|
using ComputerShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
@ -16,7 +17,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
public string AssemblyName { get; private set; } = string.Empty;
|
public string AssemblyName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Category { get; private set; } = string.Empty;
|
public string Category { get; private set; } = string.Empty;
|
||||||
@ -53,7 +54,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
Id = Model.Id,
|
Id = Model.Id,
|
||||||
UserId = Model.UserId,
|
UserId = Model.UserId,
|
||||||
AssemblyName = Model.AssemblyName,
|
AssemblyName = Model.AssemblyName,
|
||||||
Cost = Model.Cost,
|
Price = Model.Price,
|
||||||
Category = Model.Category,
|
Category = Model.Category,
|
||||||
Components = Model.AssemblyComponents.Select(x => new AssemblyComponent
|
Components = Model.AssemblyComponents.Select(x => new AssemblyComponent
|
||||||
{
|
{
|
||||||
@ -63,6 +64,64 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Update(), ViewModel, UpdateComponents()
|
public void Update(AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Model.AssemblyName))
|
||||||
|
{
|
||||||
|
AssemblyName = Model.AssemblyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Model.Category))
|
||||||
|
{
|
||||||
|
Category = Model.Category;
|
||||||
|
}
|
||||||
|
|
||||||
|
Price = Model.Price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyViewModel ViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
UserId = UserId,
|
||||||
|
AssemblyName = AssemblyName,
|
||||||
|
Price = Price,
|
||||||
|
Category = Category,
|
||||||
|
AssemblyComponents = AssemblyComponents,
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateComponents(ComputerShopDatabase Context, AssemblyBindingModel Model)
|
||||||
|
{
|
||||||
|
var AssemblyComponents = Context.AssemblyComponents.Where(x => x.AssemblyId == Model.Id).ToList();
|
||||||
|
if (AssemblyComponents != null && AssemblyComponents.Count > 0)
|
||||||
|
{
|
||||||
|
Context.AssemblyComponents
|
||||||
|
.RemoveRange(AssemblyComponents
|
||||||
|
.Where(x => !Model.AssemblyComponents.ContainsKey(x.ComponentId)));
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
foreach (var ComponentToUpdate in AssemblyComponents)
|
||||||
|
{
|
||||||
|
ComponentToUpdate.Count = Model.AssemblyComponents[ComponentToUpdate.ComponentId].Item2;
|
||||||
|
Model.AssemblyComponents.Remove(ComponentToUpdate.ComponentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
var CurrentAssembly = Context.Assemblies.First(x => x.Id == Id);
|
||||||
|
foreach (var AssemblyComponent in Model.AssemblyComponents)
|
||||||
|
{
|
||||||
|
Context.AssemblyComponents.Add(new AssemblyComponent
|
||||||
|
{
|
||||||
|
Assembly = CurrentAssembly,
|
||||||
|
Component = Context.Components.First(x => x.Id == AssemblyComponent.Key),
|
||||||
|
Count = AssemblyComponent.Value.Item2
|
||||||
|
});
|
||||||
|
|
||||||
|
Context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
_assemblyComponents = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
using ComputerShopDataModels.Enums;
|
using ComputerShopDataModels.Enums;
|
||||||
using ComputerShopDataModels.Models;
|
using ComputerShopDataModels.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@ -14,7 +15,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; private set; }
|
public int UserId { get; private set; }
|
||||||
@ -41,13 +42,14 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//при создании заказа с ним ничего ещё не связано => сумма = 0
|
||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
UserId = model.UserId,
|
UserId = model.UserId,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
Sum = model.Sum,
|
Sum = 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +63,12 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//отдельный метод изменения стоимости заказа (+ или -) на стоимость сборки внутри заявки (после действий с заявками, кот. привязаны к заказу)
|
||||||
|
public void ChangeSum(double cost_of_assembly, bool justUpdate = false)
|
||||||
|
{
|
||||||
|
Sum += cost_of_assembly;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ComputerShopContracts.BindingModels;
|
using ComputerShopContracts.BindingModels;
|
||||||
|
using ComputerShopContracts.ViewModels;
|
||||||
using ComputerShopDataModels.Models;
|
using ComputerShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
@ -12,19 +13,19 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int? ShipmentId { get; set; }
|
||||||
|
|
||||||
|
public virtual Shipment? Shipment { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Warranty { get; set; }
|
public int Warranty { get; set; }
|
||||||
|
|
||||||
public int? ShipmentId { get; set; }
|
|
||||||
|
|
||||||
public virtual Shipment? Shipment { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("ProductId")]
|
[ForeignKey("ProductId")]
|
||||||
public virtual List<ProductComponent> Components { get; set; } = new();
|
public virtual List<ProductComponent> Components { get; set; } = new();
|
||||||
|
|
||||||
@ -53,16 +54,74 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Model.Id,
|
Id = Model.Id,
|
||||||
UserId = Model.UserId,
|
UserId = Model.UserId,
|
||||||
|
ShipmentId = Model.ShipmentId,
|
||||||
ProductName = Model.ProductName,
|
ProductName = Model.ProductName,
|
||||||
Cost = Model.Cost,
|
Price = Model.Price,
|
||||||
Warranty = Model.Warranty,
|
Warranty = Model.Warranty,
|
||||||
Components = Model.ProductComponents.Select(x => new ProductComponent
|
Components = Model.ProductComponents.Select(x => new ProductComponent
|
||||||
{
|
{
|
||||||
Component = Context.Components.First(y => y.Id == x.Key),
|
Component = Context.Components.First(y => y.Id == x.Key),
|
||||||
Count = x.Value.Item2
|
Count = x.Value.Item2
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
ShipmentId = Model.ShipmentId,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Model.ProductName))
|
||||||
|
{
|
||||||
|
ProductName = Model.ProductName;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShipmentId = Model.ShipmentId;
|
||||||
|
Price = Model.Price;
|
||||||
|
Warranty = Model.Warranty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel ViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
UserId = UserId,
|
||||||
|
ShipmentId = ShipmentId,
|
||||||
|
ProviderName = Shipment?.ProviderName,
|
||||||
|
Price = Price,
|
||||||
|
Warranty = Warranty,
|
||||||
|
ProductComponents = ProductComponents,
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateComponents(ComputerShopDatabase Context, ProductBindingModel Model)
|
||||||
|
{
|
||||||
|
var ProductComponents = Context.ProductComponents.Where(x => x.ProductId == Model.Id).ToList();
|
||||||
|
if (ProductComponents != null && ProductComponents.Count > 0)
|
||||||
|
{
|
||||||
|
Context.ProductComponents
|
||||||
|
.RemoveRange(ProductComponents
|
||||||
|
.Where(x => !Model.ProductComponents.ContainsKey(x.ComponentId)));
|
||||||
|
Context.SaveChanges();
|
||||||
|
|
||||||
|
foreach (var ComponentToUpdate in ProductComponents)
|
||||||
|
{
|
||||||
|
ComponentToUpdate.Count = Model.ProductComponents[ComponentToUpdate.ComponentId].Item2;
|
||||||
|
Model.ProductComponents.Remove(ComponentToUpdate.ComponentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
var CurrentProduct = Context.Products.First(x => x.Id == Id);
|
||||||
|
foreach (var ProductComponent in Model.ProductComponents)
|
||||||
|
{
|
||||||
|
Context.ProductComponents.Add(new ProductComponent
|
||||||
|
{
|
||||||
|
Product = CurrentProduct,
|
||||||
|
Component = Context.Components.First(x => x.Id == ProductComponent.Key),
|
||||||
|
Count = ProductComponent.Value.Item2
|
||||||
|
});
|
||||||
|
|
||||||
|
Context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
_productComponents = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Models
|
namespace ComputerShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
//!!!МБ У Id сделать private set у ВСЕХ МОИХ МОДЕЛЕЙ
|
|
||||||
public class Request : IRequestModel
|
public class Request : IRequestModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; private set; }
|
||||||
|
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
@ -77,6 +76,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
ClientFIO = model.ClientFIO;
|
ClientFIO = model.ClientFIO;
|
||||||
}
|
}
|
||||||
//DateMake не обновляю, потому что странно менять дату оформления заявки после её создания
|
//DateMake не обновляю, потому что странно менять дату оформления заявки после её создания
|
||||||
|
//Обновление ссылки на сборку (assemblyId) отдельным методом
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestViewModel GetViewModel => new()
|
public RequestViewModel GetViewModel => new()
|
||||||
@ -90,36 +90,64 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
RequestOrders = RequestOrders
|
RequestOrders = RequestOrders
|
||||||
};
|
};
|
||||||
|
|
||||||
//!!!МБ ПЕРЕДАВАТЬ ЧТО-ТО ДРУГОЕ
|
//обновление списка заказов у заявки (+ изменение суммы у соответствующих заказов)
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО ВСЁ ПРАВИЛЬНО ИЗВЛЕКАЮ
|
|
||||||
public void UpdateOrders(ComputerShopDatabase context, RequestBindingModel model)
|
public void UpdateOrders(ComputerShopDatabase context, RequestBindingModel model)
|
||||||
{
|
{
|
||||||
|
var currentRequest = context.Requests.First(x => x.Id == Id);
|
||||||
|
//стоимость сборки, связанной с заявкой (или 0, если заявка не связана со сборкой)
|
||||||
|
double cost_of_assembly = (currentRequest.Assembly.Price != null) ? currentRequest.Assembly.Price : 0;
|
||||||
|
|
||||||
var requestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList();
|
var requestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList();
|
||||||
//удаление тех заказов, которых нет в модели
|
|
||||||
|
//удаление тех заказов, которых нет в модели (+ изменение суммы у удаляемых заказов)
|
||||||
if (requestOrders != null && requestOrders.Count > 0)
|
if (requestOrders != null && requestOrders.Count > 0)
|
||||||
{
|
{
|
||||||
context.RequestOrders.RemoveRange(requestOrders.Where(x => !model.RequestOrders.ContainsKey(x.OrderId)));
|
var delOrders = requestOrders.Where(x => !model.RequestOrders.ContainsKey(x.OrderId));
|
||||||
context.SaveChanges();
|
foreach (var delOrder in delOrders)
|
||||||
|
{
|
||||||
|
context.RequestOrders.Remove(delOrder);
|
||||||
|
var order = context.Orders.First(x => x.Id == delOrder.OrderId);
|
||||||
|
//вычитание из стоимости соответствующего заказа стоимость соответствующей сборки
|
||||||
|
order.ChangeSum(-cost_of_assembly);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//добавление новых заказов
|
|
||||||
var currentRequest = context.Requests.First(x => x.Id == Id);
|
//добавление новых заказов (+ изменение суммы у добавляемых заказов)
|
||||||
foreach (var request_order in model.RequestOrders)
|
foreach (var request_order in model.RequestOrders)
|
||||||
{
|
{
|
||||||
|
var order = context.Orders.First(x => x.Id == request_order.Key);
|
||||||
context.RequestOrders.Add(new RequestOrder
|
context.RequestOrders.Add(new RequestOrder
|
||||||
{
|
{
|
||||||
Request = currentRequest,
|
Request = currentRequest,
|
||||||
Order = context.Orders.First(x => x.Id == request_order.Key)
|
Order = order
|
||||||
});
|
});
|
||||||
|
//увеличение стоимости заказа, с которым связываем заявку, на стоимость сборки
|
||||||
|
order.ChangeSum(cost_of_assembly);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
_requestOrders = null;
|
_requestOrders = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Связывание заявки со сборкой
|
|
||||||
public void ConnectAssembly(ComputerShopDatabase context, int assemblyId)
|
//Связывание заявки со сборкой (+ изменение суммы у соответствующих заказов)
|
||||||
|
public void ConnectAssembly(ComputerShopDatabase context, RequestBindingModel model)
|
||||||
{
|
{
|
||||||
AssemblyId = assemblyId;
|
//стоимость старой сборки (или 0, если её не было)
|
||||||
Assembly = context.Assemblies.First(x => x.Id == assemblyId);
|
double cost_of_old_assembly = (Assembly.Price != null) ? Assembly.Price : 0;
|
||||||
|
|
||||||
|
AssemblyId = model.AssemblyId;
|
||||||
|
Assembly = context.Assemblies.First(x => x.Id == model.AssemblyId);
|
||||||
|
//изменение стоимости всех связанных заказов
|
||||||
|
foreach (var request_order in model.RequestOrders)
|
||||||
|
{
|
||||||
|
var connectedOrder = context.Orders.First(x => x.Id == request_order.Key);
|
||||||
|
//вычитание из стоимости заказа старой сборки
|
||||||
|
connectedOrder.ChangeSum(-cost_of_old_assembly);
|
||||||
|
//прибавление стоимости новой сборки
|
||||||
|
connectedOrder.ChangeSum(Assembly.Price);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,23 +13,17 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public class Shipment : IShipmentModel
|
public class Shipment : IShipmentModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; private set; }
|
public int UserId { get; private set; }
|
||||||
|
|
||||||
//!!!мб не нужен (для передачи логина пользователя)
|
|
||||||
public virtual User User { get; set; }
|
|
||||||
|
|
||||||
//!!!МБ ТУТ НЕ НУЖЕН string.Empty
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ProviderName { get; set; } = string.Empty;
|
public string ProviderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
//!!!МБ ТУТ НЕ НУЖЕН DateTime.Now
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateShipment { get; set; } = DateTime.Now;
|
public DateTime DateShipment { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
//!!!МБ ТУТ КАК-ТО ПО-ДРУГОМУ
|
|
||||||
private Dictionary<int, IOrderModel>? _shipmentOrders = null;
|
private Dictionary<int, IOrderModel>? _shipmentOrders = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
@ -44,7 +38,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
return _shipmentOrders;
|
return _shipmentOrders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО ТУТ ПРАВИЛЬНО СДЕЛАНО (ЧТО НАЗВАНИЕ ПРАВИЛЬНОЕ У ВНЕШ. КЛЮЧА, ЧТО ПРАВИЛЬНЫЙ ТИП в <>)
|
|
||||||
[ForeignKey("ShipmentId")]
|
[ForeignKey("ShipmentId")]
|
||||||
public virtual List<ShipmentOrder> Orders { get; set; } = new();
|
public virtual List<ShipmentOrder> Orders { get; set; } = new();
|
||||||
|
|
||||||
@ -52,14 +46,12 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
public virtual List<Product> Products { get; set; } = new();
|
public virtual List<Product> Products { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО ПРАВИЛЬНО ПРИСВАИВАЮ ЗНАЧЕНИЕ СПИСКУ ЗАКАЗОВ
|
|
||||||
public static Shipment Create(ComputerShopDatabase context, ShipmentBindingModel model)
|
public static Shipment Create(ComputerShopDatabase context, ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
return new Shipment()
|
return new Shipment()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
UserId = model.UserId,
|
UserId = model.UserId,
|
||||||
User = context.Users.First(x => x.Id == model.UserId),
|
|
||||||
ProviderName = model.ProviderName,
|
ProviderName = model.ProviderName,
|
||||||
DateShipment = model.DateShipment,
|
DateShipment = model.DateShipment,
|
||||||
Orders = model.ShipmentOrders.Select(x => new ShipmentOrder
|
Orders = model.ShipmentOrders.Select(x => new ShipmentOrder
|
||||||
@ -68,7 +60,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//!!!МБ ТУТ КАКИЕ-ТО ДРУГИЕ ПОЛЯ НАДО БУДЕТ ОБНОВЛЯТЬ
|
|
||||||
public void Update(ShipmentBindingModel model)
|
public void Update(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -81,7 +73,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
DateShipment = model.DateShipment;
|
DateShipment = model.DateShipment;
|
||||||
}
|
}
|
||||||
//!!!МБ ТУТ ЕЩЁ ЧТО-ТО ПРИСВАИВАТЬ
|
|
||||||
public ShipmentViewModel GetViewModel => new()
|
public ShipmentViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
@ -91,8 +83,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
ShipmentOrders = ShipmentOrders
|
ShipmentOrders = ShipmentOrders
|
||||||
};
|
};
|
||||||
|
|
||||||
//!!!МБ ПЕРЕДАВАТЬ ЧТО-ТО ДРУГОЕ
|
|
||||||
//!!!ПРОВЕРИТЬ, ЧТО ВСЁ ПРАВИЛЬНО ИЗВЛЕКАЮ
|
|
||||||
public void UpdateOrders(ComputerShopDatabase context, ShipmentBindingModel model)
|
public void UpdateOrders(ComputerShopDatabase context, ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
var shipmentOrders = context.ShipmentOrders.Where(x => x.ShipmentId == model.Id).ToList();
|
var shipmentOrders = context.ShipmentOrders.Where(x => x.ShipmentId == model.Id).ToList();
|
||||||
|
@ -67,7 +67,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
Email = model.Email;
|
Email = model.Email;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ ТУТ НЕ НАДО РОЛЬ
|
|
||||||
public UserViewModel GetViewModel => new()
|
public UserViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
|
@ -5,7 +5,6 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ComputerShopImplementerApp
|
namespace ComputerShopImplementerApp
|
||||||
{
|
{
|
||||||
//!!!мб тут оставить всё, как client (заново перекопировать файл)
|
|
||||||
public class APIUser
|
public class APIUser
|
||||||
{
|
{
|
||||||
private static readonly HttpClient _user = new();
|
private static readonly HttpClient _user = new();
|
||||||
@ -46,8 +45,5 @@ namespace ComputerShopImplementerApp
|
|||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ ДОБАВИТЬ DeleteRequest
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,41 +108,5 @@ namespace ComputerShopImplementerApp.Controllers
|
|||||||
Response.Redirect("Enter");
|
Response.Redirect("Enter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!Сделать что-то похожее
|
|
||||||
//[HttpGet]
|
|
||||||
//public IActionResult Create()
|
|
||||||
//{
|
|
||||||
// ViewBag.Textiles = APIUser.GetRequest<List<TextileViewModel>>("api/main/gettextilelist");
|
|
||||||
// return View();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//[HttpPost]
|
|
||||||
//public void Create(int Textile, int count)
|
|
||||||
//{
|
|
||||||
// if (APIUser.User == null)
|
|
||||||
// {
|
|
||||||
// throw new Exception("Вход только авторизованным");
|
|
||||||
// }
|
|
||||||
// if (count <= 0)
|
|
||||||
// {
|
|
||||||
// throw new Exception("Количество и сумма должны быть больше 0");
|
|
||||||
// }
|
|
||||||
// APIUser.PostRequest("api/main/createorder", new OrderBindingModel
|
|
||||||
// {
|
|
||||||
// UserId = APIUser.User.Id,
|
|
||||||
// TextileId = Textile,
|
|
||||||
// Count = count,
|
|
||||||
// Sum = Calc(count, Textile)
|
|
||||||
// });
|
|
||||||
// Response.Redirect("Index");
|
|
||||||
//}
|
|
||||||
|
|
||||||
//[HttpPost]
|
|
||||||
//public double Calc(int count, int textile)
|
|
||||||
//{
|
|
||||||
// var _textile = APIUser.GetRequest<TextileViewModel>($"api/main/gettextile?textileId={textile}");
|
|
||||||
// return count * (_textile?.Price ?? 1);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -83,7 +83,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//!!!мб HttpPut
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public void DeleteOrder(OrderBindingModel model)
|
public void DeleteOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -72,13 +72,13 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!ПРОВЕРИТЬ
|
//параметры для удобного использования в swagger, потом скорее всего будет передаваться RequestBindingModel model
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void ConnectRequestAssembly(int requestId, int assemblyId)
|
public void ConnectRequestAssembly(int requestId, int assemblyId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logic.ConnectRequestAssembly(requestId, assemblyId);
|
_logic.ConnectRequestAssembly(new RequestBindingModel { Id = requestId, AssemblyId = assemblyId });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -102,22 +102,6 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ УДАЛИТЬ
|
|
||||||
//[HttpPost]
|
|
||||||
//public void AddRequestOrder(int requestId, int orderId)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// _logic.Update(model);
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// _logger.LogError(ex, "Ошибка обновления заказа");
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public void DeleteRequest(RequestBindingModel model)
|
public void DeleteRequest(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
@ -131,8 +115,5 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!МБ НУЖЕН ОТДЕЛЬНЫЙ МЕТОД ДЛЯ СВЯЗЫВАНИЯ ЗАЯВКИ СО СБОРКОЙ.
|
|
||||||
//!!!тогда его надо будет добавлять в IRequestLogic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!мб не тут надо присваивать роль
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void RegisterImplementer(UserBindingModel model)
|
public void RegisterImplementer(UserBindingModel model)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user