Compare commits
37 Commits
main
...
Coursework
Author | SHA1 | Date | |
---|---|---|---|
391a54d200 | |||
8682259cfb | |||
5d42a15fef | |||
f7c05cc17d | |||
f64c7b284c | |||
8a4b8a5f79 | |||
b37e13575b | |||
2f7dac91e4 | |||
7bc1dc6adf | |||
c9c4bd00aa | |||
769979a406 | |||
7cbd0a5e50 | |||
262e730c94 | |||
fbf7292ee2 | |||
c2baea1737 | |||
9347ef10b4 | |||
d878842ac1 | |||
81454cabe4 | |||
ee3f2ff447 | |||
74de95f90b | |||
ff3957a457 | |||
a31e821be3 | |||
81673b0767 | |||
e65286870e | |||
377a803ac1 | |||
ef018c1331 | |||
42790d8e3b | |||
e0a3c1e1fd | |||
7d2196d4e8 | |||
e7ec00c14e | |||
67e03f94a1 | |||
bc4efdc01a | |||
81eba38ae9 | |||
c3f77f6bad | |||
9b8c383e22 | |||
7cff6fd966 | |||
5e275843c9 |
@ -6,4 +6,15 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerStoreDatabaseImplement\ComputerStoreDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -5,6 +5,14 @@ VisualStudioVersion = 17.5.33516.290
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStore", "ComputerStore.csproj", "{695B79EB-71FD-456D-BFEA-634500FF2ECB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreBusinessLogic", "..\ComputerStoreBusinessLogic\ComputerStoreBusinessLogic.csproj", "{17F8960F-03CB-49D7-B335-931E6BE5F9FF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreContracts", "..\ComputerStoreContracts\ComputerStoreContracts.csproj", "{1C8DB816-F530-4CC3-9F36-F6191FE49C10}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreDataModels", "..\ComputerStoreDataModels\ComputerStoreDataModels.csproj", "{93679794-7F9A-43C4-A7C3-A1AE77FAB964}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreDatabaseImplement", "..\ComputerStoreDatabaseImplement\ComputerStoreDatabaseImplement.csproj", "{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +23,22 @@ Global
|
||||
{695B79EB-71FD-456D-BFEA-634500FF2ECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{695B79EB-71FD-456D-BFEA-634500FF2ECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{695B79EB-71FD-456D-BFEA-634500FF2ECB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{17F8960F-03CB-49D7-B335-931E6BE5F9FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{17F8960F-03CB-49D7-B335-931E6BE5F9FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{17F8960F-03CB-49D7-B335-931E6BE5F9FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17F8960F-03CB-49D7-B335-931E6BE5F9FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1C8DB816-F530-4CC3-9F36-F6191FE49C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1C8DB816-F530-4CC3-9F36-F6191FE49C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1C8DB816-F530-4CC3-9F36-F6191FE49C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1C8DB816-F530-4CC3-9F36-F6191FE49C10}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{93679794-7F9A-43C4-A7C3-A1AE77FAB964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{93679794-7F9A-43C4-A7C3-A1AE77FAB964}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{93679794-7F9A-43C4-A7C3-A1AE77FAB964}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{93679794-7F9A-43C4-A7C3-A1AE77FAB964}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
116
ComputerStoreBusinessLogic/BusinessLogic/ComponentLogic.cs
Normal file
116
ComputerStoreBusinessLogic/BusinessLogic/ComponentLogic.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ComponentLogic : IComponentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_componentStorage = componentStorage;
|
||||
}
|
||||
|
||||
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) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.ID:{ ID}", model.Name, model.ID);
|
||||
|
||||
var element = _componentStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. ID:{ ID}", model?.Name, model?.ID);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
if (!withParams) { return; }
|
||||
if(string.IsNullOrEmpty(model.Name)) { throw new ArgumentNullException("Invalid component's name", nameof(model)); }
|
||||
if(model.Price <= 0) { throw new ArgumentNullException("Invalid component's price", nameof(model)); }
|
||||
|
||||
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. ID: { ID} ", model.Name, model.Price, model.ID);
|
||||
|
||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
|
||||
if (element != null && element.ID != model.ID)
|
||||
{
|
||||
throw new InvalidOperationException("Component with such name already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
Normal file
105
ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ConsignmentLogic : IConsignmentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConsignmentStorage _consignmentStorage;
|
||||
public ConsignmentLogic(ILogger<ConsignmentLogic> logger, IConsignmentStorage consignmentStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_consignmentStorage = consignmentStorage;
|
||||
}
|
||||
|
||||
public bool Create(ConsignmentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_consignmentStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ConsignmentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_consignmentStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConsignmentBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||
if (_consignmentStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConsignmentViewModel? ReadElement(ConsignmentSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Consignment ID:{ ID}", model.ID);
|
||||
|
||||
var element = _consignmentStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Consignment ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ConsignmentViewModel>? ReadList(ConsignmentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Consignment ID:{ ID}", model?.ID);
|
||||
|
||||
var list = model == null ? _consignmentStorage.GetFullList() : _consignmentStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(ConsignmentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
if (!withParams) { return; }
|
||||
if (model.Price <= 0) { throw new ArgumentNullException("Invalid consignment's price", nameof(model)); }
|
||||
if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Consignment's order ID", nameof(model)); }
|
||||
|
||||
_logger.LogInformation("Consignment. Consignment ID:{ ID}. Order ID:{ OrderID}.", model.ID, model.OrderID);
|
||||
}
|
||||
}
|
||||
}
|
122
ComputerStoreBusinessLogic/BusinessLogic/EmployeeLogic.cs
Normal file
122
ComputerStoreBusinessLogic/BusinessLogic/EmployeeLogic.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
public bool Create(EmployeeBindingModel model)
|
||||
{
|
||||
CheckEmployee(model);
|
||||
if (_employeeStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(EmployeeBindingModel model)
|
||||
{
|
||||
CheckEmployee(model);
|
||||
if (_employeeStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(EmployeeBindingModel model)
|
||||
{
|
||||
CheckEmployee(model, false);
|
||||
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||
if (_employeeStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? ReadElement(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Username:{Username}.ID:{ ID}", model.Username, model.ID);
|
||||
var element = _employeeStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Username:{Username}. ID:{ ID}", model?.Username, model?.ID);
|
||||
|
||||
var list = model == null ? _employeeStorage.GetFullList() : _employeeStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public void CheckEmployee(EmployeeBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Username))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid username of user", nameof(model.Username));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid password of user", nameof(model.Password));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Client. Username:{ Username}. ID: { ID} ", model.Username, model.ID);
|
||||
|
||||
var element = _employeeStorage.GetElement(new EmployeeSearchModel
|
||||
{
|
||||
Username = model.Username
|
||||
});
|
||||
|
||||
if (element != null && element.ID != model.ID)
|
||||
{
|
||||
throw new InvalidOperationException("Employee with such username already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
137
ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs
Normal file
137
ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class EmployeeReportLogic : IEmployeeReportLogic
|
||||
{
|
||||
private readonly IPCStorage _pcStorage;
|
||||
private readonly IProductStorage _productStorage;
|
||||
private readonly IConsignmentStorage _consignmentStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public EmployeeReportLogic(IPCStorage pcStorage, IProductStorage productStorage, IConsignmentStorage consignmentStorage, IOrderStorage orderStorage)
|
||||
{
|
||||
_pcStorage = pcStorage;
|
||||
_productStorage = productStorage;
|
||||
_consignmentStorage = consignmentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public List<ReportPCByDateViewModel> GetPCsByDate(ReportDateBindingModel model)
|
||||
{
|
||||
return _pcStorage.GetFilteredList(new PCSearchModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportPCByDateViewModel
|
||||
{
|
||||
PCName = x.Name,
|
||||
Components = x.PCComponents.Values.Select(x => (x.Item1.Name, x.Item2)).ToList(),
|
||||
EmployeeUsername = x.EmployeeUsername
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
|
||||
public List<ReportProductByDateViewModel> GetProductsByDate(ReportDateBindingModel model)
|
||||
{
|
||||
return _productStorage.GetFilteredList(new ProductSearchModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportProductByDateViewModel
|
||||
{
|
||||
ProductName = x.Name,
|
||||
Components = x.ProductComponents.Values.Select(x => (x.Item1.Name, x.Item2)).ToList()
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<ReportConsignmentsViewModel> GetConsignmentsByComponents(ReportComponentsBindingModel model)
|
||||
{
|
||||
var list = new List<ReportConsignmentsViewModel>();
|
||||
|
||||
Dictionary<int, IProductModel> specifiedProducts = new Dictionary<int, IProductModel>();
|
||||
|
||||
foreach(var component in model.Components)
|
||||
{
|
||||
var products = _productStorage.GetFilteredList(new ProductSearchModel
|
||||
{
|
||||
ComponentID = component.ID
|
||||
});
|
||||
|
||||
foreach(var product in products)
|
||||
{
|
||||
if(!specifiedProducts.ContainsKey(product.ID))
|
||||
{
|
||||
specifiedProducts.Add(product.ID, product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, IConsignmentModel> specifiedConsignments = new Dictionary<int, IConsignmentModel>();
|
||||
|
||||
foreach (var product in specifiedProducts)
|
||||
{
|
||||
var consignments = _consignmentStorage.GetFilteredList(new ConsignmentSearchModel
|
||||
{
|
||||
ProductID = product.Key
|
||||
});
|
||||
|
||||
if(!specifiedConsignments.Any())
|
||||
{
|
||||
foreach (var consignment in consignments)
|
||||
{
|
||||
specifiedConsignments.Add(consignment.ID, consignment);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var consignment in specifiedConsignments.Values)
|
||||
{
|
||||
if(!consignments.Contains(consignment))
|
||||
{
|
||||
specifiedConsignments.Remove(consignment.ID);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach(var consignment in specifiedConsignments)
|
||||
{
|
||||
var record = new ReportConsignmentsViewModel
|
||||
{
|
||||
ID = consignment.Key,
|
||||
Products = consignment.Value.ConsignmentProducts.Values.Select(x => (x.Item1.Name,x.Item2)).ToList()
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void SaveProductsToPdfFile(ReportDateBindingModel model)
|
||||
{
|
||||
//will be implemented in the future!
|
||||
}
|
||||
|
||||
public void SavePCsToPdfFile(ReportDateBindingModel model)
|
||||
{
|
||||
//will be implemented in the future!
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
136
ComputerStoreBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
136
ComputerStoreBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Unknown)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = OrderStatus.Accepted;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
model.Status = OrderStatus.Unknown;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool StatusUpdate(OrderBindingModel rawModel, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
ID = rawModel.ID
|
||||
});
|
||||
|
||||
if (viewModel == null)
|
||||
{
|
||||
_logger.LogWarning("Order model not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
OrderBindingModel model = new OrderBindingModel
|
||||
{
|
||||
ID = viewModel.ID,
|
||||
Status = viewModel.Status,
|
||||
DateCreate = viewModel.DateCreate,
|
||||
DateImplement = viewModel.DateImplement,
|
||||
Price = viewModel.Price,
|
||||
SellerID = viewModel.SellerID,
|
||||
OrderConsignments = viewModel.OrderConsignments,
|
||||
OrderRequests = viewModel.OrderRequests
|
||||
};
|
||||
|
||||
CheckModel(model, false);
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Given) model.DateImplement = DateTime.Now;
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInProcess(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.InProcess);
|
||||
}
|
||||
|
||||
public bool TakeOrderReady(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Ready);
|
||||
}
|
||||
|
||||
public bool TakeOrderGiven(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Given);
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("Order. OrderID:{Id}", model?.ID);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Incorrect Price", nameof(model.Price));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.SellerID.ToString()) && model.SellerID < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Incorrect seller ID", nameof(model.SellerID));
|
||||
}
|
||||
_logger.LogInformation("Order. OrderID:{ ID}. SellerID: { SellerID}", model.ID, model.SellerID);
|
||||
}
|
||||
}
|
||||
}
|
117
ComputerStoreBusinessLogic/BusinessLogic/PCLogic.cs
Normal file
117
ComputerStoreBusinessLogic/BusinessLogic/PCLogic.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class PCLogic : IPCLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPCStorage _PCStorage;
|
||||
public PCLogic(ILogger<PCLogic> logger, IPCStorage PCStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_PCStorage = PCStorage;
|
||||
}
|
||||
|
||||
public bool Create(PCBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_PCStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(PCBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_PCStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(PCBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||
if (_PCStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public PCViewModel? ReadElement(PCSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. PCName:{PCName}.ID:{ ID}", model.Name, model.ID);
|
||||
|
||||
var element = _PCStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<PCViewModel>? ReadList(PCSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PCName:{PCName}. ID:{ ID}", model?.Name, model?.ID);
|
||||
|
||||
var list = model == null ? _PCStorage.GetFullList() : _PCStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(PCBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
if (!withParams) { return; }
|
||||
if (string.IsNullOrEmpty(model.Name)) { throw new ArgumentNullException("Invalid PC's name", nameof(model)); }
|
||||
if (model.Price <= 0) { throw new ArgumentNullException("Invalid PC's price", nameof(model)); }
|
||||
if (string.IsNullOrEmpty(model.EmployeeID.ToString())) { throw new ArgumentNullException("Invalid PC's employee ID", nameof(model)); }
|
||||
if (string.IsNullOrEmpty(model.RequestID.ToString())) { throw new ArgumentNullException("Invalid PC's request ID", nameof(model)); }
|
||||
|
||||
_logger.LogInformation("PC. RequestID: {RequestID}. EmployeeID: {EmployeeID}. PCName:{PCName}. Cost:{ Cost}. ID: { ID} ",model.RequestID,model.EmployeeID, model.Name, model.Price, model.ID);
|
||||
|
||||
var element = _PCStorage.GetElement(new PCSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
|
||||
if (element != null && element.ID != model.ID)
|
||||
{
|
||||
throw new InvalidOperationException("PC with such name already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
116
ComputerStoreBusinessLogic/BusinessLogic/ProductLogic.cs
Normal file
116
ComputerStoreBusinessLogic/BusinessLogic/ProductLogic.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ProductLogic : IProductLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProductStorage _productStorage;
|
||||
public ProductLogic(ILogger<ProductLogic> logger, IProductStorage productStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_productStorage = productStorage;
|
||||
}
|
||||
|
||||
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) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ProductViewModel? ReadElement(ProductSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ProductName:{ProductName}.ID:{ ID}", model.Name, model.ID);
|
||||
|
||||
var element = _productStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ProductViewModel>? ReadList(ProductSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ProductName:{ProductName}. ID:{ ID}", model?.Name, model?.ID);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void CheckModel(ProductBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
if (!withParams) { return; }
|
||||
if (string.IsNullOrEmpty(model.Name)) { throw new ArgumentNullException("Invalid product's name", nameof(model)); }
|
||||
if (model.Price <= 0) { throw new ArgumentNullException("Invalid product's price", nameof(model)); }
|
||||
if (string.IsNullOrEmpty(model.EmployeeID.ToString())) { throw new ArgumentNullException("Invalid Product's employee ID", nameof(model)); }
|
||||
|
||||
_logger.LogInformation("Product. EmployeeID: {EmployeeID}. product:{product}. Cost:{ Cost}. ID: { ID} ",model.EmployeeID, model.Name, model.Price, model.ID);
|
||||
|
||||
var element = _productStorage.GetElement(new ProductSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
|
||||
if (element != null && element.ID != model.ID)
|
||||
{
|
||||
throw new InvalidOperationException("Product with such name already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
125
ComputerStoreBusinessLogic/BusinessLogic/ReportOrderLogic.cs
Normal file
125
ComputerStoreBusinessLogic/BusinessLogic/ReportOrderLogic.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ReportOrderLogic : IReportOrderLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IConsignmentStorage _consignmentStorage;
|
||||
private readonly IRequestStorage _requestStorage;
|
||||
private readonly IPCStorage _pcStorage;
|
||||
|
||||
public ReportOrderLogic(
|
||||
IOrderStorage orderStorage,
|
||||
IConsignmentStorage consignmentStorage,
|
||||
IRequestStorage requestStorage,
|
||||
IPCStorage pcStorage)
|
||||
{
|
||||
_orderStorage = orderStorage;
|
||||
_consignmentStorage = consignmentStorage;
|
||||
_requestStorage = requestStorage;
|
||||
_pcStorage = pcStorage;
|
||||
}
|
||||
|
||||
public ReportOrderViewModel GetPCsByOrders(ReportOrderBindingModel model)
|
||||
{
|
||||
var report = new ReportOrderViewModel();
|
||||
List<OrderViewModel> orders = new List<OrderViewModel>();
|
||||
|
||||
foreach (var orderSearch in model.Orders)
|
||||
{
|
||||
var element = _orderStorage.GetElement(orderSearch);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Selected order is not find.");
|
||||
}
|
||||
orders.Add(element);
|
||||
}
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (order.OrderRequests == null) { continue; }
|
||||
report.OrderPCs.Add(order.ID, (new(), new()));
|
||||
|
||||
foreach (var requestRaw in order.OrderRequests)
|
||||
{
|
||||
var request = _requestStorage.GetElement(new RequestSearchModel { ID = requestRaw.ID });
|
||||
if (request == null) { throw new Exception("Request for report is not find."); }
|
||||
|
||||
var pc = _pcStorage.GetElement(new PCSearchModel { ID = request.PCID });
|
||||
if (pc == null) { throw new Exception("PC for report is not find."); }
|
||||
|
||||
report.OrderPCs[order.ID].Item1.Add(request);
|
||||
report.OrderPCs[order.ID].Item2.Add(pc);
|
||||
}
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
public ReportOrderByDateViewModel GetOrdersByDate(ReportDateBindingModel model)
|
||||
{
|
||||
var report = new ReportOrderByDateViewModel();
|
||||
var orders = _orderStorage.GetFullList();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (order.OrderConsignments == null && order.OrderRequests == null) { continue; }
|
||||
|
||||
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||
{
|
||||
report.OrderConsignmentsAndRequests.Add(order.ID, (new(), new()));
|
||||
|
||||
if (order.OrderConsignments != null)
|
||||
{
|
||||
foreach (var consignmentRaw in order.OrderConsignments)
|
||||
{
|
||||
var consignment = _consignmentStorage.GetElement(new ConsignmentSearchModel { ID = consignmentRaw.ID });
|
||||
if (consignment == null)
|
||||
{
|
||||
throw new Exception("Consignment for create report is not found");
|
||||
}
|
||||
report.OrderConsignmentsAndRequests[order.ID].Item1.Add(consignment);
|
||||
}
|
||||
}
|
||||
|
||||
if (order.OrderRequests != null)
|
||||
{
|
||||
foreach (var requestRaw in order.OrderRequests)
|
||||
{
|
||||
var request = _requestStorage.GetElement(new RequestSearchModel { ID = requestRaw.ID });
|
||||
if (request == null)
|
||||
{
|
||||
throw new Exception("Request for create report is not found");
|
||||
}
|
||||
report.OrderConsignmentsAndRequests[order.ID].Item2.Add(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
public void SaveOrdersToExcelFile(ReportOrderBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveOrdersToPdfFile(ReportDateBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveOrdersToWordFile(ReportOrderBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class RequestComponentLogic : IRequestComponentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRequestComponentStorage _requestComponentStorage;
|
||||
public RequestComponentLogic(ILogger<PCLogic> logger, IRequestComponentStorage requestComponentStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_requestComponentStorage = requestComponentStorage;
|
||||
}
|
||||
|
||||
public List<RequestComponentViewModel>? ReadList(RequestSearchModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PCID:{ PCID}. OrderID:{ OrderID}. ID:{ ID}", model?.PCID, model?.OrderID,model?.ID);
|
||||
var list = model.ID == null ? _requestComponentStorage.GetFullList() : _requestComponentStorage.GetFilteredList(model);
|
||||
|
||||
if(list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return new();
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
105
ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
Normal file
105
ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class RequestLogic : IRequestLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRequestStorage _requestStorage;
|
||||
public RequestLogic(ILogger<RequestLogic> logger, IRequestStorage requestStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_requestStorage = requestStorage;
|
||||
}
|
||||
|
||||
public bool Create(RequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_requestStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(RequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_requestStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(RequestBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||
if (_requestStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public RequestViewModel? ReadElement(RequestSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Request ID:{ ID}. Order ID:{ OrderID}", model.ID, model.OrderID);
|
||||
|
||||
var element = _requestStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<RequestViewModel>? ReadList(RequestSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Request ID:{ ID}. Order ID: { OrderID}", model?.ID, model?.OrderID);
|
||||
|
||||
var list = model == null ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(RequestBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
if (!withParams) { return; }
|
||||
if (model.Price <= 0) { throw new ArgumentNullException("Invalid request's price", nameof(model)); }
|
||||
if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Request's order ID", nameof(model)); }
|
||||
|
||||
_logger.LogInformation("Request. Request ID:{ ID}. Order ID: { OrderID}. PC ID: { PCID}", model.ID, model.OrderID, model.PCID);
|
||||
}
|
||||
}
|
||||
}
|
122
ComputerStoreBusinessLogic/BusinessLogic/SellerLogic.cs
Normal file
122
ComputerStoreBusinessLogic/BusinessLogic/SellerLogic.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SellerLogic : ISellerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISellerStorage _sellerStorage;
|
||||
public SellerLogic(ILogger<SellerLogic> logger, ISellerStorage sellerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_sellerStorage = sellerStorage;
|
||||
}
|
||||
public bool Create(SellerBindingModel model)
|
||||
{
|
||||
CheckSeller(model);
|
||||
if (_sellerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(SellerBindingModel model)
|
||||
{
|
||||
CheckSeller(model);
|
||||
if (_sellerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(SellerBindingModel model)
|
||||
{
|
||||
CheckSeller(model, false);
|
||||
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||
if (_sellerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public SellerViewModel? ReadElement(SellerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Username:{Username}.ID:{ ID}", model.Username, model.ID);
|
||||
var element = _sellerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<SellerViewModel>? ReadList(SellerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Username:{Username}. ID:{ ID}", model?.Username, model?.ID);
|
||||
|
||||
var list = model == null ? _sellerStorage.GetFullList() : _sellerStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public void CheckSeller(SellerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Username))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid username of user", nameof(model.Username));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid password of user", nameof(model.Password));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Client. Username:{ Username}. ID: { ID} ", model.Username, model.ID);
|
||||
|
||||
var element = _sellerStorage.GetElement(new SellerSearchModel
|
||||
{
|
||||
Username = model.Username
|
||||
});
|
||||
|
||||
if (element != null && element.ID != model.ID)
|
||||
{
|
||||
throw new InvalidOperationException("Seller with such username already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
ComputerStoreBusinessLogic/ComputerStoreBusinessLogic.csproj
Normal file
18
ComputerStoreBusinessLogic/ComputerStoreBusinessLogic.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerStoreContracts\ComputerStoreContracts.csproj" />
|
||||
<ProjectReference Include="..\ComputerStoreDataModels\ComputerStoreDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,19 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ComponentBindingModel : IComponentModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ConsignmentBindingModel : IConsignmentModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int OrderID { get; set; }
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IProductModel, int)> ConsignmentProducts { get; set; } = new();
|
||||
}
|
||||
}
|
19
ComputerStoreContracts/BindingModels/EmployeeBindingModel.cs
Normal file
19
ComputerStoreContracts/BindingModels/EmployeeBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel : IEmployeeModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
22
ComputerStoreContracts/BindingModels/OrderBindingModel.cs
Normal file
22
ComputerStoreContracts/BindingModels/OrderBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public double Price { get; set; }
|
||||
public List<IConsignmentModel>? OrderConsignments { get; set; } = new();
|
||||
public List<IRequestModel>? OrderRequests { get; set; } = new();
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public int SellerID { get; set; }
|
||||
}
|
||||
}
|
23
ComputerStoreContracts/BindingModels/PCBindingModel.cs
Normal file
23
ComputerStoreContracts/BindingModels/PCBindingModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class PCBindingModel : IPCModel
|
||||
{
|
||||
public int ID {get; set;}
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public int EmployeeID { get; set; }
|
||||
|
||||
public int RequestID { get; set; }
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> PCComponents { get; set; } = new();
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/BindingModels/ProductBindingModel.cs
Normal file
21
ComputerStoreContracts/BindingModels/ProductBindingModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ProductBindingModel : IProductModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public int EmployeeID { get; set; }
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ReportComponentsBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<ComponentSearchModel> Components { get; set; } = new List<ComponentSearchModel>();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ReportDateBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set;}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class ReportOrderBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<OrderSearchModel> Orders { get; set; } = new();
|
||||
}
|
||||
}
|
17
ComputerStoreContracts/BindingModels/RequestBindingModel.cs
Normal file
17
ComputerStoreContracts/BindingModels/RequestBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class RequestBindingModel : IRequestModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int OrderID { get; set; }
|
||||
public double Price { get; set; }
|
||||
public int? PCID { get; set; }
|
||||
}
|
||||
}
|
20
ComputerStoreContracts/BindingModels/SellerBindingModel.cs
Normal file
20
ComputerStoreContracts/BindingModels/SellerBindingModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BindingModels
|
||||
{
|
||||
public class SellerBindingModel : ISellerModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IComponentLogic
|
||||
{
|
||||
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
||||
|
||||
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
||||
|
||||
bool Create(ComponentBindingModel model);
|
||||
bool Update(ComponentBindingModel model);
|
||||
bool Delete(ComponentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IConsignmentLogic
|
||||
{
|
||||
List<ConsignmentViewModel>? ReadList(ConsignmentSearchModel? model);
|
||||
ConsignmentViewModel? ReadElement(ConsignmentSearchModel model);
|
||||
bool Create(ConsignmentBindingModel model);
|
||||
bool Update(ConsignmentBindingModel model);
|
||||
bool Delete(ConsignmentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model);
|
||||
EmployeeViewModel? ReadElement(EmployeeSearchModel model);
|
||||
bool Create(EmployeeBindingModel model);
|
||||
bool Update(EmployeeBindingModel model);
|
||||
bool Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IEmployeeReportLogic
|
||||
{
|
||||
List<ReportProductByDateViewModel> GetProductsByDate(ReportDateBindingModel model);
|
||||
List<ReportPCByDateViewModel> GetPCsByDate(ReportDateBindingModel model);
|
||||
List<ReportConsignmentsViewModel> GetConsignmentsByComponents(ReportComponentsBindingModel model);
|
||||
|
||||
void SaveProductsToPdfFile(ReportDateBindingModel model);
|
||||
void SavePCsToPdfFile(ReportDateBindingModel model);
|
||||
}
|
||||
}
|
20
ComputerStoreContracts/BusinessLogicContracts/IOrderLogic.cs
Normal file
20
ComputerStoreContracts/BusinessLogicContracts/IOrderLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInProcess(OrderBindingModel model);
|
||||
bool TakeOrderReady(OrderBindingModel model);
|
||||
bool TakeOrderGiven(OrderBindingModel model);
|
||||
}
|
||||
}
|
22
ComputerStoreContracts/BusinessLogicContracts/IPCLogic.cs
Normal file
22
ComputerStoreContracts/BusinessLogicContracts/IPCLogic.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IPCLogic
|
||||
{
|
||||
List<PCViewModel>? ReadList(PCSearchModel? model);
|
||||
|
||||
PCViewModel? ReadElement(PCSearchModel model);
|
||||
|
||||
bool Create(PCBindingModel model);
|
||||
bool Update(PCBindingModel model);
|
||||
bool Delete(PCBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IProductLogic
|
||||
{
|
||||
List<ProductViewModel>? ReadList(ProductSearchModel? model);
|
||||
|
||||
ProductViewModel? ReadElement(ProductSearchModel model);
|
||||
|
||||
bool Create(ProductBindingModel model);
|
||||
bool Update(ProductBindingModel model);
|
||||
bool Delete(ProductBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportOrderLogic
|
||||
{
|
||||
ReportOrderViewModel GetPCsByOrders(ReportOrderBindingModel model);
|
||||
ReportOrderByDateViewModel GetOrdersByDate(ReportDateBindingModel model);
|
||||
void SaveOrdersToWordFile(ReportOrderBindingModel model);
|
||||
void SaveOrdersToExcelFile(ReportOrderBindingModel model);
|
||||
void SaveOrdersToPdfFile(ReportDateBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IRequestComponentLogic
|
||||
{
|
||||
List<RequestComponentViewModel>? ReadList(RequestSearchModel? model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IRequestLogic
|
||||
{
|
||||
List<RequestViewModel>? ReadList(RequestSearchModel? model);
|
||||
RequestViewModel? ReadElement(RequestSearchModel model);
|
||||
bool Create(RequestBindingModel model);
|
||||
bool Update(RequestBindingModel model);
|
||||
bool Delete(RequestBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISellerLogic
|
||||
{
|
||||
List<SellerViewModel>? ReadList(SellerSearchModel? model);
|
||||
SellerViewModel? ReadElement(SellerSearchModel model);
|
||||
bool Create(SellerBindingModel model);
|
||||
bool Update(SellerBindingModel model);
|
||||
bool Delete(SellerBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.BusinessLogicContracts
|
||||
{
|
||||
internal class ISellerReportLogic
|
||||
{
|
||||
}
|
||||
}
|
13
ComputerStoreContracts/ComputerStoreContracts.csproj
Normal file
13
ComputerStoreContracts/ComputerStoreContracts.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerStoreDataModels\ComputerStoreDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
ComputerStoreContracts/SearchModels/ComponentSearchModel.cs
Normal file
14
ComputerStoreContracts/SearchModels/ComponentSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class ComponentSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class ConsignmentSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public int? OrderID { get; set; }
|
||||
public int? ProductID { get; set; }
|
||||
}
|
||||
}
|
14
ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs
Normal file
14
ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class EmployeeSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
}
|
19
ComputerStoreContracts/SearchModels/OrderSearchModel.cs
Normal file
19
ComputerStoreContracts/SearchModels/OrderSearchModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public int? ConsignmentID { get; set; }
|
||||
public int? RequestID { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? SellerID { get; set; }
|
||||
}
|
||||
}
|
18
ComputerStoreContracts/SearchModels/PCSearchModel.cs
Normal file
18
ComputerStoreContracts/SearchModels/PCSearchModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class PCSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? RequestID { get; set; }
|
||||
public int? EmployeeID { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set;}
|
||||
}
|
||||
}
|
18
ComputerStoreContracts/SearchModels/ProductSearchModel.cs
Normal file
18
ComputerStoreContracts/SearchModels/ProductSearchModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class ProductSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? EmployeeID { get; set; }
|
||||
public int? ComponentID { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
}
|
||||
}
|
15
ComputerStoreContracts/SearchModels/RequestSearchModel.cs
Normal file
15
ComputerStoreContracts/SearchModels/RequestSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class RequestSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public int? OrderID { get; set; }
|
||||
public int? PCID { get; set; }
|
||||
}
|
||||
}
|
14
ComputerStoreContracts/SearchModels/SellerSearchModel.cs
Normal file
14
ComputerStoreContracts/SearchModels/SellerSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.SearchModels
|
||||
{
|
||||
public class SellerSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IComponentStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IComponentStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IComponentStorage
|
||||
{
|
||||
List<ComponentViewModel> GetFullList();
|
||||
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
||||
ComponentViewModel? GetElement(ComponentSearchModel model);
|
||||
ComponentViewModel? Insert(ComponentBindingModel model);
|
||||
ComponentViewModel? Update(ComponentBindingModel model);
|
||||
ComponentViewModel? Delete(ComponentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IConsignmentStorage
|
||||
{
|
||||
List<ConsignmentViewModel> GetFullList();
|
||||
List<ConsignmentViewModel> GetFilteredList(ConsignmentSearchModel model);
|
||||
ConsignmentViewModel? GetElement(ConsignmentSearchModel model);
|
||||
ConsignmentViewModel? Insert(ConsignmentBindingModel model);
|
||||
ConsignmentViewModel? Update(ConsignmentBindingModel model);
|
||||
ConsignmentViewModel? Delete(ConsignmentBindingModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IEmployeeStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IEmployeeStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model);
|
||||
EmployeeViewModel? GetElement(EmployeeSearchModel model);
|
||||
EmployeeViewModel? Insert(EmployeeBindingModel model);
|
||||
EmployeeViewModel? Update(EmployeeBindingModel model);
|
||||
EmployeeViewModel? Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IOrderStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IOrderStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IPCStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IPCStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IPCStorage
|
||||
{
|
||||
List<PCViewModel> GetFullList();
|
||||
List<PCViewModel> GetFilteredList(PCSearchModel model);
|
||||
PCViewModel? GetElement(PCSearchModel model);
|
||||
PCViewModel? Insert(PCBindingModel model);
|
||||
PCViewModel? Update(PCBindingModel model);
|
||||
PCViewModel? Delete(PCBindingModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IProductStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IProductStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IProductStorage
|
||||
{
|
||||
List<ProductViewModel> GetFullList();
|
||||
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
|
||||
ProductViewModel? GetElement(ProductSearchModel model);
|
||||
ProductViewModel? Insert(ProductBindingModel model);
|
||||
ProductViewModel? Update(ProductBindingModel model);
|
||||
ProductViewModel? Delete(ProductBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IRequestComponentStorage
|
||||
{
|
||||
List<RequestComponentViewModel> GetFullList();
|
||||
List<RequestComponentViewModel> GetFilteredList(RequestSearchModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/IRequestStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/IRequestStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface IRequestStorage
|
||||
{
|
||||
List<RequestViewModel> GetFullList();
|
||||
List<RequestViewModel> GetFilteredList(RequestSearchModel model);
|
||||
RequestViewModel? GetElement(RequestSearchModel model);
|
||||
RequestViewModel? Insert(RequestBindingModel model);
|
||||
RequestViewModel? Update(RequestBindingModel model);
|
||||
RequestViewModel? Delete(RequestBindingModel model);
|
||||
}
|
||||
}
|
21
ComputerStoreContracts/StorageContracts/ISellerStorage.cs
Normal file
21
ComputerStoreContracts/StorageContracts/ISellerStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.StorageContracts
|
||||
{
|
||||
public interface ISellerStorage
|
||||
{
|
||||
List<SellerViewModel> GetFullList();
|
||||
List<SellerViewModel> GetFilteredList(SellerSearchModel model);
|
||||
SellerViewModel? GetElement(SellerSearchModel model);
|
||||
SellerViewModel? Insert(SellerBindingModel model);
|
||||
SellerViewModel? Update(SellerBindingModel model);
|
||||
SellerViewModel? Delete(SellerBindingModel model);
|
||||
}
|
||||
}
|
23
ComputerStoreContracts/ViewModels/ComponentViewModel.cs
Normal file
23
ComputerStoreContracts/ViewModels/ComponentViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ComponentViewModel : IComponentModel
|
||||
{
|
||||
public int ID {get; set;}
|
||||
|
||||
[DisplayName("Component's name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Component's price")]
|
||||
public double Price { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
22
ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs
Normal file
22
ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ConsignmentViewModel : IConsignmentModel
|
||||
{
|
||||
[DisplayName("Consignment ID")]
|
||||
public int ID { get; set; }
|
||||
[DisplayName("Order ID")]
|
||||
public int OrderID { get; set; }
|
||||
[DisplayName("Price")]
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> ConsignmentProducts { get; set; } = new();
|
||||
}
|
||||
}
|
31
ComputerStoreContracts/ViewModels/EmployeeViewModel.cs
Normal file
31
ComputerStoreContracts/ViewModels/EmployeeViewModel.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel : IEmployeeModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
[DisplayName("Employee's login")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Employee's first name")]
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Employee's last name")]
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Employee's middle name")]
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
}
|
32
ComputerStoreContracts/ViewModels/OrderViewModel.cs
Normal file
32
ComputerStoreContracts/ViewModels/OrderViewModel.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Order ID")]
|
||||
public int ID { get; set; }
|
||||
[DisplayName("Price")]
|
||||
public double Price { get; set; }
|
||||
[DisplayName("Status")]
|
||||
public OrderStatus Status { get; set; }
|
||||
[DisplayName("Creation date")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DisplayName("Implementation date")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
public int SellerID { get; set; }
|
||||
[DisplayName("SellerUsername")]
|
||||
public string? SellerUsername { get; set; } = string.Empty;
|
||||
|
||||
public List<IConsignmentModel>? OrderConsignments { get; set; } = new();
|
||||
public List<IRequestModel>? OrderRequests { get; set; } = new();
|
||||
}
|
||||
}
|
32
ComputerStoreContracts/ViewModels/PCViewModel.cs
Normal file
32
ComputerStoreContracts/ViewModels/PCViewModel.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class PCViewModel : IPCModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
[DisplayName("PC's name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("PC's price")]
|
||||
public double Price { get; set; }
|
||||
|
||||
public int EmployeeID { get; set; }
|
||||
|
||||
[DisplayName("Employee's username")]
|
||||
public string EmployeeUsername { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Request ID")]
|
||||
public int RequestID { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> PCComponents { get; set; } = new();
|
||||
|
||||
|
||||
}
|
||||
}
|
30
ComputerStoreContracts/ViewModels/ProductViewModel.cs
Normal file
30
ComputerStoreContracts/ViewModels/ProductViewModel.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ProductViewModel : IProductModel
|
||||
{
|
||||
public int ID {get; set;}
|
||||
|
||||
[DisplayName("Product's name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Product's price")]
|
||||
public double Price { get; set; }
|
||||
|
||||
public int EmployeeID { get; set; }
|
||||
|
||||
[DisplayName("Employee's username")]
|
||||
public string EmployeeUsername { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportConsignmentsViewModel
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public List<(string product, int count)> Products { get; set; } = new List<(string, int)>();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportOrderByDateViewModel
|
||||
{
|
||||
public Dictionary<int, (List<ConsignmentViewModel>, List<RequestViewModel>)> OrderConsignmentsAndRequests { get; set; } = new();
|
||||
}
|
||||
}
|
13
ComputerStoreContracts/ViewModels/ReportOrderViewModel.cs
Normal file
13
ComputerStoreContracts/ViewModels/ReportOrderViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportOrderViewModel
|
||||
{
|
||||
public Dictionary<int, (List<RequestViewModel>, List<PCViewModel>)> OrderPCs { get; set; } = new();
|
||||
}
|
||||
}
|
16
ComputerStoreContracts/ViewModels/ReportPCByDateViewModel.cs
Normal file
16
ComputerStoreContracts/ViewModels/ReportPCByDateViewModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportPCByDateViewModel
|
||||
{
|
||||
public string PCName { get; set; } = string.Empty;
|
||||
public List<(string Component, int count)> Components { get; set; } = new List<(string Component, int count)> ();
|
||||
|
||||
public string EmployeeUsername { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportProductByDateViewModel
|
||||
{
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public List<(string Component, int count)> Components { get; set; } = new List<(string Component, int count)>();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class RequestComponentViewModel
|
||||
{
|
||||
[DisplayName("RequestID")]
|
||||
public int RequestID { get; set; }
|
||||
|
||||
[DisplayName("ComponentID")]
|
||||
public int ComponentID { get; set; }
|
||||
|
||||
[DisplayName("Component's name")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Component's count")]
|
||||
public int ComponentCount { get; set; }
|
||||
|
||||
[DisplayName("PCID")]
|
||||
public int PCID { get; set; }
|
||||
|
||||
}
|
||||
}
|
26
ComputerStoreContracts/ViewModels/RequestViewModel.cs
Normal file
26
ComputerStoreContracts/ViewModels/RequestViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class RequestViewModel : IRequestModel
|
||||
{
|
||||
[DisplayName("Request ID")]
|
||||
public int ID { get; set; }
|
||||
[DisplayName("Order ID")]
|
||||
public int OrderID { get; set; }
|
||||
[DisplayName("Price")]
|
||||
public double Price { get; set; }
|
||||
|
||||
[DisplayName("PC ID")]
|
||||
public int? PCID { get; set; }
|
||||
|
||||
[DisplayName("PC's name")]
|
||||
public string PCName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
26
ComputerStoreContracts/ViewModels/SellerViewModel.cs
Normal file
26
ComputerStoreContracts/ViewModels/SellerViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using ComputerStoreDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreContracts.ViewModels
|
||||
{
|
||||
public class SellerViewModel : ISellerModel
|
||||
{
|
||||
[DisplayName("Seller ID")]
|
||||
public int ID { get; set; }
|
||||
[DisplayName("Username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DisplayName("FirstName")]
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
[DisplayName("LastName")]
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
[DisplayName("MiddleName")]
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
9
ComputerStoreDataModels/ComputerStoreDataModels.csproj
Normal file
9
ComputerStoreDataModels/ComputerStoreDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
17
ComputerStoreDataModels/Enums/OrderStatus.cs
Normal file
17
ComputerStoreDataModels/Enums/OrderStatus.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Enums
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
Unknown = -1,
|
||||
Accepted = 0,
|
||||
InProcess = 1,
|
||||
Ready = 2,
|
||||
Given = 3
|
||||
}
|
||||
}
|
13
ComputerStoreDataModels/IID.cs
Normal file
13
ComputerStoreDataModels/IID.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels
|
||||
{
|
||||
public interface IID
|
||||
{
|
||||
int ID { get; }
|
||||
}
|
||||
}
|
16
ComputerStoreDataModels/Models/IComponentModel.cs
Normal file
16
ComputerStoreDataModels/Models/IComponentModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IComponentModel : IID
|
||||
{
|
||||
[MaxLength(255)]
|
||||
string Name { get;}
|
||||
double Price { get;}
|
||||
}
|
||||
}
|
15
ComputerStoreDataModels/Models/IConsignmentModel.cs
Normal file
15
ComputerStoreDataModels/Models/IConsignmentModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IConsignmentModel : IID
|
||||
{
|
||||
int OrderID { get; }
|
||||
double Price { get; }
|
||||
Dictionary<int, (IProductModel, int)> ConsignmentProducts { get; }
|
||||
}
|
||||
}
|
23
ComputerStoreDataModels/Models/IEmployeeModel.cs
Normal file
23
ComputerStoreDataModels/Models/IEmployeeModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IEmployeeModel : IID
|
||||
{
|
||||
[MaxLength(15)]
|
||||
string Username { get; }
|
||||
[MaxLength(20)]
|
||||
string Password { get; }
|
||||
[MaxLength(255)]
|
||||
string? FirstName { get; }
|
||||
[MaxLength(255)]
|
||||
string? LastName { get; }
|
||||
[MaxLength(255)]
|
||||
string? MiddleName { get; }
|
||||
}
|
||||
}
|
20
ComputerStoreDataModels/Models/IOrderModel.cs
Normal file
20
ComputerStoreDataModels/Models/IOrderModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IID
|
||||
{
|
||||
double Price { get; }
|
||||
List<IConsignmentModel>? OrderConsignments { get; }
|
||||
List<IRequestModel>? OrderRequests { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
int SellerID { get; }
|
||||
}
|
||||
}
|
19
ComputerStoreDataModels/Models/IPCModel.cs
Normal file
19
ComputerStoreDataModels/Models/IPCModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IPCModel : IID
|
||||
{
|
||||
[MaxLength(255)]
|
||||
public string Name { get; }
|
||||
public double Price { get; }
|
||||
public int EmployeeID { get; }
|
||||
public int RequestID { get; }
|
||||
Dictionary<int,(IComponentModel,int)> PCComponents { get; }
|
||||
}
|
||||
}
|
16
ComputerStoreDataModels/Models/IProductModel.cs
Normal file
16
ComputerStoreDataModels/Models/IProductModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IProductModel : IID
|
||||
{
|
||||
public string Name { get; }
|
||||
public double Price { get; }
|
||||
public int EmployeeID { get; }
|
||||
Dictionary<int,(IComponentModel,int)> ProductComponents { get; }
|
||||
}
|
||||
}
|
15
ComputerStoreDataModels/Models/IRequestModel.cs
Normal file
15
ComputerStoreDataModels/Models/IRequestModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface IRequestModel : IID
|
||||
{
|
||||
int OrderID { get; }
|
||||
int? PCID { get; }
|
||||
double Price { get; }
|
||||
}
|
||||
}
|
17
ComputerStoreDataModels/Models/ISellerModel.cs
Normal file
17
ComputerStoreDataModels/Models/ISellerModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDataModels.Models
|
||||
{
|
||||
public interface ISellerModel : IID
|
||||
{
|
||||
string Username { get; }
|
||||
string Password { get; }
|
||||
string? FirstName { get; }
|
||||
string? LastName { get; }
|
||||
string? MiddleName { get; }
|
||||
}
|
||||
}
|
34
ComputerStoreDatabaseImplement/ComputerStoreDatabase.cs
Normal file
34
ComputerStoreDatabaseImplement/ComputerStoreDatabase.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement
|
||||
{
|
||||
public class ComputerStoreDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=YUEEJKE\SQLEXPRESS;Initial Catalog=ComputerStoreDatabase;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Component> Components { get; set; }
|
||||
public virtual DbSet<Product> Products { get; set; }
|
||||
public virtual DbSet<PC> PCs { get; set; }
|
||||
public virtual DbSet<Employee> Employees { get; set; }
|
||||
public virtual DbSet<RequestComponent> RequestComponents { get; set; }
|
||||
public virtual DbSet<ProductComponent> ProductComponents { get; set; }
|
||||
public virtual DbSet<ConsignmentProduct> ConsignmentProducts { get; set; }
|
||||
public virtual DbSet<Consignment> Consignments { get; set; }
|
||||
public virtual DbSet<Order> Orders { get; set; }
|
||||
public virtual DbSet<Request> Requests { get; set; }
|
||||
public virtual DbSet<Seller> Sellers { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerStoreContracts\ComputerStoreContracts.csproj" />
|
||||
<ProjectReference Include="..\ComputerStoreDataModels\ComputerStoreDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,79 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class ComponentStorage : IComponentStorage
|
||||
{
|
||||
|
||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Name) && !model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && model.Name == x.Name) || (model.ID.HasValue && model.ID ==x.ID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Components.Where(x => x.Name.Equals(model.Name)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Components.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newComponent = Component.Create(model);
|
||||
|
||||
if(newComponent == null) { return null; }
|
||||
|
||||
context.Components.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specComponent = context.Components.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if(specComponent == null) { return null; }
|
||||
|
||||
specComponent.Update(model);
|
||||
context.SaveChanges();
|
||||
return specComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specComponent = context.Components.FirstOrDefault(x => x.ID==model.ID);
|
||||
|
||||
if(specComponent == null) { return null; }
|
||||
|
||||
context.Components.Remove(specComponent);
|
||||
context.SaveChanges();
|
||||
return specComponent.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
117
ComputerStoreDatabaseImplement/Implements/ConsignmentStorage.cs
Normal file
117
ComputerStoreDatabaseImplement/Implements/ConsignmentStorage.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class ConsignmentStorage : IConsignmentStorage
|
||||
{
|
||||
public List<ConsignmentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Consignments
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ConsignmentViewModel> GetFilteredList(ConsignmentSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Consignments.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(!model.ProductID.HasValue || x.Products.FirstOrDefault(y => y.ProductID == model.ProductID) != null))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ConsignmentViewModel? GetElement(ConsignmentSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Consignments.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(!model.ProductID.HasValue || x.Products.FirstOrDefault(y => y.ProductID == model.ProductID) != null))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ConsignmentViewModel? Insert(ConsignmentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var newConsignment = Consignment.Create(context, model);
|
||||
if (newConsignment == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Consignments.Add(newConsignment);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Consignments.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x => x.ID == newConsignment.ID)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ConsignmentViewModel? Update(ConsignmentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var consignment = context.Consignments.Include(x => x.Products).FirstOrDefault(x => x.ID == model.ID);
|
||||
if (consignment == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
consignment.Update(model);
|
||||
consignment.UpdateProducts(context, model);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Consignments.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x => x.ID == consignment.ID)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ConsignmentViewModel? Delete(ConsignmentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var consignment = context.Consignments.Include(x => x.Order)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (consignment != null)
|
||||
{
|
||||
context.Consignments.Remove(consignment);
|
||||
context.SaveChanges();
|
||||
|
||||
return consignment.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
79
ComputerStoreDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
79
ComputerStoreDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
|
||||
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Username) && !model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Employees.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Username) && model.Username == x.Username) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Username))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Employees.Where(x => x.Username.Equals(model.Username)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Employees.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Insert(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newEmployee = Employee.Create(model);
|
||||
|
||||
if(newEmployee == null) { return null; }
|
||||
|
||||
context.Employees.Add(newEmployee);
|
||||
context.SaveChanges();
|
||||
return newEmployee.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Update(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specEmployee = context.Employees.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if (specEmployee == null) { return null; }
|
||||
|
||||
specEmployee.Update(model);
|
||||
context.SaveChanges();
|
||||
return specEmployee.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Delete(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specEmployee = context.Employees.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if (specEmployee == null) { return null; }
|
||||
|
||||
context.Employees.Remove(specEmployee);
|
||||
context.SaveChanges();
|
||||
return specEmployee.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
134
ComputerStoreDatabaseImplement/Implements/OrderStorage.cs
Normal file
134
ComputerStoreDatabaseImplement/Implements/OrderStorage.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue ||
|
||||
x.ID == model.ID) &&
|
||||
(!model.SellerID.HasValue ||
|
||||
x.SellerID == model.SellerID) &&
|
||||
(!model.ConsignmentID.HasValue ||
|
||||
x._consignments.FirstOrDefault(y => y.ID == model.ConsignmentID) != null) &&
|
||||
(!model.RequestID.HasValue ||
|
||||
x._requests.FirstOrDefault(y => y.ID == model.RequestID) != null) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.FirstOrDefault(x =>
|
||||
(!model.ID.HasValue ||
|
||||
x.ID == model.ID) &&
|
||||
(!model.SellerID.HasValue ||
|
||||
x.SellerID == model.SellerID) &&
|
||||
(!model.ConsignmentID.HasValue ||
|
||||
x._consignments.FirstOrDefault(y => y.ID == model.ConsignmentID) != null) &&
|
||||
(!model.RequestID.HasValue ||
|
||||
x._requests.FirstOrDefault(y => y.ID == model.RequestID) != null) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo))?
|
||||
.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var newOrder = Order.Create(context, model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.FirstOrDefault(x => x.ID == newOrder.ID)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var order = context.Orders
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
order.Update(model);
|
||||
order.UpdateOrderConsignments(context, model);
|
||||
order.UpdateOrderRequests(context, model);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.FirstOrDefault(x => x.ID == model.ID)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var order = context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (order != null)
|
||||
{
|
||||
context.Orders.Remove(order);
|
||||
context.SaveChanges();
|
||||
|
||||
return order.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
101
ComputerStoreDatabaseImplement/Implements/PCStorage.cs
Normal file
101
ComputerStoreDatabaseImplement/Implements/PCStorage.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class PCStorage : IPCStorage
|
||||
{
|
||||
|
||||
public PCViewModel? GetElement(PCSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.ID.HasValue) { return null; }
|
||||
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.PCS.Include(x => x.Employee).Include(x => x.Request).FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && model.Name.Equals(x.Name)) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
public List<PCViewModel> GetFilteredList(PCSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.EmployeeID.HasValue && !model.ID.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
if(model.EmployeeID.HasValue)
|
||||
{
|
||||
return context.PCs.Include(x => x.Employee).Where(x => x.EmployeeID == model.EmployeeID).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
return context.PCS.Include(x => x.Employee).Include(x => x.Request).Where(p => context.Requests.Where(r => context.Orders.Where(o => o.DateCreate >= model.DateFrom && o.DateCreate <= model.DateTo).Select(o => o.ID).Contains(r.OrderID)).Select(r => r.ID).Contains(p.RequestID)).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<PCViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.PCS.Include(x => x.Employee).Include(x => x.Request).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public PCViewModel? Insert(PCBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newPC = PC.Create(context, model);
|
||||
if(newPC == null) { return null; }
|
||||
|
||||
context.PCS.Add(newPC);
|
||||
|
||||
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
|
||||
|
||||
var pc = context.PCS.FirstOrDefault(x => x.Name.Equals(model.Name));
|
||||
PC.EnterPCID(context, pc);
|
||||
|
||||
return newPC.GetViewModel;
|
||||
}
|
||||
|
||||
public PCViewModel? Update(PCBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var specPC = context.PCs.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(specPC == null) { return null; }
|
||||
|
||||
specPC.Update(model);
|
||||
context.SaveChanges();
|
||||
specPC.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return specPC.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public PCViewModel? Delete(PCBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specPC = context.PCS.Include(x => x.Request).FirstOrDefault(x => x.ID == model.ID);
|
||||
if(specPC == null) { return null;}
|
||||
context.PCs.Remove(specPC);
|
||||
context.SaveChanges();
|
||||
return specPC.GetViewModel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
94
ComputerStoreDatabaseImplement/Implements/ProductStorage.cs
Normal file
94
ComputerStoreDatabaseImplement/Implements/ProductStorage.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class ProductStorage : IProductStorage
|
||||
{
|
||||
public ProductViewModel? GetElement(ProductSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Name) && !model.ID.HasValue) { return null; }
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && model.Name.Equals(x.Name)) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Name) && !model.EmployeeID.HasValue && !model.DateTo.HasValue && !model.DateFrom.HasValue && !model.ComponentID.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new ComputerStoreDatabase();
|
||||
if(model.EmployeeID.HasValue)
|
||||
{
|
||||
return context.Products.Include(x => x.Employee).Where(x => x.EmployeeID == model.EmployeeID).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
if(model.ComponentID.HasValue)
|
||||
{
|
||||
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).Where(p => context.ProductComponents.Where(pc => pc.ComponentID == model.ComponentID).Select(pc => pc.ProductID).Contains(p.ID)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).Where(p => context.ConsignmentProducts.Where(cp => context.Consignments.Where(c => context.Orders.Where(o => o.DateCreate >= model.DateFrom && o.DateCreate <= model.DateTo).Select(o => o.ID).Contains(c.OrderID)).Select(c => c.ID).Contains(cp.ConsignmentID)).Select(cp => cp.ProductID).Contains(p.ID)).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ProductViewModel? Insert(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newProduct = Product.Create(context, model);
|
||||
|
||||
if(newProduct == null) { return null; }
|
||||
|
||||
context.Products.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return newProduct.GetViewModel;
|
||||
}
|
||||
|
||||
public ProductViewModel? Update(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var specProduct = context.Products.FirstOrDefault(x => x.ID==model.ID);
|
||||
if(specProduct == null) { return null; }
|
||||
specProduct.Update(model);
|
||||
context.SaveChanges();
|
||||
specProduct.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return specProduct.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductViewModel? Delete(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specProduct = context.Products.Include(x => x.Components).FirstOrDefault(x => x.ID == model.ID);
|
||||
if(specProduct == null) { return null; }
|
||||
|
||||
context.Products.Remove(specProduct);
|
||||
context.SaveChanges();
|
||||
return specProduct.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class RequestComponentStorage : IRequestComponentStorage
|
||||
{
|
||||
public List<RequestComponentViewModel> GetFilteredList(RequestSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var list = new List<RequestComponentViewModel>();
|
||||
foreach (var pc in context.RequestComponents.Include(x => x.Component).Include(x => x.Request).Where(x => x.PCID == null && x.RequestID == model.ID))
|
||||
{
|
||||
list.Add(new RequestComponentViewModel
|
||||
{
|
||||
RequestID = pc.RequestID,
|
||||
ComponentID = pc.ComponentID,
|
||||
ComponentName = pc.Component.Name,
|
||||
ComponentCount = pc.Count,
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<RequestComponentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var list = new List<RequestComponentViewModel>();
|
||||
|
||||
foreach(var pc in context.RequestComponents.Include(x => x.Component).Include(x => x.Request).Where(x => x.PCID == null))
|
||||
{
|
||||
list.Add(new RequestComponentViewModel {
|
||||
RequestID = pc.RequestID,
|
||||
ComponentID = pc.ComponentID,
|
||||
ComponentName = pc.Component.Name,
|
||||
ComponentCount = pc.Count,
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
104
ComputerStoreDatabaseImplement/Implements/RequestStorage.cs
Normal file
104
ComputerStoreDatabaseImplement/Implements/RequestStorage.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class RequestStorage : IRequestStorage
|
||||
{
|
||||
public RequestViewModel? GetElement(RequestSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.FirstOrDefault(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(!model.PCID.HasValue || x.PCID == model.PCID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<RequestViewModel> GetFilteredList(RequestSearchModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(!model.PCID.HasValue || x.PCID == model.PCID))
|
||||
.Select(y => y.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RequestViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.Select(y => y.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RequestViewModel? Insert(RequestBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newRequest = Request.Create(context, model);
|
||||
if (newRequest == null) { return null; }
|
||||
context.Requests.Add(newRequest);
|
||||
context.SaveChanges();
|
||||
return context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
}
|
||||
|
||||
public RequestViewModel? Update(RequestBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var request = context.Requests.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (request == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
request.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
}
|
||||
|
||||
public RequestViewModel? Delete(RequestBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var request = context.Requests
|
||||
.Include(x => x.Order)
|
||||
.Include(y => y.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
context.Requests.Remove(request);
|
||||
context.SaveChanges();
|
||||
|
||||
return request.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
78
ComputerStoreDatabaseImplement/Implements/SellerStorage.cs
Normal file
78
ComputerStoreDatabaseImplement/Implements/SellerStorage.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.StorageContracts;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class SellerStorage : ISellerStorage
|
||||
{
|
||||
public SellerViewModel? GetElement(SellerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Username) && !model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Sellers.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Username) && model.Username == x.Username) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<SellerViewModel> GetFilteredList(SellerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Username))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Sellers.Where(x => x.Username.Equals(model.Username)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<SellerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Sellers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public SellerViewModel? Insert(SellerBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var newSeller = Seller.Create(model);
|
||||
|
||||
if (newSeller == null) { return null; }
|
||||
|
||||
context.Sellers.Add(newSeller);
|
||||
context.SaveChanges();
|
||||
return newSeller.GetViewModel;
|
||||
}
|
||||
|
||||
public SellerViewModel? Update(SellerBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specSeller = context.Sellers.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if (specSeller == null) { return null; }
|
||||
|
||||
specSeller.Update(model);
|
||||
context.SaveChanges();
|
||||
return specSeller.GetViewModel;
|
||||
}
|
||||
|
||||
public SellerViewModel? Delete(SellerBindingModel model)
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
var specSeller = context.Sellers.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
||||
if (specSeller == null) { return null; }
|
||||
|
||||
context.Sellers.Remove(specSeller);
|
||||
context.SaveChanges();
|
||||
return specSeller.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
501
ComputerStoreDatabaseImplement/Migrations/20230408204154_init.Designer.cs
generated
Normal file
501
ComputerStoreDatabaseImplement/Migrations/20230408204154_init.Designer.cs
generated
Normal file
@ -0,0 +1,501 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerStoreDatabase))]
|
||||
[Migration("20230408204154_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int?>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ConsignmentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConsignmentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ConsignmentProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SellerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("PCID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Sellers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_consignments")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Consignments")
|
||||
.HasForeignKey("ProductID");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("ConsignmentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Consignment");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Seller");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ConsignmentComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_requests")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RequestComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.PC", "PC")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("PCID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("PC");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ConsignmentComponents");
|
||||
|
||||
b.Navigation("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("_consignments");
|
||||
|
||||
b.Navigation("_requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
367
ComputerStoreDatabaseImplement/Migrations/20230408204154_init.cs
Normal file
367
ComputerStoreDatabaseImplement/Migrations/20230408204154_init.cs
Normal file
@ -0,0 +1,367 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Username = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Sellers",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Username = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Sellers", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PCs",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
EmployeeID = table.Column<int>(type: "int", nullable: false),
|
||||
RequestID = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PCs", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_PCs_Employees_EmployeeID",
|
||||
column: x => x.EmployeeID,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
EmployeeID = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_Employees_EmployeeID",
|
||||
column: x => x.EmployeeID,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
SellerID = table.Column<int>(type: "int", nullable: false),
|
||||
OrderID = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Sellers_OrderID",
|
||||
column: x => x.OrderID,
|
||||
principalTable: "Sellers",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductComponents",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentID = table.Column<int>(type: "int", nullable: false),
|
||||
ProductID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductComponents", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Components_ComponentID",
|
||||
column: x => x.ComponentID,
|
||||
principalTable: "Components",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Products_ProductID",
|
||||
column: x => x.ProductID,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Consignments",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
OrderID = table.Column<int>(type: "int", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
ProductID = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Consignments", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Consignments_Orders_OrderID",
|
||||
column: x => x.OrderID,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Consignments_Products_ProductID",
|
||||
column: x => x.ProductID,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ID");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Requests",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
OrderID = table.Column<int>(type: "int", nullable: false),
|
||||
PCID = table.Column<int>(type: "int", nullable: true),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Requests", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Requests_Orders_OrderID",
|
||||
column: x => x.OrderID,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConsignmentProducts",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ConsignmentID = table.Column<int>(type: "int", nullable: false),
|
||||
ProductID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConsignmentProducts", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConsignmentProducts_Consignments_ConsignmentID",
|
||||
column: x => x.ConsignmentID,
|
||||
principalTable: "Consignments",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConsignmentProducts_Products_ProductID",
|
||||
column: x => x.ProductID,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RequestComponents",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RequestID = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentID = table.Column<int>(type: "int", nullable: false),
|
||||
PCID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RequestComponents", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_RequestComponents_Components_ComponentID",
|
||||
column: x => x.ComponentID,
|
||||
principalTable: "Components",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
column: x => x.PCID,
|
||||
principalTable: "PCs",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RequestComponents_Requests_RequestID",
|
||||
column: x => x.RequestID,
|
||||
principalTable: "Requests",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConsignmentProducts_ConsignmentID",
|
||||
table: "ConsignmentProducts",
|
||||
column: "ConsignmentID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConsignmentProducts_ProductID",
|
||||
table: "ConsignmentProducts",
|
||||
column: "ProductID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Consignments_OrderID",
|
||||
table: "Consignments",
|
||||
column: "OrderID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Consignments_ProductID",
|
||||
table: "Consignments",
|
||||
column: "ProductID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_OrderID",
|
||||
table: "Orders",
|
||||
column: "OrderID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PCs_EmployeeID",
|
||||
table: "PCs",
|
||||
column: "EmployeeID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ComponentID",
|
||||
table: "ProductComponents",
|
||||
column: "ComponentID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ProductID",
|
||||
table: "ProductComponents",
|
||||
column: "ProductID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_EmployeeID",
|
||||
table: "Products",
|
||||
column: "EmployeeID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RequestComponents_ComponentID",
|
||||
table: "RequestComponents",
|
||||
column: "ComponentID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RequestComponents_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RequestComponents_RequestID",
|
||||
table: "RequestComponents",
|
||||
column: "RequestID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Requests_OrderID",
|
||||
table: "Requests",
|
||||
column: "OrderID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConsignmentProducts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Consignments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PCs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Requests");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sellers");
|
||||
}
|
||||
}
|
||||
}
|
499
ComputerStoreDatabaseImplement/Migrations/20230516114631_fieldFixes.Designer.cs
generated
Normal file
499
ComputerStoreDatabaseImplement/Migrations/20230516114631_fieldFixes.Designer.cs
generated
Normal file
@ -0,0 +1,499 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerStoreDatabase))]
|
||||
[Migration("20230516114631_fieldFixes")]
|
||||
partial class fieldFixes
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int?>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ConsignmentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConsignmentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ConsignmentProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SellerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("PCID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Sellers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_consignments")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Consignments")
|
||||
.HasForeignKey("ProductID");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("ConsignmentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Consignment");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Seller");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ConsignmentComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_requests")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RequestComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.PC", "PC")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("PCID");
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("PC");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ConsignmentComponents");
|
||||
|
||||
b.Navigation("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("_consignments");
|
||||
|
||||
b.Navigation("_requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class fieldFixes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "PCID",
|
||||
table: "RequestComponents",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID",
|
||||
principalTable: "PCs",
|
||||
principalColumn: "ID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "PCID",
|
||||
table: "RequestComponents",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID",
|
||||
principalTable: "PCs",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
496
ComputerStoreDatabaseImplement/Migrations/20230517142400_RelationFixes.Designer.cs
generated
Normal file
496
ComputerStoreDatabaseImplement/Migrations/20230517142400_RelationFixes.Designer.cs
generated
Normal file
@ -0,0 +1,496 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerStoreDatabase))]
|
||||
[Migration("20230517142400_RelationFixes")]
|
||||
partial class RelationFixes
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int?>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ConsignmentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConsignmentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ConsignmentProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SellerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("SellerID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("PCID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Sellers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_consignments")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Consignments")
|
||||
.HasForeignKey("ProductID");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("ConsignmentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Consignment");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SellerID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Seller");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ConsignmentComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_requests")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RequestComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.PC", "PC")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("PCID");
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("PC");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ConsignmentComponents");
|
||||
|
||||
b.Navigation("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("_consignments");
|
||||
|
||||
b.Navigation("_requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RelationFixes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Sellers_OrderID",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_OrderID",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "OrderID",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "PCID",
|
||||
table: "RequestComponents",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SellerID",
|
||||
table: "Orders",
|
||||
column: "SellerID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Sellers_SellerID",
|
||||
table: "Orders",
|
||||
column: "SellerID",
|
||||
principalTable: "Sellers",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID",
|
||||
principalTable: "PCs",
|
||||
principalColumn: "ID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Sellers_SellerID",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_SellerID",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "PCID",
|
||||
table: "RequestComponents",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "OrderID",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_OrderID",
|
||||
table: "Orders",
|
||||
column: "OrderID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Sellers_OrderID",
|
||||
table: "Orders",
|
||||
column: "OrderID",
|
||||
principalTable: "Sellers",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RequestComponents_PCs_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID",
|
||||
principalTable: "PCs",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
495
ComputerStoreDatabaseImplement/Migrations/20230517211626_RelationsFixesV7.Designer.cs
generated
Normal file
495
ComputerStoreDatabaseImplement/Migrations/20230517211626_RelationsFixesV7.Designer.cs
generated
Normal file
@ -0,0 +1,495 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerStoreDatabase))]
|
||||
[Migration("20230517211626_RelationsFixesV7")]
|
||||
partial class RelationsFixesV7
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int?>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ConsignmentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConsignmentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ConsignmentProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SellerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("SellerID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("PCS");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Sellers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_consignments")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Consignments")
|
||||
.HasForeignKey("ProductID");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("ConsignmentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Consignment");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SellerID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Seller");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PersonalComputers")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ConsignmentComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_requests")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RequestComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ConsignmentComponents");
|
||||
|
||||
b.Navigation("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("_consignments");
|
||||
|
||||
b.Navigation("_requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("PersonalComputers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RelationsFixesV7 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RequestComponents_PCS_PCID",
|
||||
table: "RequestComponents");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_RequestComponents_PCID",
|
||||
table: "RequestComponents");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RequestComponents_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RequestComponents_PCS_PCID",
|
||||
table: "RequestComponents",
|
||||
column: "PCID",
|
||||
principalTable: "PCS",
|
||||
principalColumn: "ID");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,492 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerStoreDatabase))]
|
||||
partial class ComputerStoreDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int?>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ConsignmentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConsignmentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ConsignmentProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SellerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("SellerID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("PCS");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ComponentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PCID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("RequestID");
|
||||
|
||||
b.ToTable("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Sellers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_consignments")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Consignments")
|
||||
.HasForeignKey("ProductID");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("ConsignmentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Consignment");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SellerID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Seller");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PersonalComputers")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ConsignmentComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("_requests")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RequestComponents")
|
||||
.HasForeignKey("ComponentID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
|
||||
.WithMany("PCs")
|
||||
.HasForeignKey("RequestID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ConsignmentComponents");
|
||||
|
||||
b.Navigation("RequestComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("_consignments");
|
||||
|
||||
b.Navigation("_requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Consignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Navigation("PCs");
|
||||
|
||||
b.Navigation("PersonalComputers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user