Compare commits
81 Commits
registrati
...
main
Author | SHA1 | Date | |
---|---|---|---|
82308fd351 | |||
af14af2496 | |||
4c0b6d983d | |||
62372eb2a4 | |||
83d1365b68 | |||
2f245da975 | |||
2f1866659c | |||
49853d94de | |||
24ac6da8cc | |||
47f012cfda | |||
8ed478c392 | |||
00af193095 | |||
146deadf89 | |||
6a6aabdf86 | |||
3f1d56bcfc | |||
fab303ad1d | |||
1dd2a00964 | |||
0d08c87f0b | |||
5678ff27d5 | |||
472b98ba57 | |||
a3390f0576 | |||
794931d97b | |||
464ab47941 | |||
8bb0d37211 | |||
5cf65ccdb2 | |||
882a46ba3b | |||
28437690c0 | |||
7776de448b | |||
5eaeef8528 | |||
eeec81593b | |||
e1673bca2c | |||
933a3bf3ea | |||
424703e397 | |||
57a28d9baf | |||
a1575b150d | |||
bca6631aab | |||
17403f4ce9 | |||
1fa7832bd7 | |||
489be1deb8 | |||
c716bda901 | |||
4f5c9f4b71 | |||
ebc61c5ef4 | |||
dfbbdb049a | |||
98de25531e | |||
b055d523bf | |||
8706337153 | |||
3c0bfa50ef | |||
5119290baa | |||
7938a755b7 | |||
93abfa5de5 | |||
d10d633a65 | |||
d2d51532a4 | |||
5dbfe140db | |||
5ab60a79f9 | |||
df6cabddb3 | |||
f8f28c3cfd | |||
da4de1eb95 | |||
8dc6f43608 | |||
cddde78b59 | |||
6d686b4851 | |||
ac6ab33e2c | |||
c87d686110 | |||
8a1732026c | |||
3525772c45 | |||
f1417ad554 | |||
b2b2922acf | |||
a42202f627 | |||
abe9f95aae | |||
3de3f75776 | |||
09a8d45482 | |||
3b5447e760 | |||
545ab2321e | |||
258dd5055d | |||
a2f733ce8e | |||
1c2130203d | |||
86a0b43a9a | |||
d0e0776717 | |||
cb37c8ab52 | |||
c113e8f1a7 | |||
05b0fb35d6 | |||
825ad31759 |
@ -11,13 +11,18 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BarCode" Version="2024.6.1" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="IronPrint" Version="2024.6.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
21
BusinessLogic/BusinessLogic/BarcodeLogic.cs
Normal file
21
BusinessLogic/BusinessLogic/BarcodeLogic.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Contracts.BindingModels;
|
||||
using IronBarCode;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class BarcodeLogic
|
||||
{
|
||||
public GeneratedBarcode CreateBarcode(ProductBindingModel model, bool save)
|
||||
{
|
||||
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128);
|
||||
var path = $"product{model.Id}.png";
|
||||
if (save) return barCode.SaveAsPng(path);
|
||||
return barCode;
|
||||
}
|
||||
}
|
||||
}
|
122
BusinessLogic/BusinessLogic/BillLogic.cs
Normal file
122
BusinessLogic/BusinessLogic/BillLogic.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using MigraDoc;
|
||||
using PdfSharp;
|
||||
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using PdfSharp.Pdf;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.ViewModels;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using BusinessLogic.Tools.Mail.MailTemplates;
|
||||
using BusinessLogic.Tools.Mail;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class BillLogic : IBillLogic
|
||||
{
|
||||
public void CreateBill(BillViewModel model)
|
||||
{
|
||||
string basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
string h1 = "АО \"21 guns\"";
|
||||
string h2 = "г. Ульяновск, ул. Северный Венец, 32";
|
||||
|
||||
Document document = new Document();
|
||||
|
||||
// Изменение стиля Normal для установки шрифта Arial по умолчанию для всего документа
|
||||
Style styleNormal = document.Styles["Normal"];
|
||||
styleNormal.Font.Name = "Arial";
|
||||
|
||||
//document.Info.Title = $"{model.PurchaseId}";
|
||||
Section section = document.AddSection();
|
||||
|
||||
section.PageSetup.PageFormat = PageFormat.A5;
|
||||
section.PageSetup.Orientation = Orientation.Portrait;
|
||||
section.PageSetup.BottomMargin = 10;
|
||||
section.PageSetup.TopMargin = 10;
|
||||
|
||||
Paragraph h1Paragraph = section.AddParagraph(); // Заголовок
|
||||
h1Paragraph.Format.Font.Bold = true;
|
||||
h1Paragraph.Format.Font.Size = 16;
|
||||
h1Paragraph.AddText(h1); // Текст заголовка
|
||||
|
||||
Paragraph h2Paragraph = section.AddParagraph();
|
||||
h2Paragraph.Format.Font.Bold = true;
|
||||
h2Paragraph.Format.Font.Size = 12;
|
||||
h2Paragraph.AddText(h2);
|
||||
|
||||
Paragraph userParagraph = section.AddParagraph();
|
||||
userParagraph.Format.Font.Size = 12;
|
||||
userParagraph.AddText("Покупатель: " + model.UserLastName + ' ' + model.UserFirstName + ' ' + model.UserId
|
||||
+ "\n" + "Чек отправлен на почту: " + model.UserEmail);
|
||||
|
||||
|
||||
Paragraph producth1Paragraph = section.AddParagraph();
|
||||
producth1Paragraph.Format.Font.Size = 16;
|
||||
producth1Paragraph.AddText("Товары:");
|
||||
|
||||
Paragraph productListParagraph = section.AddParagraph();
|
||||
productListParagraph.Format.Font.Size = 12;
|
||||
|
||||
Table table = section.AddTable();
|
||||
table.Style = "Table";
|
||||
table.Borders.Width = 0.75;
|
||||
|
||||
// Определение колонок
|
||||
Column columnProduct = table.AddColumn(Unit.FromCentimeter(1));
|
||||
columnProduct.Format.Alignment = ParagraphAlignment.Left;
|
||||
|
||||
Column columnPrice = table.AddColumn(Unit.FromCentimeter(1));
|
||||
columnPrice.Format.Alignment = ParagraphAlignment.Right;
|
||||
|
||||
// Добавление строк с товарами
|
||||
foreach (var product in model.Products)
|
||||
{
|
||||
Row row = table.AddRow();
|
||||
row.Cells[0].AddParagraph(product.Name);
|
||||
row.Cells[1].AddParagraph($"{product.ActualPrice} руб.");
|
||||
}
|
||||
|
||||
Paragraph totalParagraph = section.AddParagraph();
|
||||
totalParagraph.Format.Font.Size = 16;
|
||||
totalParagraph.Format.Font.Bold = true;
|
||||
totalParagraph.AddText("ИТОГ:");
|
||||
|
||||
Paragraph totalTextParagraph = section.AddParagraph();
|
||||
totalTextParagraph.Format.Font.Size = 16;
|
||||
totalTextParagraph.AddText(model.Count + " товаров на сумму " + model.Cost + " руб.");
|
||||
|
||||
|
||||
// Определение стилей для заголовков
|
||||
Style styleHeading1 = document.Styles["Heading1"];
|
||||
styleHeading1.Font.Name = "Arial";
|
||||
styleHeading1.Font.Size = 14;
|
||||
styleHeading1.Font.Bold = true;
|
||||
|
||||
Style styleHeading2 = document.Styles["Heading2"];
|
||||
styleHeading2.Font.Name = "Arial";
|
||||
styleHeading2.Font.Size = 12;
|
||||
styleHeading2.Font.Bold = true;
|
||||
|
||||
// Применение стилей к параграфам
|
||||
h1Paragraph.Style = "Heading1";
|
||||
h2Paragraph.Style = "Heading2";
|
||||
|
||||
|
||||
var pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
|
||||
pdfRenderer.Document = document;
|
||||
pdfRenderer.RenderDocument();
|
||||
|
||||
byte[] file = null;
|
||||
// Сохраняем PDF в MemoryStream вместо файла
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
pdfRenderer.PdfDocument.Save(stream);
|
||||
file = stream.ToArray();
|
||||
}
|
||||
|
||||
MailSender.Send(new MailBillSender(model.UserEmail, file));
|
||||
}
|
||||
}
|
||||
}
|
105
BusinessLogic/BusinessLogic/CartItemLogic.cs
Normal file
105
BusinessLogic/BusinessLogic/CartItemLogic.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class CartItemLogic : ICartItemLogic
|
||||
{
|
||||
private readonly ICartItemStorage _cartItemStorage;
|
||||
private readonly ILogger _logger;
|
||||
public CartItemLogic(ICartItemStorage cartItemStorage, ILogger<CartItemLogic> logger)
|
||||
{
|
||||
_cartItemStorage = cartItemStorage;
|
||||
_logger = logger;
|
||||
}
|
||||
public bool Create(CartItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_cartItemStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(CartItemBindingModel model)
|
||||
{
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_cartItemStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CartItemViewModel ReadElement(CartItemSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||
var element = _cartItemStorage.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<CartItemViewModel> ReadElements(CartItemSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _cartItemStorage.GetFullList() : _cartItemStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(CartItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_cartItemStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void CheckModel(CartItemBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ProductName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет категории", nameof(model.ProductName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Cart Item. Id: { Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
107
BusinessLogic/BusinessLogic/MediaFileLogic.cs
Normal file
107
BusinessLogic/BusinessLogic/MediaFileLogic.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class MediaFileLogic : IMediaFileLogic
|
||||
{
|
||||
private readonly IMediaFileStorage _mediafileStorage;
|
||||
private readonly ILogger _logger;
|
||||
public MediaFileLogic(IMediaFileStorage mediafileStorage, ILogger<MediaFileLogic> logger)
|
||||
{
|
||||
_mediafileStorage = mediafileStorage;
|
||||
_logger = logger;
|
||||
}
|
||||
public bool Create(MediaFileBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
_logger.LogInformation("Работа идёт нормально, криэйт в логике");
|
||||
if (_mediafileStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MediaFileBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_mediafileStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public MediaFileViewModel? ReadElement(MediaFileSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement .Id:{ Id}", model.Id);
|
||||
var element = _mediafileStorage.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<MediaFileViewModel>? ReadList(MediaFileSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _mediafileStorage.GetFullList() : _mediafileStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MediaFileBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_mediafileStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MediaFileBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.Image == null)
|
||||
{
|
||||
//throw new ArgumentNullException("Нет изображения", nameof(model.Name));
|
||||
}
|
||||
_logger.LogError("Проверка модели медиа файла выдала ошибку.");
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
}
|
||||
public bool Create(ProductBindingModel model)
|
||||
{
|
||||
|
||||
CheckModel(model);
|
||||
if (_productStorage.Insert(model) == null)
|
||||
{
|
||||
|
127
BusinessLogic/BusinessLogic/PurchaseLogic.cs
Normal file
127
BusinessLogic/BusinessLogic/PurchaseLogic.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.Converters;
|
||||
using Contracts.Exceptions;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Implements;
|
||||
using DatabaseImplement.Migrations;
|
||||
using DatabaseImplement.Models;
|
||||
using DataModels.Enums;
|
||||
using DataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class PurchaseLogic : IPurchaseLogic
|
||||
{
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
private readonly IProductStorage _productStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public PurchaseLogic(IPurchaseStorage purchaseStorage, IProductStorage productStorage, ILogger<PurchaseLogic> logger)
|
||||
{
|
||||
_purchaseStorage = purchaseStorage;
|
||||
_logger = logger;
|
||||
_productStorage = productStorage;
|
||||
|
||||
}
|
||||
|
||||
public PurchaseViewModel Create(PurchaseBindingModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
||||
var purchase = _purchaseStorage.Insert(model);
|
||||
if (purchase is null)
|
||||
{
|
||||
throw new Exception("Insert operation failed.");
|
||||
}
|
||||
|
||||
return purchase;
|
||||
}
|
||||
|
||||
public PurchaseViewModel Delete(PurchaseSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
||||
_logger.LogInformation("Delete purchase. Id: {0}", model.Id);
|
||||
var purchase = _purchaseStorage.Delete(model);
|
||||
if (purchase is null)
|
||||
{
|
||||
throw new Exception("Delete operation failed.");
|
||||
}
|
||||
|
||||
return purchase;
|
||||
|
||||
}
|
||||
|
||||
public PurchaseViewModel ReadElement(PurchaseSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
||||
_logger.LogInformation("ReadElement. Id: {0}", model.Id);
|
||||
var purchase = _purchaseStorage.GetElement(model);
|
||||
if (purchase is null)
|
||||
{
|
||||
throw new ElementNotFoundException();
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id: {0}", purchase.Id);
|
||||
|
||||
return purchase;
|
||||
|
||||
}
|
||||
|
||||
public List<PurchaseViewModel> ReadElements(PurchaseSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var purchase_list = model == null ? _purchaseStorage.GetFullList(model) : _purchaseStorage.GetFilteredList(model);
|
||||
if (purchase_list is null || purchase_list.Count() == 0)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return [];
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", purchase_list.Count());
|
||||
|
||||
return purchase_list;
|
||||
|
||||
}
|
||||
|
||||
public PurchaseViewModel Update(PurchaseBindingModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
||||
var purchase = _purchaseStorage.Update(model);
|
||||
if (purchase is null)
|
||||
{
|
||||
throw new Exception("Update operation failed.");
|
||||
}
|
||||
return purchase;
|
||||
}
|
||||
public List<CartItemViewModel> GetCartItems(PurchaseSearchModel model)
|
||||
{
|
||||
var items = _purchaseStorage.GetCartItems(model);
|
||||
if (items is null)
|
||||
{
|
||||
throw new Exception("Get operation failed.");
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetProducts(PurchaseSearchModel model)
|
||||
{
|
||||
var products = _purchaseStorage.GetProducts(model);
|
||||
if (products is null)
|
||||
{
|
||||
throw new Exception("Get operation failed.");
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
104
BusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
104
BusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using BusinessLogic.OfficePackage;
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using Contracts.SearchModels;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IProductStorage _productStorage;
|
||||
private readonly ISupplyStorage _supplyStorage;
|
||||
private readonly IMediaFileStorage _mediaFileStorage;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
private readonly AbstractSaveToPdfCheque _saveToCheque;
|
||||
private readonly AbstractSaveToPdfPricelist _savePricelist;
|
||||
public ReportLogic(IProductStorage productStorage, ISupplyStorage supplyStorage, AbstractSaveToPdf saveToPdf, AbstractSaveToPdfCheque saveToPdfCheque, IMediaFileStorage mediaFileStorage, AbstractSaveToPdfPricelist savePricelist)
|
||||
{
|
||||
_productStorage = productStorage;
|
||||
_supplyStorage = supplyStorage;
|
||||
_saveToPdf = saveToPdf;
|
||||
_saveToCheque = saveToPdfCheque;
|
||||
_mediaFileStorage = mediaFileStorage;
|
||||
_savePricelist = savePricelist;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ReportSupplyProductViewModel> GetSupplyProduct()
|
||||
{
|
||||
var products = _productStorage.GetFullList();
|
||||
var supplies = _supplyStorage.GetFullList();
|
||||
var list = new List<ReportSupplyProductViewModel>();
|
||||
foreach (var supply in supplies)
|
||||
{
|
||||
var record = new ReportSupplyProductViewModel
|
||||
{
|
||||
SupplyName = supply.Name,
|
||||
Products = new List<Tuple<string, int>>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (supply.Products.ContainsKey(product.Id))
|
||||
{
|
||||
record.Products.Add(new Tuple<string, int>(product.Name, supply.Products[product.Id].Item2));
|
||||
record.TotalCount += supply.Products[product.Id].Item2;
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveSuppliesToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Накладная",
|
||||
Date = model.Date!.Value,
|
||||
Supply = _supplyStorage.GetElement(new SupplySearchModel()
|
||||
{
|
||||
Id = model.SupplyId,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveProductToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToCheque.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Чек на товар",
|
||||
Product = _productStorage.GetElement(new ProductSearchModel()
|
||||
{
|
||||
Id = model.ProductId
|
||||
}),
|
||||
//MediaFiles = _mediaFileStorage.GetFilteredList(new MediaFileSearchModel() { ProductId = model.ProductId })
|
||||
});
|
||||
}
|
||||
public void SavePriceListToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_savePricelist.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Прайс-лист",
|
||||
Date = model.Date,
|
||||
Products = _productStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
116
BusinessLogic/BusinessLogic/SaleLogic.cs
Normal file
116
BusinessLogic/BusinessLogic/SaleLogic.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SaleLogic : ISaleLogic
|
||||
{
|
||||
private readonly ISaleStorage _saleStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SaleLogic(ISaleStorage saleStorage, ILogger<SaleLogic> logger)
|
||||
{
|
||||
_saleStorage = saleStorage;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public bool Create(SaleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_saleStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(SaleBindingModel model)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_saleStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public SaleViewModel ReadElement(SaleSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||
var element = _saleStorage.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<SaleViewModel> ReadElements(SaleSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _saleStorage.GetFullList() : _saleStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(SaleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_saleStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void CheckModel(SaleBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Category))
|
||||
{
|
||||
throw new ArgumentNullException("Нет категории", nameof(model.Category));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Sale. Id: { Id}", model.Id);
|
||||
var element = _saleStorage.GetElement(new SaleSearchModel
|
||||
{
|
||||
Description = model.Description
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Акция с таким описанием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
80
BusinessLogic/BusinessLogic/SellLogic.cs
Normal file
80
BusinessLogic/BusinessLogic/SellLogic.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.Converters;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SellLogic : ISellLogic
|
||||
{
|
||||
private readonly ISellStorage _sellStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SellLogic(ISellStorage sellStorage, ILogger<SellLogic> logger)
|
||||
{
|
||||
_sellStorage = sellStorage;
|
||||
_logger = logger;
|
||||
}
|
||||
public SellViewModel Create(SellBindingModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
var sell = _sellStorage.Insert(model);
|
||||
if (sell is null)
|
||||
{
|
||||
throw new Exception("Insert operation failed.");
|
||||
}
|
||||
return sell;
|
||||
}
|
||||
public SellViewModel ReadElement(SellSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
var sell = _sellStorage.GetElement(model);
|
||||
if (sell is null)
|
||||
{
|
||||
throw new Exception("Get element operation failed.");
|
||||
}
|
||||
return sell;
|
||||
}
|
||||
|
||||
public IEnumerable<SellViewModel> ReadElements(SellSearchModel? model)
|
||||
{
|
||||
var sell_list = _sellStorage.GetFullList(model);
|
||||
if (sell_list is null || sell_list.Count() == 0)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return [];
|
||||
}
|
||||
return sell_list;
|
||||
}
|
||||
|
||||
public SellViewModel Update(SellSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
var sell = _sellStorage.GetElement(model);
|
||||
if (sell is null)
|
||||
{
|
||||
throw new Exception("Update operation failed.");
|
||||
}
|
||||
return sell;
|
||||
}
|
||||
public SellViewModel Delete(SellSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
var sell = _sellStorage.Delete(model);
|
||||
if (sell is null)
|
||||
{
|
||||
throw new Exception("Update operation failed.");
|
||||
}
|
||||
return sell;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using Contracts.BusinessLogicContracts;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -101,5 +102,30 @@ namespace BusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException("Нет названия поставки", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public bool StatusUpdate(SupplyBindingModel model, SupplyStatus newStatus)
|
||||
{
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Supply status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (newStatus == SupplyStatus.Arriving)
|
||||
{
|
||||
model.DateArriving = DateTime.UtcNow;
|
||||
}
|
||||
if (newStatus == SupplyStatus.Completed)
|
||||
{
|
||||
model.DateComplete = DateTime.UtcNow;
|
||||
}
|
||||
if (_supplyStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,5 +181,10 @@ namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
return _twoFactorAuthService.Verify(code);
|
||||
}
|
||||
|
||||
public void UpdateBonus(BonusUpdateBindingModel model)
|
||||
{
|
||||
_userStorage.UpdateBonus(model);
|
||||
}
|
||||
}
|
||||
}
|
80
BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
80
BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using BusinessLogic.BusinessLogic;
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"{info.Title}\nОт {DateTime.UtcNow}",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
string dateArriving = info.Supply.DateArriving.HasValue ? info.Supply.DateArriving.ToString() : "-";
|
||||
string dateComplete = info.Supply.DateComplete.HasValue ? info.Supply.DateComplete.ToString() : "-";
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Поставщик: {info.Supply.SupplierName}\nДата создания поставки: {info.Supply.Date}\nДата отправления поставки: {dateArriving}\nДата получения поставки: {dateComplete}\nСтатус: {info.Supply.Status}",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
CreateTable(new List<string> { "5cm", "10cm"});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Id", "Информация" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { info.Supply.Id.ToString(), info.Supply.Name, },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = "Товары",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var product in info.Supply.Products.Values)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { product.Item1.Id.ToString(), product.Item1.Name, product.Item1.Price.ToString(), product.Item2.ToString() },
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Supply.Price.ToString("0.00")} руб.",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void CreateImage(string path);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
57
BusinessLogic/OfficePackage/AbstractSaveToPdfCheque.cs
Normal file
57
BusinessLogic/OfficePackage/AbstractSaveToPdfCheque.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfCheque
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"{info.Title}\n{info.Product.Name}",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Id: {info.Product.Id}",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
//CreateParagraph(new PdfParagraph
|
||||
//{
|
||||
// Text = "Список прилагаемых файлов",
|
||||
// Style = "NormalTitle",
|
||||
// ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
//});
|
||||
//CreateTable(new List<string> { "10cm", "5cm" });
|
||||
//CreateRow(new PdfRowParameters
|
||||
//{
|
||||
// Texts = new List<string> { "Название", "расширение" },
|
||||
// Style = "NormalTitle",
|
||||
// ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
//});
|
||||
CreateImage($"product{info.Product.Id}.png");
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Цена: {info.Product.Price.ToString("0.00")} руб.",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void CreateImage(string path);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
51
BusinessLogic/OfficePackage/AbstractSaveToPdfPricelist.cs
Normal file
51
BusinessLogic/OfficePackage/AbstractSaveToPdfPricelist.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdfPricelist
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"{info.Title}\nОт {info.Date}",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = "Товары",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во на складе" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var product in info.Products)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { product.Id.ToString(), product.Name, product.Price.ToString(), product.Amount.ToString() },
|
||||
});
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void CreateImage(string path);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
20
BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
20
BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime? Date { get; set; }
|
||||
public SupplyViewModel? Supply { get; set; } = new();
|
||||
public ProductViewModel? Product { get; set; } = new();
|
||||
public List<MediaFileViewModel>? MediaFiles { get; set; } = new();
|
||||
public List<ProductViewModel>? Products { get; set; } = new();
|
||||
}
|
||||
}
|
16
BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
Normal file
16
BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
16
BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
Normal file
16
BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
111
BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
111
BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdf : AbstractSaveToPdf
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private Image _image;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment =
|
||||
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void CreateImage(string path)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_document.LastSection.AddImage(path);
|
||||
}
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
118
BusinessLogic/OfficePackage/Implements/SaveToPdfCheque.cs
Normal file
118
BusinessLogic/OfficePackage/Implements/SaveToPdfCheque.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using PdfSharp.Drawing;
|
||||
using PdfSharp.Pdf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfCheque : AbstractSaveToPdfCheque
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private PdfPage? _page;
|
||||
private Table? _table;
|
||||
private Image _image;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment =
|
||||
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void CreateImage(string path)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_document.LastSection.AddImage(path);
|
||||
}
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
115
BusinessLogic/OfficePackage/Implements/SaveToPdfPricelist.cs
Normal file
115
BusinessLogic/OfficePackage/Implements/SaveToPdfPricelist.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using BusinessLogic.OfficePackage.HelperEnums;
|
||||
using BusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdfPricelist : AbstractSaveToPdfPricelist
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
private Image _image;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = _table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment =
|
||||
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
protected override void CreateImage(string path)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_document.LastSection.AddImage(path);
|
||||
}
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -12,5 +13,6 @@ namespace BusinessLogic.Tools.Mail
|
||||
public string Title { get; set; } = null!;
|
||||
public string Body { get; set; } = null!;
|
||||
public bool IsSendable { get; set; } = true;
|
||||
public List<Attachment>? Attachments { get; set; } = new List<Attachment>();
|
||||
}
|
||||
}
|
@ -42,6 +42,11 @@ namespace BusinessLogic.Tools.Mail
|
||||
message.Subject = mail.Title;
|
||||
message.Body = mail.Body;
|
||||
|
||||
foreach (var attachment in mail.Attachments)
|
||||
{
|
||||
message.Attachments.Add(attachment);
|
||||
}
|
||||
|
||||
client.Send(message);
|
||||
}
|
||||
}
|
||||
|
28
BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs
Normal file
28
BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Contracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DatabaseImplement.Models;
|
||||
|
||||
namespace BusinessLogic.Tools.Mail.MailTemplates
|
||||
{
|
||||
public class MailBillSender : Mail
|
||||
{
|
||||
public MailBillSender(string recipientEmail, byte[] invoicePdfBytes)
|
||||
{
|
||||
To = [recipientEmail];
|
||||
Title = "Ваш чек";
|
||||
Body = "";
|
||||
|
||||
// Создаем MemoryStream из байтового массива инвойса
|
||||
var memoryStream = new MemoryStream(invoicePdfBytes);
|
||||
// Создаем Attachment, используя MemoryStream
|
||||
var attachment = new Attachment(memoryStream, "invoice.pdf", "application/pdf");
|
||||
Attachments.Add(attachment);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ namespace BusinessLogic.Tools.Mail.MailTemplates
|
||||
Title = "Ваш код для подтверждения";
|
||||
Body = $"Здравствуйте, {user.SecondName} {user.FirstName}! Вот Ваш код для подтверждения:\n" +
|
||||
$"{code}\n" +
|
||||
$"Если это не Вы, игноритруйте это сообщение.";
|
||||
$"Если это не Вы, игнорируйте это сообщение.";
|
||||
}
|
||||
}
|
||||
}
|
15
Contracts/BindingModels/BonusUpdateBindingModel.cs
Normal file
15
Contracts/BindingModels/BonusUpdateBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class BonusUpdateBindingModel
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public int BonusPlus { get; set; }
|
||||
public int BonusMinus { get; set; }
|
||||
}
|
||||
}
|
20
Contracts/BindingModels/CartItemBindingModel.cs
Normal file
20
Contracts/BindingModels/CartItemBindingModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class CartItemBindingModel : ICartItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public DateTime DateCreated { get; set; }
|
||||
public int Count { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid? PurchaseId { get; set; }
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ namespace Contracts.BindingModels
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Location { get; set; } = string.Empty;
|
||||
public required byte[] Image { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,8 @@ namespace Contracts.BindingModels
|
||||
public int Amount { get; set; }
|
||||
public bool IsBeingSold { get; set; }
|
||||
public double Rate { get; set; }
|
||||
}
|
||||
public string? Description { get; set; }
|
||||
public string? Category { get; set; }
|
||||
public Guid? SaleId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using DataModels.Enums;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -9,6 +11,12 @@ namespace Contracts.BindingModels
|
||||
public class PurchaseBindingModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTime DatePurchase { get; set; }
|
||||
}
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTime? DateClosed { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public PurchaseStatus Status { get; set; }
|
||||
public int ProductCount { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public bool IsPaid { get; set; }
|
||||
}
|
||||
}
|
||||
|
16
Contracts/BindingModels/ReportBindingModel.cs
Normal file
16
Contracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? Date { get; set; }
|
||||
public Guid? SupplyId { get; set; }
|
||||
public Guid? ProductId { get; set; }
|
||||
}
|
||||
}
|
21
Contracts/BindingModels/SaleBindingModel.cs
Normal file
21
Contracts/BindingModels/SaleBindingModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class SaleBindingModel : ISale
|
||||
{
|
||||
public string Category { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string FullDescription { get; set; } = string.Empty;
|
||||
public DateTime Start { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int Value { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -10,5 +11,7 @@ namespace Contracts.BindingModels
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTime DateSell { get; set; }
|
||||
}
|
||||
public Guid? UserId { get; set; }
|
||||
public Dictionary<Guid, (IProduct, int)> SellProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ namespace Contracts.BindingModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Guid SupplierId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime? DateArriving { get; set; }
|
||||
public DateTime? DateComplete { get; set; }
|
||||
public double Price { get; set; }
|
||||
public SupplyStatus Status { get; set; }
|
||||
public Dictionary<Guid, (IProduct, int)> SupplyProducts { get; set; } = new();
|
||||
|
@ -17,5 +17,6 @@ namespace Contracts.BindingModels
|
||||
public DateTime Birthday { get; set; }
|
||||
public bool OnlyImportantMails { get; set; }
|
||||
public RoleBindingModel Role { get; set; } = null!;
|
||||
public int Bonus { get; set; }
|
||||
}
|
||||
}
|
14
Contracts/BusinessLogicContracts/IBillLogic.cs
Normal file
14
Contracts/BusinessLogicContracts/IBillLogic.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IBillLogic
|
||||
{
|
||||
void CreateBill(BillViewModel model);
|
||||
}
|
||||
}
|
24
Contracts/BusinessLogicContracts/ICartItemLogic.cs
Normal file
24
Contracts/BusinessLogicContracts/ICartItemLogic.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ICartItemLogic
|
||||
{
|
||||
bool Create(CartItemBindingModel model);
|
||||
|
||||
bool Update(CartItemBindingModel model);
|
||||
|
||||
CartItemViewModel ReadElement(CartItemSearchModel model);
|
||||
|
||||
List<CartItemViewModel> ReadElements(CartItemSearchModel? model);
|
||||
|
||||
bool Delete(CartItemBindingModel model);
|
||||
}
|
||||
}
|
20
Contracts/BusinessLogicContracts/IMediaFileLogic.cs
Normal file
20
Contracts/BusinessLogicContracts/IMediaFileLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IMediaFileLogic
|
||||
{
|
||||
bool Create(MediaFileBindingModel model);
|
||||
bool Update(MediaFileBindingModel model);
|
||||
bool Delete(MediaFileBindingModel model);
|
||||
List<MediaFileViewModel>? ReadList(MediaFileSearchModel? model);
|
||||
MediaFileViewModel? ReadElement(MediaFileSearchModel model);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -17,8 +18,10 @@ namespace Contracts.BusinessLogicContracts
|
||||
|
||||
PurchaseViewModel ReadElement(PurchaseSearchModel model);
|
||||
|
||||
IEnumerable<PurchaseViewModel> ReadElements(PurchaseSearchModel? model);
|
||||
List<PurchaseViewModel> ReadElements(PurchaseSearchModel? model);
|
||||
|
||||
PurchaseViewModel Delete(PurchaseSearchModel model);
|
||||
}
|
||||
List<CartItemViewModel> GetCartItems(PurchaseSearchModel model);
|
||||
List<ProductViewModel> GetProducts(PurchaseSearchModel model);
|
||||
}
|
||||
}
|
||||
|
26
Contracts/BusinessLogicContracts/IReportLogic.cs
Normal file
26
Contracts/BusinessLogicContracts/IReportLogic.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportSupplyProductViewModel> GetSupplyProduct();
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveSuppliesToPdfFile(ReportBindingModel model);
|
||||
void SaveProductToPdfFile(ReportBindingModel model);
|
||||
void SavePriceListToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
24
Contracts/BusinessLogicContracts/ISaleLogic.cs
Normal file
24
Contracts/BusinessLogicContracts/ISaleLogic.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISaleLogic
|
||||
{
|
||||
bool Create(SaleBindingModel model);
|
||||
|
||||
bool Update(SaleBindingModel model);
|
||||
|
||||
SaleViewModel ReadElement(SaleSearchModel model);
|
||||
|
||||
List<SaleViewModel> ReadElements(SaleSearchModel? model);
|
||||
|
||||
bool Delete(SaleBindingModel model);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
SellViewModel Create(SellBindingModel model);
|
||||
|
||||
SellViewModel Update(SellBindingModel model);
|
||||
SellViewModel Update(SellSearchModel model);
|
||||
|
||||
SellViewModel ReadElement(SellSearchModel model);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -16,5 +17,6 @@ namespace Contracts.BusinessLogicContracts
|
||||
bool Create(SupplyBindingModel model);
|
||||
bool Update(SupplyBindingModel model);
|
||||
bool Delete(SupplyBindingModel model);
|
||||
bool StatusUpdate(SupplyBindingModel model, SupplyStatus status);
|
||||
}
|
||||
}
|
||||
|
@ -25,5 +25,6 @@ namespace Contracts.BusinessLogicContracts
|
||||
IEnumerable<UserViewModel> ReadElements(UserSearchModel? model);
|
||||
|
||||
UserViewModel Delete(UserSearchModel model);
|
||||
void UpdateBonus(BonusUpdateBindingModel model);
|
||||
}
|
||||
}
|
33
Contracts/Converters/PurchaseConverter.cs
Normal file
33
Contracts/Converters/PurchaseConverter.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.Converters
|
||||
{
|
||||
public class PurchaseConverter
|
||||
{
|
||||
public static PurchaseViewModel ToView(PurchaseBindingModel model) => new()
|
||||
{
|
||||
Id = model.Id,
|
||||
DateCreated = model.DateCreated,
|
||||
UserId = model.UserId,
|
||||
Status = model.Status,
|
||||
ProductCount = model.ProductCount,
|
||||
Cost = model.Cost
|
||||
};
|
||||
|
||||
public static PurchaseBindingModel ToBinding(PurchaseViewModel model) => new()
|
||||
{
|
||||
Id = model.Id,
|
||||
DateCreated = model.DateCreated,
|
||||
UserId = model.UserId,
|
||||
Status = model.Status,
|
||||
ProductCount = model.ProductCount,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ namespace Contracts.Converters
|
||||
Birthday = model.Birthday,
|
||||
OnlyImportantMails = model.OnlyImportantMails,
|
||||
Role = RoleConverter.ToView(model.Role),
|
||||
Bonus = model.Bonus,
|
||||
};
|
||||
|
||||
public static UserBindingModel ToBinding(UserViewModel model) => new()
|
||||
@ -30,6 +31,7 @@ namespace Contracts.Converters
|
||||
Birthday = model.Birthday,
|
||||
OnlyImportantMails = model.OnlyImportantMails,
|
||||
Role = RoleConverter.ToBinding(model.Role),
|
||||
Bonus = model.Bonus,
|
||||
};
|
||||
}
|
||||
}
|
16
Contracts/SearchModels/CartItemSearchModel.cs
Normal file
16
Contracts/SearchModels/CartItemSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class CartItemSearchModel
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public Guid? ProductId { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
}
|
@ -11,8 +11,11 @@ namespace Contracts.SearchModels
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public double? Price { get; set; }
|
||||
public double? Rate { get; set; }
|
||||
public double? PriceFrom { get; set; }
|
||||
public double? PriceTo { get; set; }
|
||||
public double? Rate { get; set; }
|
||||
public int? Amount { get; set; }
|
||||
public bool? IsBeingSold { get; set; }
|
||||
public string? Category { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ namespace Contracts.SearchModels
|
||||
public Guid? Id { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public double? PriceFrom { get; set; }
|
||||
public double? PriceTo { get; set; }
|
||||
public double? CostFrom { get; set; }
|
||||
public double? CostTo { get; set; }
|
||||
public PurchaseStatus? Status { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
15
Contracts/SearchModels/SaleSearchModel.cs
Normal file
15
Contracts/SearchModels/SaleSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class SaleSearchModel
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Category { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
21
Contracts/StorageContracts/ICartItemStorage.cs
Normal file
21
Contracts/StorageContracts/ICartItemStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.StorageContracts
|
||||
{
|
||||
public interface ICartItemStorage
|
||||
{
|
||||
List<CartItemViewModel> GetFullList();
|
||||
List<CartItemViewModel> GetFilteredList(CartItemSearchModel model);
|
||||
CartItemViewModel? GetElement(CartItemSearchModel model);
|
||||
CartItemViewModel? Insert(CartItemBindingModel model);
|
||||
CartItemViewModel? Update(CartItemBindingModel model);
|
||||
CartItemViewModel? Delete(CartItemBindingModel model);
|
||||
}
|
||||
}
|
21
Contracts/StorageContracts/IMediaFileStorage.cs
Normal file
21
Contracts/StorageContracts/IMediaFileStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.StorageContracts
|
||||
{
|
||||
public interface IMediaFileStorage
|
||||
{
|
||||
List<MediaFileViewModel> GetFullList();
|
||||
List<MediaFileViewModel> GetFilteredList(MediaFileSearchModel model);
|
||||
MediaFileViewModel? GetElement(MediaFileSearchModel model);
|
||||
MediaFileViewModel? Insert(MediaFileBindingModel model);
|
||||
MediaFileViewModel? Update(MediaFileBindingModel model);
|
||||
MediaFileViewModel? Delete(MediaFileBindingModel model);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,14 +12,17 @@ namespace Contracts.StorageContracts
|
||||
{
|
||||
public interface IPurchaseStorage
|
||||
{
|
||||
PurchaseBindingModel? Insert(PurchaseBindingModel model);
|
||||
PurchaseViewModel? Insert(PurchaseBindingModel model);
|
||||
|
||||
IEnumerable<PurchaseBindingModel> GetList(PurchaseSearchModel? model);
|
||||
List<PurchaseViewModel> GetFullList(PurchaseSearchModel? model);
|
||||
List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model);
|
||||
|
||||
PurchaseBindingModel? GetElement(PurchaseSearchModel model);
|
||||
PurchaseViewModel? GetElement(PurchaseSearchModel model);
|
||||
|
||||
PurchaseBindingModel? Update(PurchaseBindingModel model);
|
||||
PurchaseViewModel? Update(PurchaseBindingModel model);
|
||||
|
||||
PurchaseBindingModel? Delete(PurchaseSearchModel model);
|
||||
}
|
||||
PurchaseViewModel? Delete(PurchaseSearchModel model);
|
||||
List<CartItemViewModel> GetCartItems(PurchaseSearchModel purchaseModel);
|
||||
List<ProductViewModel> GetProducts(PurchaseSearchModel model);
|
||||
}
|
||||
}
|
||||
|
21
Contracts/StorageContracts/ISaleStorage.cs
Normal file
21
Contracts/StorageContracts/ISaleStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.StorageContracts
|
||||
{
|
||||
public interface ISaleStorage
|
||||
{
|
||||
List<SaleViewModel> GetFullList();
|
||||
List<SaleViewModel> GetFilteredList(SaleSearchModel model);
|
||||
SaleViewModel? GetElement(SaleSearchModel model);
|
||||
SaleViewModel? Insert(SaleBindingModel model);
|
||||
SaleViewModel? Update(SaleBindingModel model);
|
||||
SaleViewModel? Delete(SaleBindingModel model);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,14 +11,15 @@ namespace Contracts.StorageContracts
|
||||
{
|
||||
public interface ISellStorage
|
||||
{
|
||||
SellBindingModel? Insert(SellBindingModel model);
|
||||
SellViewModel? Insert(SellBindingModel model);
|
||||
|
||||
IEnumerable<SellBindingModel> GetList(SellSearchModel? model);
|
||||
IEnumerable<SellViewModel> GetFullList(SellSearchModel? model);
|
||||
IEnumerable<SellViewModel> GetFilteredList(SellSearchModel? model);
|
||||
|
||||
SellBindingModel? GetElement(SellSearchModel model);
|
||||
SellViewModel? GetElement(SellSearchModel model);
|
||||
|
||||
SellBindingModel? Update(SellBindingModel model);
|
||||
SellViewModel? Update(SellBindingModel model);
|
||||
|
||||
SellBindingModel? Delete(SellSearchModel model);
|
||||
SellViewModel? Delete(SellSearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ namespace Contracts.StorageContracts
|
||||
List<SupplyViewModel> GetFullList();
|
||||
List<SupplyViewModel> GetFilteredList(SupplySearchModel model);
|
||||
SupplyViewModel? GetElement(SupplySearchModel model);
|
||||
SupplyViewModel? Insert(SupplyBindingModel model);
|
||||
SupplyViewModel? Update(SupplyBindingModel model);
|
||||
bool? Insert(SupplyBindingModel model);
|
||||
bool? Update(SupplyBindingModel model);
|
||||
SupplyViewModel? Delete(SupplyBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,7 @@ namespace Contracts.StorageContracts
|
||||
UserBindingModel? Update(UserBindingModel model);
|
||||
|
||||
UserBindingModel? Delete(UserSearchModel model);
|
||||
}
|
||||
void UpdateBonus(BonusUpdateBindingModel model);
|
||||
|
||||
}
|
||||
}
|
22
Contracts/ViewModels/BillViewModel.cs
Normal file
22
Contracts/ViewModels/BillViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class BillViewModel
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public Guid PurchaseId { get; set; }
|
||||
public List<ProductViewModel> Products { get; set; } = new List<ProductViewModel>();
|
||||
public int Count { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreated { get; set; }
|
||||
public string UserFirstName { get; set; } = string.Empty;
|
||||
public string UserLastName { get; set; } = string.Empty;
|
||||
public string UserEmail { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
21
Contracts/ViewModels/CartItemViewModel.cs
Normal file
21
Contracts/ViewModels/CartItemViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class CartItemViewModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public DateTime DateCreated { get; set; }
|
||||
public int Count { get; set; }
|
||||
public Guid? PurchaseId { get; set; }
|
||||
}
|
||||
}
|
@ -5,22 +5,22 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class MediaFileViewModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Location { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public required byte[] Image { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public MediaFileBindingModel GetBindingModel()
|
||||
{
|
||||
return new MediaFileBindingModel
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Location = Location,
|
||||
Image = Image,
|
||||
ProductId = ProductId
|
||||
};
|
||||
}
|
||||
|
19
Contracts/ViewModels/PaymentViewModel.cs
Normal file
19
Contracts/ViewModels/PaymentViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class PaymentViewModel
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public string UserFirstName { get; set; } = string.Empty;
|
||||
public string UserSecondName { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public int ProductCount { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public int? Bonus { get; set; }
|
||||
}
|
||||
}
|
@ -7,14 +7,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class ProductViewModel
|
||||
public class ProductViewModel : IProduct
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public double Rating { get; set; }
|
||||
public double ActualPrice { get; set; }
|
||||
public double Rate { get; set; }
|
||||
public bool IsBeingSold { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public string? Category { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public List<MediaFileViewModel> MediaFiles { get; set; } = new();
|
||||
public Guid? SaleId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,12 @@ namespace Contracts.ViewModels
|
||||
public class PurchaseViewModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTime DatePurchase { get; set; }
|
||||
public required IUser User { get; set; }
|
||||
public required List<IProduct> Products { get; set; }
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTime? DateClosed { get; set; }
|
||||
public required Guid UserId { get; set; }
|
||||
public PurchaseStatus Status { get; set; }
|
||||
}
|
||||
public int ProductCount { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public bool IsPaid { get; set; }
|
||||
}
|
||||
}
|
||||
|
15
Contracts/ViewModels/ReportSupplyProductViewModel.cs
Normal file
15
Contracts/ViewModels/ReportSupplyProductViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class ReportSupplyProductViewModel
|
||||
{
|
||||
public string SupplyName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<Tuple<string, int>> Products { get; set; } = new();
|
||||
}
|
||||
}
|
17
Contracts/ViewModels/ReportSupplyViewModel.cs
Normal file
17
Contracts/ViewModels/ReportSupplyViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class ReportSupplyViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public String Status { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
21
Contracts/ViewModels/SaleViewModel.cs
Normal file
21
Contracts/ViewModels/SaleViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class SaleViewModel : ISale
|
||||
{
|
||||
public string Category { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string FullDescription { get; set; } = string.Empty;
|
||||
public DateTime Start { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int Value { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace Contracts.ViewModels
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTime DateSell { get; set; }
|
||||
public ISupplyDoc? SupplyDoc { get; set; }
|
||||
}
|
||||
public Guid? UserId { get; set; }
|
||||
public Dictionary<Guid, (IProduct, int)> SellProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace Contracts.ViewModels
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int Deals { get; set; }
|
||||
public Dictionary<Guid, (IProduct, int)> AvailibleProducts = new();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ namespace Contracts.ViewModels
|
||||
public double Price { get; set; }
|
||||
public Dictionary<Guid, (IProduct, int)> Products { get; set; } = new();
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime? DateArriving { get; set; }
|
||||
public DateTime? DateComplete { get; set; }
|
||||
public SupplyStatus Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace Contracts.ViewModels
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public double Rate { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public double Rate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ namespace Contracts.ViewModels
|
||||
public DateTime Birthday { get; set; }
|
||||
public bool OnlyImportantMails { get; set; }
|
||||
public RoleViewModel Role { get; set; } = null!;
|
||||
public int Bonus { get; set; }
|
||||
}
|
||||
}
|
17
DataModels/Models/ICartItem.cs
Normal file
17
DataModels/Models/ICartItem.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface ICartItem : IId
|
||||
{
|
||||
Guid UserId { get; }
|
||||
int Count { get; }
|
||||
DateTime DateCreated { get; set; }
|
||||
Guid ProductId { get; set; }
|
||||
string ProductName { get; set; }
|
||||
}
|
||||
}
|
@ -8,8 +8,7 @@ namespace DataModels.Models
|
||||
{
|
||||
public interface IMediaFile : IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Location { get; }
|
||||
byte[] Image { get; }
|
||||
Guid ProductId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace DataModels.Models
|
||||
bool IsBeingSold { get; }
|
||||
public double Rate { get; }
|
||||
int Amount { get; }
|
||||
// будут браться через mediafilestorage так что скорее всего это тут не надо
|
||||
// List<IMediaFile> MediaFiles { get; }
|
||||
string Category { get; }
|
||||
string Description { get; }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,11 @@ namespace DataModels.Models
|
||||
{
|
||||
public interface IPurchase : IId
|
||||
{
|
||||
DateTime DatePurchase { get; }
|
||||
PurchaseStatus Status { get; }
|
||||
DateTime DateCreated { get; }
|
||||
DateTime? DateClosed { get; }
|
||||
PurchaseStatus Status { get; }
|
||||
int ProductCount { get; }
|
||||
double Cost { get; }
|
||||
bool IsPaid { get; }
|
||||
}
|
||||
}
|
||||
|
19
DataModels/Models/ISale.cs
Normal file
19
DataModels/Models/ISale.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface ISale : IId
|
||||
{
|
||||
public string Category { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string FullDescription { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Value { get; set; }
|
||||
public DateTime Start { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ namespace DataModels.Models
|
||||
double Price { get; }
|
||||
Guid SupplierId { get; }
|
||||
DateTime Date { get; }
|
||||
DateTime? DateArriving { get; }
|
||||
DateTime? DateComplete { get; }
|
||||
SupplyStatus Status { get; }
|
||||
Dictionary<Guid, (IProduct, int)> SupplyProducts { get; }
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ namespace DataModels.Models
|
||||
string Email { get; }
|
||||
DateTime Birthday { get; }
|
||||
bool OnlyImportantMails { get; }
|
||||
int Bonus { get; }
|
||||
}
|
||||
}
|
@ -14,12 +14,14 @@ namespace DatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Server=192.168.191.42:32768;Database=gun_market;Username=postgres;Password=7355608;");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
|
||||
optionsBuilder.UseNpgsql("Server=192.168.191.42:32768;Database=gun_market;Username=postgres;Password=7355608;");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Role> Roles { get; set; } = null!;
|
||||
public virtual DbSet<Role> Roles { get; set; } = null!;
|
||||
public virtual DbSet<User> Users { get; set; } = null!;
|
||||
public virtual DbSet<Sell> Sells { get; set; } = null!;
|
||||
public virtual DbSet<Purchase> Purchases { get; set; } = null!;
|
||||
@ -27,8 +29,12 @@ namespace DatabaseImplement
|
||||
public virtual DbSet<Supply> Supplies { get; set; } = null!;
|
||||
public virtual DbSet<SupplyProduct> SupplyProducts { get; set; } = null!;
|
||||
public virtual DbSet<Supplier> Suppliers { get; set; } = null!;
|
||||
public virtual DbSet<SupplierProduct> SupplierProducts { get; set; } = null!;
|
||||
|
||||
public virtual DbSet<MediaFile> MediaFiles { get; set; } = null!;
|
||||
}
|
||||
public virtual DbSet<SupplierProduct> SupplierProducts { get; set; } = null!;
|
||||
public virtual DbSet<MediaFile> MediaFiles { get; set; } = null!;
|
||||
public virtual DbSet<SellProducts> SellProducts { get; set; } = null!;
|
||||
public virtual DbSet<SupplyDoc> SupplyDocs { get; set; } = null!;
|
||||
public virtual DbSet<CartItem> CartItems { get; set; } = null!;
|
||||
public virtual DbSet<Sale> Sales { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
112
DatabaseImplement/Implements/CartItemStorage.cs
Normal file
112
DatabaseImplement/Implements/CartItemStorage.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class CartItemStorage : ICartItemStorage
|
||||
{
|
||||
public CartItemViewModel? Delete(CartItemBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.CartItems
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.CartItems.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CartItemViewModel? GetElement(CartItemSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.CartItems
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CartItemViewModel> GetFilteredList(CartItemSearchModel model)
|
||||
{
|
||||
if (model.UserId == Guid.Empty && string.IsNullOrEmpty(model.ProductName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new Database();
|
||||
if (model.UserId != Guid.Empty)
|
||||
{
|
||||
return context.CartItems
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.CartItems
|
||||
.Where(x => x.ProductName.Contains(model.ProductName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CartItemViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.CartItems
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CartItemViewModel? Insert(CartItemBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var newItem = CartItem.Create(context, model);
|
||||
if (newItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.CartItems.Add(newItem);
|
||||
context.SaveChanges();
|
||||
return newItem.GetViewModel;
|
||||
}
|
||||
|
||||
public CartItemViewModel? Update(CartItemBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var item = context.CartItems.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
item.Update(model);
|
||||
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return new();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
101
DatabaseImplement/Implements/MediaFileStorage.cs
Normal file
101
DatabaseImplement/Implements/MediaFileStorage.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class MediaFileStorage : IMediaFileStorage
|
||||
{
|
||||
public MediaFileViewModel? Delete(MediaFileBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.MediaFiles
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.MediaFiles.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MediaFileViewModel? GetElement(MediaFileSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.MediaFiles
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<MediaFileViewModel> GetFilteredList(MediaFileSearchModel model)
|
||||
{
|
||||
if (!model.ProductId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new Database();
|
||||
if (model.ProductId.HasValue)
|
||||
{
|
||||
return context.MediaFiles.Where(x => x.ProductId == model.ProductId).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
return context.MediaFiles.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<MediaFileViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.MediaFiles
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public MediaFileViewModel? Insert(MediaFileBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var newProduct = MediaFile.Create(model);
|
||||
if (newProduct == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.MediaFiles.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return newProduct.GetViewModel;
|
||||
}
|
||||
|
||||
public MediaFileViewModel? Update(MediaFileBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var product = context.MediaFiles.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
product.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return product.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,11 +18,6 @@ namespace DatabaseImplement.Implements
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
@ -40,43 +35,54 @@ namespace DatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
if (!model.IsBeingSold.HasValue && !model.Price.HasValue && !model.Rate.HasValue && !model.Amount.HasValue && string.IsNullOrEmpty(model.Name))
|
||||
if (!model.IsBeingSold.HasValue && !model.PriceFrom.HasValue && !model.PriceTo.HasValue && !model.Price.HasValue && !model.Rate.HasValue
|
||||
&& !model.Amount.HasValue && string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.Category))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new Database();
|
||||
|
||||
if (model.Price.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Price <= model.Price)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.PriceFrom.HasValue && model.PriceTo.HasValue)
|
||||
{
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Price <= model.PriceTo && x.Price >= model.PriceFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.PriceFrom.HasValue)
|
||||
{
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Price >= model.PriceFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.PriceTo.HasValue)
|
||||
{
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Price <= model.PriceTo)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.Rate.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Rate <= model.Rate)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -84,24 +90,22 @@ namespace DatabaseImplement.Implements
|
||||
}
|
||||
if (model.Amount.HasValue && model.IsBeingSold.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.IsBeingSold == model.IsBeingSold && x.Amount >= model.Amount)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
.Where(x => x.Name == model.Name)
|
||||
if (!string.IsNullOrEmpty(model.Category))
|
||||
{
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Category == model.Category)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -110,12 +114,7 @@ namespace DatabaseImplement.Implements
|
||||
public List<ProductViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
return context.Products.Include(x => x.Sale)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -125,6 +124,16 @@ namespace DatabaseImplement.Implements
|
||||
{
|
||||
using var context = new Database();
|
||||
var newProduct = Product.Create(context, model);
|
||||
|
||||
foreach (var sale in context.Sales)
|
||||
{
|
||||
if (sale.Category == newProduct.Category)
|
||||
{
|
||||
newProduct.Sale = sale;
|
||||
newProduct.SaleId = sale.Id;
|
||||
}
|
||||
}
|
||||
|
||||
if (newProduct == null)
|
||||
{
|
||||
return null;
|
||||
@ -140,7 +149,7 @@ namespace DatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var product = context.Products.FirstOrDefault(rec =>
|
||||
var product = context.Products.Include(x => x.Sale).FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
@ -149,7 +158,7 @@ namespace DatabaseImplement.Implements
|
||||
product.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return product.GetViewModel;
|
||||
return new();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
214
DatabaseImplement/Implements/PurchaseStorage.cs
Normal file
214
DatabaseImplement/Implements/PurchaseStorage.cs
Normal file
@ -0,0 +1,214 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using DataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class PurchaseStorage : IPurchaseStorage
|
||||
{
|
||||
public PurchaseViewModel? Delete(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Purchases.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Purchases.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Purchases
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<PurchaseViewModel> GetFullList(PurchaseSearchModel? model)
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Purchases
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model)
|
||||
{
|
||||
using var context = new Database();
|
||||
if (model.UserId == Guid.Empty && !model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue
|
||||
&& !model.DateFrom.HasValue && !model.Status.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (model.CostFrom.HasValue && model.CostTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.Cost <= model.CostTo && x.Cost >= model.CostFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.CostFrom.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.Cost >= model.CostFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.CostTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.Cost <= model.CostTo)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.DateCreated <= model.DateTo && x.DateCreated >= model.DateFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.DateCreated >= model.DateFrom)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.DateTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.DateCreated <= model.DateTo)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.UserId != Guid.Empty)
|
||||
{
|
||||
return context.Purchases
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Purchases
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var purchase = Purchase.Create(context, model);
|
||||
if (purchase == null)
|
||||
return null;
|
||||
|
||||
|
||||
var cartItems = context.CartItems
|
||||
.Where(x => x.PurchaseId == purchase.Id).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
|
||||
|
||||
var products = new List<Product>();
|
||||
|
||||
foreach (var item in cartItems)
|
||||
{
|
||||
var product = context.Products
|
||||
.Where(x => x.Id == item.ProductId)
|
||||
.FirstOrDefault();
|
||||
|
||||
products.Add(product);
|
||||
}
|
||||
|
||||
purchase.Products = products;
|
||||
context.Purchases.Add(purchase);
|
||||
context.SaveChanges();
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Update(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var purchase = context.Purchases.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (purchase == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
purchase.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public List<CartItemViewModel> GetCartItems(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
|
||||
var cartItems = context.CartItems
|
||||
.Where(x => x.PurchaseId == model.Id).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
|
||||
if (cartItems == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return cartItems;
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetProducts(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var purchase = context.Purchases
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id));
|
||||
|
||||
var products = new List<ProductViewModel>();
|
||||
|
||||
if (purchase.Products == null)
|
||||
return null;
|
||||
|
||||
foreach (var product in purchase.Products)
|
||||
products.Add(product.GetViewModel);
|
||||
|
||||
return products;
|
||||
}
|
||||
}
|
||||
}
|
113
DatabaseImplement/Implements/SaleStorage.cs
Normal file
113
DatabaseImplement/Implements/SaleStorage.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class SaleStorage : ISaleStorage
|
||||
{
|
||||
public SaleViewModel? Delete(SaleBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Sales
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Sales.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SaleViewModel? GetElement(SaleSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Sales
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<SaleViewModel> GetFilteredList(SaleSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Category))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Sales
|
||||
.Where(x => x.Category.Contains(model.Category))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<SaleViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Sales
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public SaleViewModel? Insert(SaleBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var newSale = Sale.Create(context, model);
|
||||
if (newSale == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var product in context.Products)
|
||||
{
|
||||
if (product.Category == newSale.Category)
|
||||
{
|
||||
product.Sale = newSale;
|
||||
product.SaleId = newSale.Id;
|
||||
}
|
||||
}
|
||||
context.Sales.Add(newSale);
|
||||
context.SaveChanges();
|
||||
return newSale.GetViewModel;
|
||||
}
|
||||
|
||||
public SaleViewModel? Update(SaleBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var sale = context.Sales.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
|
||||
if (sale == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
sale.Update(model);
|
||||
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return new();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
92
DatabaseImplement/Implements/SellStorage.cs
Normal file
92
DatabaseImplement/Implements/SellStorage.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.Converters;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class SellStorage : ISellStorage
|
||||
{
|
||||
public SellViewModel? Delete(SellSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Sells.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Sells.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SellViewModel? GetElement(SellSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Sells
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public IEnumerable<SellViewModel> GetFilteredList(SellSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<SellViewModel> GetFullList(SellSearchModel? model)
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Sells
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.ToList()
|
||||
.Select((Sell sell, int index) => sell.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public SellViewModel? Insert(SellBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var sell = Sell.Create(context, model);
|
||||
if (sell == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Sells.Add(sell);
|
||||
context.SaveChanges();
|
||||
return sell.GetViewModel;
|
||||
}
|
||||
|
||||
public SellViewModel? Update(SellBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var sell = context.Sells.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (sell == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
sell.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return sell.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace DatabaseImplement.Implements
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Suppliers
|
||||
.Include(x => x.Name)
|
||||
//.Include(x => x.Name)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -106,7 +107,7 @@ namespace DatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public SupplyViewModel? Insert(SupplyBindingModel model)
|
||||
public bool? Insert(SupplyBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var newProduct = Supply.Create(context, model);
|
||||
@ -115,11 +116,18 @@ namespace DatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
context.Supplies.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return newProduct.GetViewModel;
|
||||
try
|
||||
{
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public SupplyViewModel? Update(SupplyBindingModel model)
|
||||
public bool? Update(SupplyBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
@ -129,13 +137,12 @@ namespace DatabaseImplement.Implements
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
product.Update(model);
|
||||
context.SaveChanges();
|
||||
product.UpdateProducts(context, model);
|
||||
transaction.Commit();
|
||||
return product.GetViewModel;
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -106,5 +106,20 @@ namespace DatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return user.GetBindingModel();
|
||||
}
|
||||
|
||||
public void UpdateBonus(BonusUpdateBindingModel model)
|
||||
{
|
||||
var context = new Database();
|
||||
var user = context.Users
|
||||
.FirstOrDefault(u => u.Id == model.UserId);
|
||||
|
||||
if (user is null)
|
||||
return;
|
||||
|
||||
user.Bonus += model.BonusPlus;
|
||||
user.Bonus -= model.BonusMinus;
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
395
DatabaseImplement/Migrations/20240623130351_many-to-many.Designer.cs
generated
Normal file
395
DatabaseImplement/Migrations/20240623130351_many-to-many.Designer.cs
generated
Normal file
@ -0,0 +1,395 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240623130351_many-to-many")]
|
||||
partial class manytomany
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
90
DatabaseImplement/Migrations/20240623130351_many-to-many.cs
Normal file
90
DatabaseImplement/Migrations/20240623130351_many-to-many.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class manytomany : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "UserId",
|
||||
table: "Purchases",
|
||||
type: "uuid",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseProducts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
PurchaseId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseProducts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseProducts_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseProducts_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_UserId",
|
||||
table: "Purchases",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseProducts_ProductId",
|
||||
table: "PurchaseProducts",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseProducts_PurchaseId",
|
||||
table: "PurchaseProducts",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Purchases_Users_UserId",
|
||||
table: "Purchases",
|
||||
column: "UserId",
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Purchases_Users_UserId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseProducts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Purchases_UserId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UserId",
|
||||
table: "Purchases");
|
||||
}
|
||||
}
|
||||
}
|
477
DatabaseImplement/Migrations/20240624105540_sellproducts.Designer.cs
generated
Normal file
477
DatabaseImplement/Migrations/20240624105540_sellproducts.Designer.cs
generated
Normal file
@ -0,0 +1,477 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240624105540_sellproducts")]
|
||||
partial class sellproducts
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SellId");
|
||||
|
||||
b.ToTable("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SupplyDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("SellProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SellId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Sell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
|
||||
b.Navigation("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
104
DatabaseImplement/Migrations/20240624105540_sellproducts.cs
Normal file
104
DatabaseImplement/Migrations/20240624105540_sellproducts.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class sellproducts : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "UserId",
|
||||
table: "Sells",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SellProducts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
SellId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SellProducts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SellProducts_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SellProducts_Sells_SellId",
|
||||
column: x => x.SellId,
|
||||
principalTable: "Sells",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SupplyDocs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
SupplyId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SupplyDocs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sells_UserId",
|
||||
table: "Sells",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellProducts_ProductId",
|
||||
table: "SellProducts",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellProducts_SellId",
|
||||
table: "SellProducts",
|
||||
column: "SellId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Sells_Users_UserId",
|
||||
table: "Sells",
|
||||
column: "UserId",
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Sells_Users_UserId",
|
||||
table: "Sells");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellProducts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SupplyDocs");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Sells_UserId",
|
||||
table: "Sells");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UserId",
|
||||
table: "Sells");
|
||||
}
|
||||
}
|
||||
}
|
496
DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
generated
Normal file
496
DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
generated
Normal file
@ -0,0 +1,496 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240625085945_dates_migration")]
|
||||
partial class dates_migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SellId");
|
||||
|
||||
b.ToTable("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateArriving")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SupplyDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("SellProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SellId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Sell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
|
||||
b.Navigation("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class dates_migration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateArriving",
|
||||
table: "Supplies",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateComplete",
|
||||
table: "Supplies",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MediaFiles_ProductId",
|
||||
table: "MediaFiles",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_MediaFiles_Products_ProductId",
|
||||
table: "MediaFiles",
|
||||
column: "ProductId",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_MediaFiles_Products_ProductId",
|
||||
table: "MediaFiles");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_MediaFiles_ProductId",
|
||||
table: "MediaFiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateArriving",
|
||||
table: "Supplies");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateComplete",
|
||||
table: "Supplies");
|
||||
}
|
||||
}
|
||||
}
|
496
DatabaseImplement/Migrations/20240625124236_image.Designer.cs
generated
Normal file
496
DatabaseImplement/Migrations/20240625124236_image.Designer.cs
generated
Normal file
@ -0,0 +1,496 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240625124236_image")]
|
||||
partial class image
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte[]>("Image")
|
||||
.IsRequired()
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SellId");
|
||||
|
||||
b.ToTable("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateArriving")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SupplyDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("SellProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SellId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Sell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
|
||||
b.Navigation("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
40
DatabaseImplement/Migrations/20240625124236_image.cs
Normal file
40
DatabaseImplement/Migrations/20240625124236_image.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class image : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Location",
|
||||
table: "MediaFiles");
|
||||
|
||||
migrationBuilder.AddColumn<byte[]>(
|
||||
name: "Image",
|
||||
table: "MediaFiles",
|
||||
type: "bytea",
|
||||
nullable: false,
|
||||
defaultValue: new byte[0]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Image",
|
||||
table: "MediaFiles");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Location",
|
||||
table: "MediaFiles",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
492
DatabaseImplement/Migrations/20240625131604_image2.Designer.cs
generated
Normal file
492
DatabaseImplement/Migrations/20240625131604_image2.Designer.cs
generated
Normal file
@ -0,0 +1,492 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240625131604_image2")]
|
||||
partial class image2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte[]>("Image")
|
||||
.IsRequired()
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SellId");
|
||||
|
||||
b.ToTable("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateArriving")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SupplyDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("SellProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SellId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Sell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
|
||||
b.Navigation("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
29
DatabaseImplement/Migrations/20240625131604_image2.cs
Normal file
29
DatabaseImplement/Migrations/20240625131604_image2.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class image2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Name",
|
||||
table: "MediaFiles");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Name",
|
||||
table: "MediaFiles",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
495
DatabaseImplement/Migrations/20240625215017_purchase.Designer.cs
generated
Normal file
495
DatabaseImplement/Migrations/20240625215017_purchase.Designer.cs
generated
Normal file
@ -0,0 +1,495 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240625215017_purchase")]
|
||||
partial class purchase
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte[]>("Image")
|
||||
.IsRequired()
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsBeingSold")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<double>("Rate")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DatePurchase")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PurchaseId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("DateSell")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sells");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SellId");
|
||||
|
||||
b.ToTable("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Deals")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("SupplierProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateArriving")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateComplete")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupplierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SupplyDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SupplyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("Birthday")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("OnlyImportantMails")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("RoleId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("SecondName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("PurchaseProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("SellProducts")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SellId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Sell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("PurchaseProducts");
|
||||
|
||||
b.Navigation("SellProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user