From af14af2496132bf3a21c91a06d44ee2dcdd65be0 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Fri, 26 Jul 2024 02:46:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=83=D1=80=D1=81=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F:=20=D0=92=D0=BE=D0=B9=D0=BD=D0=B0=20=D0=91=D0=B5=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=B5=D1=87=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BusinessLogic/BusinessLogic/BillLogic.cs | 122 ++++ BusinessLogic/BusinessLogic/CartItemLogic.cs | 105 +++ BusinessLogic/BusinessLogic/ProductLogic.cs | 1 + BusinessLogic/BusinessLogic/PurchaseLogic.cs | 27 +- BusinessLogic/BusinessLogic/SaleLogic.cs | 116 ++++ BusinessLogic/BusinessLogic/UserLogic.cs | 5 + BusinessLogic/Tools/Mail/Mail.cs | 2 + BusinessLogic/Tools/Mail/MailSender.cs | 5 + .../Mail/MailTemplates/MailBillSender.cs | 28 + .../Mail/MailTemplates/MailTwoFactorCode.cs | 2 +- .../BindingModels/BonusUpdateBindingModel.cs | 15 + .../BindingModels/CartItemBindingModel.cs | 20 + .../BindingModels/ProductBindingModel.cs | 5 +- .../BindingModels/PurchaseBindingModel.cs | 10 +- Contracts/BindingModels/SaleBindingModel.cs | 21 + Contracts/BindingModels/UserBindingModel.cs | 1 + .../BusinessLogicContracts/IBillLogic.cs | 14 + .../BusinessLogicContracts/ICartItemLogic.cs | 24 + .../BusinessLogicContracts/IPurchaseLogic.cs | 5 +- .../BusinessLogicContracts/ISaleLogic.cs | 24 + .../BusinessLogicContracts/IUserLogic.cs | 1 + Contracts/Converters/PurchaseConverter.cs | 38 +- Contracts/Converters/SellConverter.cs | 28 - Contracts/Converters/UserConverter.cs | 2 + Contracts/SearchModels/CartItemSearchModel.cs | 16 + Contracts/SearchModels/ProductSearchModel.cs | 1 + Contracts/SearchModels/PurchaseSearchModel.cs | 1 + Contracts/SearchModels/SaleSearchModel.cs | 15 + .../StorageContracts/ICartItemStorage.cs | 21 + .../StorageContracts/IPurchaseStorage.cs | 5 +- Contracts/StorageContracts/ISaleStorage.cs | 21 + Contracts/StorageContracts/IUserStorage.cs | 4 +- Contracts/ViewModels/BillViewModel.cs | 22 + Contracts/ViewModels/CartItemViewModel.cs | 21 + Contracts/ViewModels/PaymentViewModel.cs | 19 + Contracts/ViewModels/ProductViewModel.cs | 4 + Contracts/ViewModels/PurchaseViewModel.cs | 8 +- Contracts/ViewModels/SaleViewModel.cs | 21 + Contracts/ViewModels/UserProductViewModel.cs | 3 +- Contracts/ViewModels/UserViewModel.cs | 1 + DataModels/Models/ICartItem.cs | 17 + DataModels/Models/IProduct.cs | 4 +- DataModels/Models/IPurchase.cs | 7 +- DataModels/Models/ISale.cs | 19 + DataModels/Models/IUser.cs | 1 + DatabaseImplement/Database.cs | 6 +- .../Implements/CartItemStorage.cs | 112 ++++ .../Implements/ProductStorage.cs | 44 +- .../Implements/PurchaseStorage.cs | 123 ++-- DatabaseImplement/Implements/SaleStorage.cs | 113 ++++ DatabaseImplement/Implements/UserStorage.cs | 15 + .../20240702133630_prod.Designer.cs | 503 +++++++++++++++ .../Migrations/20240702133630_prod.cs | 40 ++ .../20240714172818_bonus.Designer.cs | 506 +++++++++++++++ .../Migrations/20240714172818_bonus.cs | 29 + .../20240714214732_sale.Designer.cs | 536 ++++++++++++++++ .../Migrations/20240714214732_sale.cs | 101 +++ .../20240715001559_sale2.Designer.cs | 541 ++++++++++++++++ .../Migrations/20240715001559_sale2.cs | 22 + .../20240715122630_sale-update.Designer.cs | 548 ++++++++++++++++ .../Migrations/20240715122630_sale-update.cs | 40 ++ .../20240715233951_sale3.Designer.cs | 558 ++++++++++++++++ .../Migrations/20240715233951_sale3.cs | 52 ++ .../20240716134506_cartitem.Designer.cs | 601 ++++++++++++++++++ .../Migrations/20240716134506_cartitem.cs | 68 ++ .../20240717230804_cartitem2.Designer.cs | 598 +++++++++++++++++ .../Migrations/20240717230804_cartitem2.cs | 29 + .../20240718212855_purchaseitems.Designer.cs | 559 ++++++++++++++++ .../20240718212855_purchaseitems.cs | 88 +++ .../20240718214141_purchasepatch.Designer.cs | 562 ++++++++++++++++ .../20240718214141_purchasepatch.cs | 40 ++ .../20240720140718_purchase2.Designer.cs | 565 ++++++++++++++++ .../Migrations/20240720140718_purchase2.cs | 29 + .../20240722134201_purchase3.Designer.cs | 568 +++++++++++++++++ .../Migrations/20240722134201_purchase3.cs | 29 + .../Migrations/DatabaseModelSnapshot.cs | 167 +++-- DatabaseImplement/Models/CartItem.cs | 83 +++ DatabaseImplement/Models/Product.cs | 68 +- DatabaseImplement/Models/Purchase.cs | 106 ++- DatabaseImplement/Models/PurchaseProducts.cs | 24 - DatabaseImplement/Models/Sale.cs | 123 ++++ DatabaseImplement/Models/SupplierProduct.cs | 2 +- DatabaseImplement/Models/User.cs | 15 +- RestAPI/Controllers/CartItemController.cs | 147 +++++ RestAPI/Controllers/MediaFileController.cs | 2 +- RestAPI/Controllers/ProductController.cs | 5 +- RestAPI/Controllers/PurchaseController.cs | 108 ++-- RestAPI/Controllers/SaleController.cs | 100 +++ RestAPI/Controllers/UserController.cs | 18 +- RestAPI/Program.cs | 7 + WebApp/Pages/Cart.cshtml | 94 ++- WebApp/Pages/Cart.cshtml.cs | 52 +- WebApp/Pages/Index.cshtml | 145 +++-- WebApp/Pages/Index.cshtml.cs | 12 +- WebApp/Pages/Login.cshtml.cs | 4 +- WebApp/Pages/ProductPage.cshtml | 210 ++++-- WebApp/Pages/ProductPage.cshtml.cs | 29 +- WebApp/Pages/Purchase.cshtml | 63 ++ WebApp/Pages/Purchase.cshtml.cs | 98 +++ WebApp/Pages/Shared/_Layout.cshtml | 30 +- WebApp/Pages/Shared/_Layout.cshtml.css | 106 +-- WebApp/Pages/TwoFactor.cshtml | 49 +- WebApp/Pages/User/Index.cshtml | 22 +- WebApp/Pages/User/Purchases.cshtml | 172 +++++ WebApp/Pages/User/Purchases.cshtml.cs | 82 +++ WebApp/Pages/_Header.cshtml | 5 + WebApp/Pages/_Header.cshtml.cs | 12 + WebApp/WebApp.csproj | 17 + WebApp/wwwroot/big-sale.png | Bin 0 -> 33090 bytes WebApp/wwwroot/css/site.css | 14 + 110 files changed, 10060 insertions(+), 608 deletions(-) create mode 100644 BusinessLogic/BusinessLogic/BillLogic.cs create mode 100644 BusinessLogic/BusinessLogic/CartItemLogic.cs create mode 100644 BusinessLogic/BusinessLogic/SaleLogic.cs create mode 100644 BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs create mode 100644 Contracts/BindingModels/BonusUpdateBindingModel.cs create mode 100644 Contracts/BindingModels/CartItemBindingModel.cs create mode 100644 Contracts/BindingModels/SaleBindingModel.cs create mode 100644 Contracts/BusinessLogicContracts/IBillLogic.cs create mode 100644 Contracts/BusinessLogicContracts/ICartItemLogic.cs create mode 100644 Contracts/BusinessLogicContracts/ISaleLogic.cs delete mode 100644 Contracts/Converters/SellConverter.cs create mode 100644 Contracts/SearchModels/CartItemSearchModel.cs create mode 100644 Contracts/SearchModels/SaleSearchModel.cs create mode 100644 Contracts/StorageContracts/ICartItemStorage.cs create mode 100644 Contracts/StorageContracts/ISaleStorage.cs create mode 100644 Contracts/ViewModels/BillViewModel.cs create mode 100644 Contracts/ViewModels/CartItemViewModel.cs create mode 100644 Contracts/ViewModels/PaymentViewModel.cs create mode 100644 Contracts/ViewModels/SaleViewModel.cs create mode 100644 DataModels/Models/ICartItem.cs create mode 100644 DataModels/Models/ISale.cs create mode 100644 DatabaseImplement/Implements/CartItemStorage.cs create mode 100644 DatabaseImplement/Implements/SaleStorage.cs create mode 100644 DatabaseImplement/Migrations/20240702133630_prod.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240702133630_prod.cs create mode 100644 DatabaseImplement/Migrations/20240714172818_bonus.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240714172818_bonus.cs create mode 100644 DatabaseImplement/Migrations/20240714214732_sale.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240714214732_sale.cs create mode 100644 DatabaseImplement/Migrations/20240715001559_sale2.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240715001559_sale2.cs create mode 100644 DatabaseImplement/Migrations/20240715122630_sale-update.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240715122630_sale-update.cs create mode 100644 DatabaseImplement/Migrations/20240715233951_sale3.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240715233951_sale3.cs create mode 100644 DatabaseImplement/Migrations/20240716134506_cartitem.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240716134506_cartitem.cs create mode 100644 DatabaseImplement/Migrations/20240717230804_cartitem2.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240717230804_cartitem2.cs create mode 100644 DatabaseImplement/Migrations/20240718212855_purchaseitems.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240718212855_purchaseitems.cs create mode 100644 DatabaseImplement/Migrations/20240718214141_purchasepatch.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240718214141_purchasepatch.cs create mode 100644 DatabaseImplement/Migrations/20240720140718_purchase2.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240720140718_purchase2.cs create mode 100644 DatabaseImplement/Migrations/20240722134201_purchase3.Designer.cs create mode 100644 DatabaseImplement/Migrations/20240722134201_purchase3.cs create mode 100644 DatabaseImplement/Models/CartItem.cs delete mode 100644 DatabaseImplement/Models/PurchaseProducts.cs create mode 100644 DatabaseImplement/Models/Sale.cs create mode 100644 RestAPI/Controllers/CartItemController.cs create mode 100644 RestAPI/Controllers/SaleController.cs create mode 100644 WebApp/Pages/Purchase.cshtml create mode 100644 WebApp/Pages/Purchase.cshtml.cs create mode 100644 WebApp/Pages/User/Purchases.cshtml create mode 100644 WebApp/Pages/User/Purchases.cshtml.cs create mode 100644 WebApp/Pages/_Header.cshtml create mode 100644 WebApp/Pages/_Header.cshtml.cs create mode 100644 WebApp/wwwroot/big-sale.png diff --git a/BusinessLogic/BusinessLogic/BillLogic.cs b/BusinessLogic/BusinessLogic/BillLogic.cs new file mode 100644 index 0000000..674c943 --- /dev/null +++ b/BusinessLogic/BusinessLogic/BillLogic.cs @@ -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)); + } + } +} diff --git a/BusinessLogic/BusinessLogic/CartItemLogic.cs b/BusinessLogic/BusinessLogic/CartItemLogic.cs new file mode 100644 index 0000000..546e327 --- /dev/null +++ b/BusinessLogic/BusinessLogic/CartItemLogic.cs @@ -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 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 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); + } + } +} diff --git a/BusinessLogic/BusinessLogic/ProductLogic.cs b/BusinessLogic/BusinessLogic/ProductLogic.cs index e10985d..64e594d 100644 --- a/BusinessLogic/BusinessLogic/ProductLogic.cs +++ b/BusinessLogic/BusinessLogic/ProductLogic.cs @@ -23,6 +23,7 @@ namespace BusinessLogic.BusinessLogic } public bool Create(ProductBindingModel model) { + CheckModel(model); if (_productStorage.Insert(model) == null) { diff --git a/BusinessLogic/BusinessLogic/PurchaseLogic.cs b/BusinessLogic/BusinessLogic/PurchaseLogic.cs index d9acc2b..4ea4fd8 100644 --- a/BusinessLogic/BusinessLogic/PurchaseLogic.cs +++ b/BusinessLogic/BusinessLogic/PurchaseLogic.cs @@ -103,14 +103,25 @@ namespace BusinessLogic.BusinessLogic } return purchase; } - public PurchaseViewModel AddProduct(PurchaseSearchModel purchase_model, ProductSearchModel product_model, int count) - { - _purchaseStorage.AddProducts(purchase_model, product_model, count); - return _purchaseStorage.GetElement(purchase_model); - } - public Dictionary GetProducts(PurchaseSearchModel model) + public List GetCartItems(PurchaseSearchModel model) { - return _purchaseStorage.GetProducts(model); + var items = _purchaseStorage.GetCartItems(model); + if (items is null) + { + throw new Exception("Get operation failed."); + } + return items; } - } + + public List GetProducts(PurchaseSearchModel model) + { + var products = _purchaseStorage.GetProducts(model); + if (products is null) + { + throw new Exception("Get operation failed."); + } + return products; + } + + } } diff --git a/BusinessLogic/BusinessLogic/SaleLogic.cs b/BusinessLogic/BusinessLogic/SaleLogic.cs new file mode 100644 index 0000000..b4c6cee --- /dev/null +++ b/BusinessLogic/BusinessLogic/SaleLogic.cs @@ -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 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 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("Акция с таким описанием уже есть"); + } + } + } +} diff --git a/BusinessLogic/BusinessLogic/UserLogic.cs b/BusinessLogic/BusinessLogic/UserLogic.cs index 0ccec27..163d1c2 100644 --- a/BusinessLogic/BusinessLogic/UserLogic.cs +++ b/BusinessLogic/BusinessLogic/UserLogic.cs @@ -181,5 +181,10 @@ namespace BusinessLogic.BusinessLogic { return _twoFactorAuthService.Verify(code); } + + public void UpdateBonus(BonusUpdateBindingModel model) + { + _userStorage.UpdateBonus(model); + } } } \ No newline at end of file diff --git a/BusinessLogic/Tools/Mail/Mail.cs b/BusinessLogic/Tools/Mail/Mail.cs index 44cc1a8..1b677a9 100644 --- a/BusinessLogic/Tools/Mail/Mail.cs +++ b/BusinessLogic/Tools/Mail/Mail.cs @@ -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? Attachments { get; set; } = new List(); } } \ No newline at end of file diff --git a/BusinessLogic/Tools/Mail/MailSender.cs b/BusinessLogic/Tools/Mail/MailSender.cs index 3df9c48..bb1c93a 100644 --- a/BusinessLogic/Tools/Mail/MailSender.cs +++ b/BusinessLogic/Tools/Mail/MailSender.cs @@ -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); } } diff --git a/BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs b/BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs new file mode 100644 index 0000000..c4cbaf3 --- /dev/null +++ b/BusinessLogic/Tools/Mail/MailTemplates/MailBillSender.cs @@ -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); + } + } +} diff --git a/BusinessLogic/Tools/Mail/MailTemplates/MailTwoFactorCode.cs b/BusinessLogic/Tools/Mail/MailTemplates/MailTwoFactorCode.cs index 6c5e4d4..ae72567 100644 --- a/BusinessLogic/Tools/Mail/MailTemplates/MailTwoFactorCode.cs +++ b/BusinessLogic/Tools/Mail/MailTemplates/MailTwoFactorCode.cs @@ -15,7 +15,7 @@ namespace BusinessLogic.Tools.Mail.MailTemplates Title = "Ваш код для подтверждения"; Body = $"Здравствуйте, {user.SecondName} {user.FirstName}! Вот Ваш код для подтверждения:\n" + $"{code}\n" + - $"Если это не Вы, игноритруйте это сообщение."; + $"Если это не Вы, игнорируйте это сообщение."; } } } \ No newline at end of file diff --git a/Contracts/BindingModels/BonusUpdateBindingModel.cs b/Contracts/BindingModels/BonusUpdateBindingModel.cs new file mode 100644 index 0000000..d2bb6bf --- /dev/null +++ b/Contracts/BindingModels/BonusUpdateBindingModel.cs @@ -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; } + } +} diff --git a/Contracts/BindingModels/CartItemBindingModel.cs b/Contracts/BindingModels/CartItemBindingModel.cs new file mode 100644 index 0000000..fc042d1 --- /dev/null +++ b/Contracts/BindingModels/CartItemBindingModel.cs @@ -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; } + } +} diff --git a/Contracts/BindingModels/ProductBindingModel.cs b/Contracts/BindingModels/ProductBindingModel.cs index 8f44dbd..4a86885 100644 --- a/Contracts/BindingModels/ProductBindingModel.cs +++ b/Contracts/BindingModels/ProductBindingModel.cs @@ -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; } + } } diff --git a/Contracts/BindingModels/PurchaseBindingModel.cs b/Contracts/BindingModels/PurchaseBindingModel.cs index 67268dd..1c0a66c 100644 --- a/Contracts/BindingModels/PurchaseBindingModel.cs +++ b/Contracts/BindingModels/PurchaseBindingModel.cs @@ -11,10 +11,12 @@ namespace Contracts.BindingModels public class PurchaseBindingModel { public Guid Id { get; set; } - public DateTime DatePurchase { get; set; } - public Guid UserId { get; set; } + public DateTime DateCreated { get; set; } + public DateTime? DateClosed { get; set; } + public Guid UserId { get; set; } public PurchaseStatus Status { get; set; } - public Dictionary? PurchaseProducts { get; set; } = new(); + public int ProductCount { get; set; } public double Cost { get; set; } - } + public bool IsPaid { get; set; } + } } diff --git a/Contracts/BindingModels/SaleBindingModel.cs b/Contracts/BindingModels/SaleBindingModel.cs new file mode 100644 index 0000000..0cb5f95 --- /dev/null +++ b/Contracts/BindingModels/SaleBindingModel.cs @@ -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; } + } +} diff --git a/Contracts/BindingModels/UserBindingModel.cs b/Contracts/BindingModels/UserBindingModel.cs index 6c192d6..7b131d9 100644 --- a/Contracts/BindingModels/UserBindingModel.cs +++ b/Contracts/BindingModels/UserBindingModel.cs @@ -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; } } } \ No newline at end of file diff --git a/Contracts/BusinessLogicContracts/IBillLogic.cs b/Contracts/BusinessLogicContracts/IBillLogic.cs new file mode 100644 index 0000000..753abd3 --- /dev/null +++ b/Contracts/BusinessLogicContracts/IBillLogic.cs @@ -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); + } +} diff --git a/Contracts/BusinessLogicContracts/ICartItemLogic.cs b/Contracts/BusinessLogicContracts/ICartItemLogic.cs new file mode 100644 index 0000000..ad1a4aa --- /dev/null +++ b/Contracts/BusinessLogicContracts/ICartItemLogic.cs @@ -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 ReadElements(CartItemSearchModel? model); + + bool Delete(CartItemBindingModel model); + } +} diff --git a/Contracts/BusinessLogicContracts/IPurchaseLogic.cs b/Contracts/BusinessLogicContracts/IPurchaseLogic.cs index 8fa80fa..353df3b 100644 --- a/Contracts/BusinessLogicContracts/IPurchaseLogic.cs +++ b/Contracts/BusinessLogicContracts/IPurchaseLogic.cs @@ -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; @@ -20,7 +21,7 @@ namespace Contracts.BusinessLogicContracts List ReadElements(PurchaseSearchModel? model); PurchaseViewModel Delete(PurchaseSearchModel model); - PurchaseViewModel AddProduct(PurchaseSearchModel purchase, ProductSearchModel product, int count); - Dictionary GetProducts(PurchaseSearchModel model); + List GetCartItems(PurchaseSearchModel model); + List GetProducts(PurchaseSearchModel model); } } diff --git a/Contracts/BusinessLogicContracts/ISaleLogic.cs b/Contracts/BusinessLogicContracts/ISaleLogic.cs new file mode 100644 index 0000000..aec7741 --- /dev/null +++ b/Contracts/BusinessLogicContracts/ISaleLogic.cs @@ -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 ReadElements(SaleSearchModel? model); + + bool Delete(SaleBindingModel model); + } +} diff --git a/Contracts/BusinessLogicContracts/IUserLogic.cs b/Contracts/BusinessLogicContracts/IUserLogic.cs index 802f723..a801e75 100644 --- a/Contracts/BusinessLogicContracts/IUserLogic.cs +++ b/Contracts/BusinessLogicContracts/IUserLogic.cs @@ -25,5 +25,6 @@ namespace Contracts.BusinessLogicContracts IEnumerable ReadElements(UserSearchModel? model); UserViewModel Delete(UserSearchModel model); + void UpdateBonus(BonusUpdateBindingModel model); } } \ No newline at end of file diff --git a/Contracts/Converters/PurchaseConverter.cs b/Contracts/Converters/PurchaseConverter.cs index c2139b8..53bd3d7 100644 --- a/Contracts/Converters/PurchaseConverter.cs +++ b/Contracts/Converters/PurchaseConverter.cs @@ -8,22 +8,26 @@ using System.Threading.Tasks; namespace Contracts.Converters { - public class PurchaseConverter - { - public static PurchaseViewModel ToView(PurchaseBindingModel model) => new() - { - Id = model.Id, - DatePurchase = model.DatePurchase, - UserId = model.UserId, - PurchaseProducts = model.PurchaseProducts, - }; + 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, - DatePurchase = model.DatePurchase, - UserId = model.UserId, - PurchaseProducts = model.PurchaseProducts, - }; - } + 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 + }; + } } diff --git a/Contracts/Converters/SellConverter.cs b/Contracts/Converters/SellConverter.cs deleted file mode 100644 index e24a426..0000000 --- a/Contracts/Converters/SellConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Contracts.BindingModels; -using Contracts.ViewModels; -using DataModels.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Contracts.Converters -{ - public class SellConverter - { - public static SellViewModel ToView(SellBindingModel model) => new() - { - Id = model.Id, - DateSell = model.DateSell, - UserId = model.UserId - }; - - public static SellBindingModel ToBinding(SellViewModel model) => new() - { - Id = model.Id, - DateSell = model.DateSell, - UserId = model.UserId - }; - } -} diff --git a/Contracts/Converters/UserConverter.cs b/Contracts/Converters/UserConverter.cs index ae6fd8a..9a24b7a 100644 --- a/Contracts/Converters/UserConverter.cs +++ b/Contracts/Converters/UserConverter.cs @@ -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, }; } } \ No newline at end of file diff --git a/Contracts/SearchModels/CartItemSearchModel.cs b/Contracts/SearchModels/CartItemSearchModel.cs new file mode 100644 index 0000000..27dd057 --- /dev/null +++ b/Contracts/SearchModels/CartItemSearchModel.cs @@ -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; } + } +} diff --git a/Contracts/SearchModels/ProductSearchModel.cs b/Contracts/SearchModels/ProductSearchModel.cs index dac5012..0241aec 100644 --- a/Contracts/SearchModels/ProductSearchModel.cs +++ b/Contracts/SearchModels/ProductSearchModel.cs @@ -16,5 +16,6 @@ namespace Contracts.SearchModels public double? Rate { get; set; } public int? Amount { get; set; } public bool? IsBeingSold { get; set; } + public string? Category { get; set; } } } diff --git a/Contracts/SearchModels/PurchaseSearchModel.cs b/Contracts/SearchModels/PurchaseSearchModel.cs index 2738bf0..853c9d7 100644 --- a/Contracts/SearchModels/PurchaseSearchModel.cs +++ b/Contracts/SearchModels/PurchaseSearchModel.cs @@ -16,5 +16,6 @@ namespace Contracts.SearchModels public double? CostFrom { get; set; } public double? CostTo { get; set; } public PurchaseStatus? Status { get; set; } + public Guid UserId { get; set; } } } diff --git a/Contracts/SearchModels/SaleSearchModel.cs b/Contracts/SearchModels/SaleSearchModel.cs new file mode 100644 index 0000000..023817a --- /dev/null +++ b/Contracts/SearchModels/SaleSearchModel.cs @@ -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; } + } +} diff --git a/Contracts/StorageContracts/ICartItemStorage.cs b/Contracts/StorageContracts/ICartItemStorage.cs new file mode 100644 index 0000000..e7a35d4 --- /dev/null +++ b/Contracts/StorageContracts/ICartItemStorage.cs @@ -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 GetFullList(); + List GetFilteredList(CartItemSearchModel model); + CartItemViewModel? GetElement(CartItemSearchModel model); + CartItemViewModel? Insert(CartItemBindingModel model); + CartItemViewModel? Update(CartItemBindingModel model); + CartItemViewModel? Delete(CartItemBindingModel model); + } +} diff --git a/Contracts/StorageContracts/IPurchaseStorage.cs b/Contracts/StorageContracts/IPurchaseStorage.cs index 8944c44..2a29c45 100644 --- a/Contracts/StorageContracts/IPurchaseStorage.cs +++ b/Contracts/StorageContracts/IPurchaseStorage.cs @@ -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; @@ -21,7 +22,7 @@ namespace Contracts.StorageContracts PurchaseViewModel? Update(PurchaseBindingModel model); PurchaseViewModel? Delete(PurchaseSearchModel model); - PurchaseViewModel? AddProducts(PurchaseSearchModel purchaseModel, ProductSearchModel productModel, int count); - Dictionary GetProducts(PurchaseSearchModel purchaseModel); + List GetCartItems(PurchaseSearchModel purchaseModel); + List GetProducts(PurchaseSearchModel model); } } diff --git a/Contracts/StorageContracts/ISaleStorage.cs b/Contracts/StorageContracts/ISaleStorage.cs new file mode 100644 index 0000000..1acc043 --- /dev/null +++ b/Contracts/StorageContracts/ISaleStorage.cs @@ -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 GetFullList(); + List GetFilteredList(SaleSearchModel model); + SaleViewModel? GetElement(SaleSearchModel model); + SaleViewModel? Insert(SaleBindingModel model); + SaleViewModel? Update(SaleBindingModel model); + SaleViewModel? Delete(SaleBindingModel model); + } +} \ No newline at end of file diff --git a/Contracts/StorageContracts/IUserStorage.cs b/Contracts/StorageContracts/IUserStorage.cs index 3a38799..6483843 100644 --- a/Contracts/StorageContracts/IUserStorage.cs +++ b/Contracts/StorageContracts/IUserStorage.cs @@ -19,5 +19,7 @@ namespace Contracts.StorageContracts UserBindingModel? Update(UserBindingModel model); UserBindingModel? Delete(UserSearchModel model); - } + void UpdateBonus(BonusUpdateBindingModel model); + + } } \ No newline at end of file diff --git a/Contracts/ViewModels/BillViewModel.cs b/Contracts/ViewModels/BillViewModel.cs new file mode 100644 index 0000000..01a5307 --- /dev/null +++ b/Contracts/ViewModels/BillViewModel.cs @@ -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 Products { get; set; } = new List(); + 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; + + } +} diff --git a/Contracts/ViewModels/CartItemViewModel.cs b/Contracts/ViewModels/CartItemViewModel.cs new file mode 100644 index 0000000..50344d1 --- /dev/null +++ b/Contracts/ViewModels/CartItemViewModel.cs @@ -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; } + } +} diff --git a/Contracts/ViewModels/PaymentViewModel.cs b/Contracts/ViewModels/PaymentViewModel.cs new file mode 100644 index 0000000..d7ff482 --- /dev/null +++ b/Contracts/ViewModels/PaymentViewModel.cs @@ -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; } + } +} diff --git a/Contracts/ViewModels/ProductViewModel.cs b/Contracts/ViewModels/ProductViewModel.cs index 14b7df3..933212a 100644 --- a/Contracts/ViewModels/ProductViewModel.cs +++ b/Contracts/ViewModels/ProductViewModel.cs @@ -12,9 +12,13 @@ namespace Contracts.ViewModels public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public double Price { 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 MediaFiles { get; set; } = new(); + public Guid? SaleId { get; set; } } } diff --git a/Contracts/ViewModels/PurchaseViewModel.cs b/Contracts/ViewModels/PurchaseViewModel.cs index bd2eede..1eba591 100644 --- a/Contracts/ViewModels/PurchaseViewModel.cs +++ b/Contracts/ViewModels/PurchaseViewModel.cs @@ -11,10 +11,12 @@ namespace Contracts.ViewModels public class PurchaseViewModel { public Guid Id { get; set; } - public DateTime DatePurchase { get; set; } - public required Guid UserId { get; set; } + public DateTime DateCreated { get; set; } + public DateTime? DateClosed { get; set; } + public required Guid UserId { get; set; } public PurchaseStatus Status { get; set; } - public Dictionary? PurchaseProducts { get; set; } = new(); + public int ProductCount { get; set; } public double Cost { get; set; } + public bool IsPaid { get; set; } } } diff --git a/Contracts/ViewModels/SaleViewModel.cs b/Contracts/ViewModels/SaleViewModel.cs new file mode 100644 index 0000000..9c48256 --- /dev/null +++ b/Contracts/ViewModels/SaleViewModel.cs @@ -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; } + } +} diff --git a/Contracts/ViewModels/UserProductViewModel.cs b/Contracts/ViewModels/UserProductViewModel.cs index 2da47eb..ed882ac 100644 --- a/Contracts/ViewModels/UserProductViewModel.cs +++ b/Contracts/ViewModels/UserProductViewModel.cs @@ -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; } } } diff --git a/Contracts/ViewModels/UserViewModel.cs b/Contracts/ViewModels/UserViewModel.cs index 6b3ccd4..71d805f 100644 --- a/Contracts/ViewModels/UserViewModel.cs +++ b/Contracts/ViewModels/UserViewModel.cs @@ -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; } } } \ No newline at end of file diff --git a/DataModels/Models/ICartItem.cs b/DataModels/Models/ICartItem.cs new file mode 100644 index 0000000..4dba12d --- /dev/null +++ b/DataModels/Models/ICartItem.cs @@ -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; } + } +} diff --git a/DataModels/Models/IProduct.cs b/DataModels/Models/IProduct.cs index bfb12c0..c6e1652 100644 --- a/DataModels/Models/IProduct.cs +++ b/DataModels/Models/IProduct.cs @@ -13,7 +13,7 @@ namespace DataModels.Models bool IsBeingSold { get; } public double Rate { get; } int Amount { get; } - // будут браться через mediafilestorage так что скорее всего это тут не надо - // List MediaFiles { get; } + string Category { get; } + string Description { get; } } } diff --git a/DataModels/Models/IPurchase.cs b/DataModels/Models/IPurchase.cs index d862ed1..46645c6 100644 --- a/DataModels/Models/IPurchase.cs +++ b/DataModels/Models/IPurchase.cs @@ -9,8 +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; } } } diff --git a/DataModels/Models/ISale.cs b/DataModels/Models/ISale.cs new file mode 100644 index 0000000..d736e3b --- /dev/null +++ b/DataModels/Models/ISale.cs @@ -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; } + } +} diff --git a/DataModels/Models/IUser.cs b/DataModels/Models/IUser.cs index fb5020d..98be4d5 100644 --- a/DataModels/Models/IUser.cs +++ b/DataModels/Models/IUser.cs @@ -14,5 +14,6 @@ namespace DataModels.Models string Email { get; } DateTime Birthday { get; } bool OnlyImportantMails { get; } + int Bonus { get; } } } \ No newline at end of file diff --git a/DatabaseImplement/Database.cs b/DatabaseImplement/Database.cs index dbb6a25..4bb249e 100644 --- a/DatabaseImplement/Database.cs +++ b/DatabaseImplement/Database.cs @@ -21,7 +21,7 @@ namespace DatabaseImplement base.OnConfiguring(optionsBuilder); } - public virtual DbSet Roles { get; set; } = null!; + public virtual DbSet Roles { get; set; } = null!; public virtual DbSet Users { get; set; } = null!; public virtual DbSet Sells { get; set; } = null!; public virtual DbSet Purchases { get; set; } = null!; @@ -31,8 +31,10 @@ namespace DatabaseImplement public virtual DbSet Suppliers { get; set; } = null!; public virtual DbSet SupplierProducts { get; set; } = null!; public virtual DbSet MediaFiles { get; set; } = null!; - public virtual DbSet PurchaseProducts { get; set; } = null!; public virtual DbSet SellProducts { get; set; } = null!; public virtual DbSet SupplyDocs { get; set; } = null!; + public virtual DbSet CartItems { get; set; } = null!; + public virtual DbSet Sales { get; set; } = null!; + } } \ No newline at end of file diff --git a/DatabaseImplement/Implements/CartItemStorage.cs b/DatabaseImplement/Implements/CartItemStorage.cs new file mode 100644 index 0000000..8dadcc7 --- /dev/null +++ b/DatabaseImplement/Implements/CartItemStorage.cs @@ -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 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 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; + } + } + } +} diff --git a/DatabaseImplement/Implements/ProductStorage.cs b/DatabaseImplement/Implements/ProductStorage.cs index 2fc3c0c..7c3706f 100644 --- a/DatabaseImplement/Implements/ProductStorage.cs +++ b/DatabaseImplement/Implements/ProductStorage.cs @@ -35,20 +35,22 @@ namespace DatabaseImplement.Implements return null; } using var context = new Database(); - return context.Products - .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 GetFilteredList(ProductSearchModel model) { - if (!model.IsBeingSold.HasValue && !model.PriceFrom.HasValue && !model.PriceTo.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 + return context.Products.Include(x => x.Sale) .Where(x => x.Price <= model.Price) .ToList() .Select(x => x.GetViewModel) @@ -56,7 +58,7 @@ namespace DatabaseImplement.Implements } if (model.PriceFrom.HasValue && model.PriceTo.HasValue) { - return context.Products + return context.Products.Include(x => x.Sale) .Where(x => x.Price <= model.PriceTo && x.Price >= model.PriceFrom) .ToList() .Select(x => x.GetViewModel) @@ -64,7 +66,7 @@ namespace DatabaseImplement.Implements } if (model.PriceFrom.HasValue) { - return context.Products + return context.Products.Include(x => x.Sale) .Where(x => x.Price >= model.PriceFrom) .ToList() .Select(x => x.GetViewModel) @@ -72,7 +74,7 @@ namespace DatabaseImplement.Implements } if (model.PriceTo.HasValue) { - return context.Products + return context.Products.Include(x => x.Sale) .Where(x => x.Price <= model.PriceTo) .ToList() .Select(x => x.GetViewModel) @@ -80,7 +82,7 @@ namespace DatabaseImplement.Implements } if (model.Rate.HasValue) { - return context.Products + return context.Products.Include(x => x.Sale) .Where(x => x.Rate <= model.Rate) .ToList() .Select(x => x.GetViewModel) @@ -88,13 +90,21 @@ namespace DatabaseImplement.Implements } if (model.Amount.HasValue && model.IsBeingSold.HasValue) { - return context.Products + 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 + 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) @@ -104,7 +114,7 @@ namespace DatabaseImplement.Implements public List GetFullList() { using var context = new Database(); - return context.Products + return context.Products.Include(x => x.Sale) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -114,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; @@ -129,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) { diff --git a/DatabaseImplement/Implements/PurchaseStorage.cs b/DatabaseImplement/Implements/PurchaseStorage.cs index 2239727..ae2e23c 100644 --- a/DatabaseImplement/Implements/PurchaseStorage.cs +++ b/DatabaseImplement/Implements/PurchaseStorage.cs @@ -3,6 +3,7 @@ using Contracts.SearchModels; using Contracts.StorageContracts; using Contracts.ViewModels; using DatabaseImplement.Models; +using DataModels.Models; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; @@ -35,8 +36,6 @@ namespace DatabaseImplement.Implements } using var context = new Database(); return context.Purchases - .Include(x => x.Products) - .ThenInclude(x => x.Product) .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } @@ -44,8 +43,6 @@ namespace DatabaseImplement.Implements { using var context = new Database(); return context.Purchases - .Include(x => x.Products) - .ThenInclude(x => x.Product) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -53,7 +50,8 @@ namespace DatabaseImplement.Implements public List GetFilteredList(PurchaseSearchModel? model) { using var context = new Database(); - if (!model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue && !model.DateFrom.HasValue && !model.Status.HasValue) + if (model.UserId == Guid.Empty && !model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue + && !model.DateFrom.HasValue && !model.Status.HasValue) { return new(); } @@ -85,7 +83,7 @@ namespace DatabaseImplement.Implements if (model.DateFrom.HasValue && model.DateTo.HasValue) { return context.Purchases - .Where(x => x.DatePurchase <= model.DateTo && x.DatePurchase >= model.DateFrom) + .Where(x => x.DateCreated <= model.DateTo && x.DateCreated >= model.DateFrom) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -93,7 +91,7 @@ namespace DatabaseImplement.Implements if (model.DateFrom.HasValue) { return context.Purchases - .Where(x => x.DatePurchase >= model.DateFrom) + .Where(x => x.DateCreated >= model.DateFrom) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -101,14 +99,20 @@ namespace DatabaseImplement.Implements if (model.DateTo.HasValue) { return context.Purchases - .Where(x => x.DatePurchase <= model.DateTo) + .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 - .Include(x => x.Products) - .ThenInclude(x => x.Product) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -120,13 +124,31 @@ namespace DatabaseImplement.Implements var purchase = Purchase.Create(context, model); if (purchase == null) return null; + + + var cartItems = context.CartItems + .Where(x => x.PurchaseId == model.Id).ToList() + .Select(x => x.GetViewModel).ToList(); + + var products = new List(); + + 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) - { + public PurchaseViewModel? Update(PurchaseBindingModel model) + { using var context = new Database(); using var transaction = context.Database.BeginTransaction(); try @@ -139,7 +161,6 @@ namespace DatabaseImplement.Implements } purchase.Update(model); context.SaveChanges(); - purchase.UpdateProducts(context, model); transaction.Commit(); return purchase.GetViewModel; } @@ -149,64 +170,44 @@ namespace DatabaseImplement.Implements throw; } } - public PurchaseViewModel? AddProducts(PurchaseSearchModel purchaseModel, ProductSearchModel productModel, int count) - { - using var context = new Database(); - using var transaction = context.Database.BeginTransaction(); - try - { - var purchase = context.Purchases.FirstOrDefault(rec => - rec.Id == purchaseModel.Id); - var product = context.Products.FirstOrDefault(rec => - rec.Id == productModel.Id); - - if (purchase == null) - return null; - - if (product == null) - return null; - - if (count <= 0) - return null; - - context.PurchaseProducts.Add(new PurchaseProducts - { - Purchase = purchase, - Product = product, - Count = count - }); - context.SaveChanges(); - return purchase.GetViewModel; - } - catch { transaction.Rollback(); throw; } - - } - - public Dictionary GetProducts(PurchaseSearchModel model) + public List GetCartItems(PurchaseSearchModel model) { - Dictionary productsDict = new(); using var context = new Database(); - var purchase = context.Purchases.FirstOrDefault(rec => - rec.Id == model.Id); + var cartItems = context.CartItems + .Where(x => x.PurchaseId == model.Id).ToList() + .Select(x => x.GetViewModel).ToList(); - if (purchase == null) + if (cartItems == null) { return null; } - var purchaseProducts = context.PurchaseProducts - .Where(x => x.PurchaseId == model.Id) - .ToList(); - - foreach (var purchaseProduct in purchaseProducts) - { - productsDict.Add(purchaseProduct.ProductId, purchaseProduct.Count); - } - - return productsDict; + return cartItems; } + public List 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(); + + if (purchase.Products == null) + return null; + + foreach (var product in purchase.Products) + products.Add(product.GetViewModel); + + return products; + } } } diff --git a/DatabaseImplement/Implements/SaleStorage.cs b/DatabaseImplement/Implements/SaleStorage.cs new file mode 100644 index 0000000..fc8047f --- /dev/null +++ b/DatabaseImplement/Implements/SaleStorage.cs @@ -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 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 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; + } + } + } +} diff --git a/DatabaseImplement/Implements/UserStorage.cs b/DatabaseImplement/Implements/UserStorage.cs index 2755bbf..b5f3ac6 100644 --- a/DatabaseImplement/Implements/UserStorage.cs +++ b/DatabaseImplement/Implements/UserStorage.cs @@ -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(); + } } } \ No newline at end of file diff --git a/DatabaseImplement/Migrations/20240702133630_prod.Designer.cs b/DatabaseImplement/Migrations/20240702133630_prod.Designer.cs new file mode 100644 index 0000000..a7d5b8c --- /dev/null +++ b/DatabaseImplement/Migrations/20240702133630_prod.Designer.cs @@ -0,0 +1,503 @@ +// +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("20240702133630_prod")] + partial class prod + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240702133630_prod.cs b/DatabaseImplement/Migrations/20240702133630_prod.cs new file mode 100644 index 0000000..c4865c9 --- /dev/null +++ b/DatabaseImplement/Migrations/20240702133630_prod.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class prod : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Category", + table: "Products", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Description", + table: "Products", + type: "text", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Category", + table: "Products"); + + migrationBuilder.DropColumn( + name: "Description", + table: "Products"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240714172818_bonus.Designer.cs b/DatabaseImplement/Migrations/20240714172818_bonus.Designer.cs new file mode 100644 index 0000000..ad29b16 --- /dev/null +++ b/DatabaseImplement/Migrations/20240714172818_bonus.Designer.cs @@ -0,0 +1,506 @@ +// +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("20240714172818_bonus")] + partial class bonus + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240714172818_bonus.cs b/DatabaseImplement/Migrations/20240714172818_bonus.cs new file mode 100644 index 0000000..849ac16 --- /dev/null +++ b/DatabaseImplement/Migrations/20240714172818_bonus.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class bonus : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Bonus", + table: "Users", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Bonus", + table: "Users"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240714214732_sale.Designer.cs b/DatabaseImplement/Migrations/20240714214732_sale.Designer.cs new file mode 100644 index 0000000..7f4ce35 --- /dev/null +++ b/DatabaseImplement/Migrations/20240714214732_sale.Designer.cs @@ -0,0 +1,536 @@ +// +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("20240714214732_sale")] + partial class sale + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany() + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240714214732_sale.cs b/DatabaseImplement/Migrations/20240714214732_sale.cs new file mode 100644 index 0000000..065ced3 --- /dev/null +++ b/DatabaseImplement/Migrations/20240714214732_sale.cs @@ -0,0 +1,101 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class sale : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Description", + table: "Products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Category", + table: "Products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AddColumn( + name: "SaleId", + table: "Products", + type: "uuid", + nullable: true); + + migrationBuilder.CreateTable( + name: "Sales", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Category = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sales", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Products_SaleId", + table: "Products", + column: "SaleId"); + + migrationBuilder.AddForeignKey( + name: "FK_Products_Sales_SaleId", + table: "Products", + column: "SaleId", + principalTable: "Sales", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Products_Sales_SaleId", + table: "Products"); + + migrationBuilder.DropTable( + name: "Sales"); + + migrationBuilder.DropIndex( + name: "IX_Products_SaleId", + table: "Products"); + + migrationBuilder.DropColumn( + name: "SaleId", + table: "Products"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Products", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Category", + table: "Products", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + } + } +} diff --git a/DatabaseImplement/Migrations/20240715001559_sale2.Designer.cs b/DatabaseImplement/Migrations/20240715001559_sale2.Designer.cs new file mode 100644 index 0000000..527d50b --- /dev/null +++ b/DatabaseImplement/Migrations/20240715001559_sale2.Designer.cs @@ -0,0 +1,541 @@ +// +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("20240715001559_sale2")] + partial class sale2 + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240715001559_sale2.cs b/DatabaseImplement/Migrations/20240715001559_sale2.cs new file mode 100644 index 0000000..8218095 --- /dev/null +++ b/DatabaseImplement/Migrations/20240715001559_sale2.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class sale2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/DatabaseImplement/Migrations/20240715122630_sale-update.Designer.cs b/DatabaseImplement/Migrations/20240715122630_sale-update.Designer.cs new file mode 100644 index 0000000..998f1c3 --- /dev/null +++ b/DatabaseImplement/Migrations/20240715122630_sale-update.Designer.cs @@ -0,0 +1,548 @@ +// +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("20240715122630_sale-update")] + partial class saleupdate + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240715122630_sale-update.cs b/DatabaseImplement/Migrations/20240715122630_sale-update.cs new file mode 100644 index 0000000..109d05b --- /dev/null +++ b/DatabaseImplement/Migrations/20240715122630_sale-update.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class saleupdate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Name", + table: "Sales", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Value", + table: "Sales", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Name", + table: "Sales"); + + migrationBuilder.DropColumn( + name: "Value", + table: "Sales"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240715233951_sale3.Designer.cs b/DatabaseImplement/Migrations/20240715233951_sale3.Designer.cs new file mode 100644 index 0000000..0b0ffc5 --- /dev/null +++ b/DatabaseImplement/Migrations/20240715233951_sale3.Designer.cs @@ -0,0 +1,558 @@ +// +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("20240715233951_sale3")] + partial class sale3 + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240715233951_sale3.cs b/DatabaseImplement/Migrations/20240715233951_sale3.cs new file mode 100644 index 0000000..eee91f7 --- /dev/null +++ b/DatabaseImplement/Migrations/20240715233951_sale3.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class sale3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "End", + table: "Sales", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "FullDescription", + table: "Sales", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Start", + table: "Sales", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "End", + table: "Sales"); + + migrationBuilder.DropColumn( + name: "FullDescription", + table: "Sales"); + + migrationBuilder.DropColumn( + name: "Start", + table: "Sales"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240716134506_cartitem.Designer.cs b/DatabaseImplement/Migrations/20240716134506_cartitem.Designer.cs new file mode 100644 index 0000000..8f18b85 --- /dev/null +++ b/DatabaseImplement/Migrations/20240716134506_cartitem.Designer.cs @@ -0,0 +1,601 @@ +// +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("20240716134506_cartitem")] + partial class cartitem + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240716134506_cartitem.cs b/DatabaseImplement/Migrations/20240716134506_cartitem.cs new file mode 100644 index 0000000..a1e7bb4 --- /dev/null +++ b/DatabaseImplement/Migrations/20240716134506_cartitem.cs @@ -0,0 +1,68 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class cartitem : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "DatePurchase", + table: "Purchases", + type: "timestamp without time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp without time zone"); + + migrationBuilder.CreateTable( + name: "CartItems", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Cost = table.Column(type: "double precision", nullable: false), + DateCreated = table.Column(type: "timestamp without time zone", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + ProductName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CartItems", x => x.Id); + table.ForeignKey( + name: "FK_CartItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_ProductId", + table: "CartItems", + column: "ProductId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CartItems"); + + migrationBuilder.AlterColumn( + name: "DatePurchase", + table: "Purchases", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "timestamp without time zone", + oldNullable: true); + } + } +} diff --git a/DatabaseImplement/Migrations/20240717230804_cartitem2.Designer.cs b/DatabaseImplement/Migrations/20240717230804_cartitem2.Designer.cs new file mode 100644 index 0000000..bb8aa46 --- /dev/null +++ b/DatabaseImplement/Migrations/20240717230804_cartitem2.Designer.cs @@ -0,0 +1,598 @@ +// +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("20240717230804_cartitem2")] + partial class cartitem2 + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240717230804_cartitem2.cs b/DatabaseImplement/Migrations/20240717230804_cartitem2.cs new file mode 100644 index 0000000..31b72bb --- /dev/null +++ b/DatabaseImplement/Migrations/20240717230804_cartitem2.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class cartitem2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Cost", + table: "CartItems"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Cost", + table: "CartItems", + type: "double precision", + nullable: false, + defaultValue: 0.0); + } + } +} diff --git a/DatabaseImplement/Migrations/20240718212855_purchaseitems.Designer.cs b/DatabaseImplement/Migrations/20240718212855_purchaseitems.Designer.cs new file mode 100644 index 0000000..4827142 --- /dev/null +++ b/DatabaseImplement/Migrations/20240718212855_purchaseitems.Designer.cs @@ -0,0 +1,559 @@ +// +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("20240718212855_purchaseitems")] + partial class purchaseitems + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DatePurchase") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseImplement.Models.Purchase", "Purchase") + .WithMany() + .HasForeignKey("PurchaseId"); + + b.Navigation("Product"); + + b.Navigation("Purchase"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.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("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240718212855_purchaseitems.cs b/DatabaseImplement/Migrations/20240718212855_purchaseitems.cs new file mode 100644 index 0000000..97f0c8a --- /dev/null +++ b/DatabaseImplement/Migrations/20240718212855_purchaseitems.cs @@ -0,0 +1,88 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class purchaseitems : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PurchaseProducts"); + + migrationBuilder.AddColumn( + name: "PurchaseId", + table: "CartItems", + type: "uuid", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_PurchaseId", + table: "CartItems", + column: "PurchaseId"); + + migrationBuilder.AddForeignKey( + name: "FK_CartItems_Purchases_PurchaseId", + table: "CartItems", + column: "PurchaseId", + principalTable: "Purchases", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_CartItems_Purchases_PurchaseId", + table: "CartItems"); + + migrationBuilder.DropIndex( + name: "IX_CartItems_PurchaseId", + table: "CartItems"); + + migrationBuilder.DropColumn( + name: "PurchaseId", + table: "CartItems"); + + migrationBuilder.CreateTable( + name: "PurchaseProducts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + PurchaseId = table.Column(type: "uuid", nullable: false), + Count = table.Column(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_PurchaseProducts_ProductId", + table: "PurchaseProducts", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_PurchaseProducts_PurchaseId", + table: "PurchaseProducts", + column: "PurchaseId"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240718214141_purchasepatch.Designer.cs b/DatabaseImplement/Migrations/20240718214141_purchasepatch.Designer.cs new file mode 100644 index 0000000..1ca65fe --- /dev/null +++ b/DatabaseImplement/Migrations/20240718214141_purchasepatch.Designer.cs @@ -0,0 +1,562 @@ +// +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("20240718214141_purchasepatch")] + partial class purchasepatch + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DateClosed") + .HasColumnType("timestamp without time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseImplement.Models.Purchase", "Purchase") + .WithMany() + .HasForeignKey("PurchaseId"); + + b.Navigation("Product"); + + b.Navigation("Purchase"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.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("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240718214141_purchasepatch.cs b/DatabaseImplement/Migrations/20240718214141_purchasepatch.cs new file mode 100644 index 0000000..0a7f621 --- /dev/null +++ b/DatabaseImplement/Migrations/20240718214141_purchasepatch.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class purchasepatch : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "DatePurchase", + table: "Purchases", + newName: "DateClosed"); + + migrationBuilder.AddColumn( + name: "DateCreated", + table: "Purchases", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateCreated", + table: "Purchases"); + + migrationBuilder.RenameColumn( + name: "DateClosed", + table: "Purchases", + newName: "DatePurchase"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240720140718_purchase2.Designer.cs b/DatabaseImplement/Migrations/20240720140718_purchase2.Designer.cs new file mode 100644 index 0000000..f435080 --- /dev/null +++ b/DatabaseImplement/Migrations/20240720140718_purchase2.Designer.cs @@ -0,0 +1,565 @@ +// +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("20240720140718_purchase2")] + partial class purchase2 + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DateClosed") + .HasColumnType("timestamp without time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseImplement.Models.Purchase", "Purchase") + .WithMany() + .HasForeignKey("PurchaseId"); + + b.Navigation("Product"); + + b.Navigation("Purchase"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.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("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240720140718_purchase2.cs b/DatabaseImplement/Migrations/20240720140718_purchase2.cs new file mode 100644 index 0000000..f2df882 --- /dev/null +++ b/DatabaseImplement/Migrations/20240720140718_purchase2.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class purchase2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ProductCount", + table: "Purchases", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ProductCount", + table: "Purchases"); + } + } +} diff --git a/DatabaseImplement/Migrations/20240722134201_purchase3.Designer.cs b/DatabaseImplement/Migrations/20240722134201_purchase3.Designer.cs new file mode 100644 index 0000000..297db26 --- /dev/null +++ b/DatabaseImplement/Migrations/20240722134201_purchase3.Designer.cs @@ -0,0 +1,568 @@ +// +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("20240722134201_purchase3")] + partial class purchase3 + { + /// + 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.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Image") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsBeingSold") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("SaleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SaleId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("DateClosed") + .HasColumnType("timestamp without time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("IsPaid") + .HasColumnType("boolean"); + + b.Property("ProductCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateSell") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Sells"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SellId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SellId"); + + b.ToTable("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Deals") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplierId"); + + b.ToTable("SupplierProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DateArriving") + .HasColumnType("timestamp without time zone"); + + b.Property("DateComplete") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supplies"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("SupplyDocs"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SupplyId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Birthday") + .HasColumnType("timestamp without time zone"); + + b.Property("Bonus") + .HasColumnType("integer"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OnlyImportantMails") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("SecondName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseImplement.Models.Purchase", "Purchase") + .WithMany() + .HasForeignKey("PurchaseId"); + + b.Navigation("Product"); + + b.Navigation("Purchase"); + }); + + 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.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + + 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.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("SellProducts"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Sale", 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 + } + } +} diff --git a/DatabaseImplement/Migrations/20240722134201_purchase3.cs b/DatabaseImplement/Migrations/20240722134201_purchase3.cs new file mode 100644 index 0000000..d7d899c --- /dev/null +++ b/DatabaseImplement/Migrations/20240722134201_purchase3.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class purchase3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsPaid", + table: "Purchases", + type: "boolean", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsPaid", + table: "Purchases"); + } + } +} diff --git a/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs b/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs index db099bf..953543e 100644 --- a/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -22,6 +22,40 @@ namespace DatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("PurchaseId"); + + b.ToTable("CartItems"); + }); + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => { b.Property("Id") @@ -51,6 +85,12 @@ namespace DatabaseImplement.Migrations b.Property("Amount") .HasColumnType("integer"); + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + b.Property("IsBeingSold") .HasColumnType("boolean"); @@ -64,8 +104,13 @@ namespace DatabaseImplement.Migrations b.Property("Rate") .HasColumnType("double precision"); + b.Property("SaleId") + .HasColumnType("uuid"); + b.HasKey("Id"); + b.HasIndex("SaleId"); + b.ToTable("Products"); }); @@ -78,9 +123,18 @@ namespace DatabaseImplement.Migrations b.Property("Cost") .HasColumnType("double precision"); - b.Property("DatePurchase") + b.Property("DateClosed") .HasColumnType("timestamp without time zone"); + b.Property("DateCreated") + .HasColumnType("timestamp without time zone"); + + b.Property("IsPaid") + .HasColumnType("boolean"); + + b.Property("ProductCount") + .HasColumnType("integer"); + b.Property("Status") .HasColumnType("integer"); @@ -94,30 +148,6 @@ namespace DatabaseImplement.Migrations b.ToTable("Purchases"); }); - modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Count") - .HasColumnType("integer"); - - b.Property("ProductId") - .HasColumnType("uuid"); - - b.Property("PurchaseId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("PurchaseId"); - - b.ToTable("PurchaseProducts"); - }); - modelBuilder.Entity("DatabaseImplement.Models.Role", b => { b.Property("Id") @@ -133,6 +163,41 @@ namespace DatabaseImplement.Migrations b.ToTable("Roles"); }); + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("End") + .HasColumnType("timestamp without time zone"); + + b.Property("FullDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Start") + .HasColumnType("timestamp without time zone"); + + b.Property("Value") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + modelBuilder.Entity("DatabaseImplement.Models.Sell", b => { b.Property("Id") @@ -304,6 +369,9 @@ namespace DatabaseImplement.Migrations b.Property("Birthday") .HasColumnType("timestamp without time zone"); + b.Property("Bonus") + .HasColumnType("integer"); + b.Property("Email") .IsRequired() .HasColumnType("text"); @@ -333,6 +401,23 @@ namespace DatabaseImplement.Migrations b.ToTable("Users"); }); + modelBuilder.Entity("DatabaseImplement.Models.CartItem", b => + { + b.HasOne("DatabaseImplement.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseImplement.Models.Purchase", "Purchase") + .WithMany() + .HasForeignKey("PurchaseId"); + + b.Navigation("Product"); + + b.Navigation("Purchase"); + }); + modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b => { b.HasOne("DatabaseImplement.Models.Product", "Product") @@ -344,6 +429,15 @@ namespace DatabaseImplement.Migrations b.Navigation("Product"); }); + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.HasOne("DatabaseImplement.Models.Sale", "Sale") + .WithMany("Products") + .HasForeignKey("SaleId"); + + b.Navigation("Sale"); + }); + modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => { b.HasOne("DatabaseImplement.Models.User", "User") @@ -355,25 +449,6 @@ namespace DatabaseImplement.Migrations 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") @@ -462,12 +537,10 @@ namespace DatabaseImplement.Migrations modelBuilder.Entity("DatabaseImplement.Models.Product", b => { - b.Navigation("PurchaseProducts"); - b.Navigation("SellProducts"); }); - modelBuilder.Entity("DatabaseImplement.Models.Purchase", b => + modelBuilder.Entity("DatabaseImplement.Models.Sale", b => { b.Navigation("Products"); }); diff --git a/DatabaseImplement/Models/CartItem.cs b/DatabaseImplement/Models/CartItem.cs new file mode 100644 index 0000000..7db0737 --- /dev/null +++ b/DatabaseImplement/Models/CartItem.cs @@ -0,0 +1,83 @@ +using Contracts.BindingModels; +using Contracts.ViewModels; +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Xml.Linq; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DatabaseImplement.Models +{ + public class CartItem : ICartItem + { + public Guid Id { get; set; } + [Required] + public Guid UserId { get; set; } + [Required] + public int Count { get; set; } + public Guid? PurchaseId { get; set; } + [Required] + public DateTime DateCreated { get; set; } + [Required] + public Guid ProductId { get; set; } + [Required] + public string ProductName { get; set; } = string.Empty; + public virtual Product? Product { get; set; } + public virtual Purchase? Purchase { get; set; } + public static CartItem Create(Database context, CartItemBindingModel model) + { + return new CartItem() + { + Id = model.Id, + UserId = model.UserId, + Count = model.Count, + DateCreated = model.DateCreated, + ProductId = model.ProductId, + ProductName = model.ProductName, + PurchaseId = model.PurchaseId, + }; + } + public void Update(CartItemBindingModel model) + { + if (model is null) + { + throw new ArgumentNullException("Update CartItem: binding model is null"); + } + Count = model.Count; + PurchaseId = model.PurchaseId; + } + public CartItemViewModel GetViewModel + { + get + { + var context = new Database(); + return new() + { + Id = Id, + UserId = UserId, + DateCreated = DateCreated, + ProductId = ProductId, + ProductName = ProductName, + Count = Count, + PurchaseId = PurchaseId, + }; + } + } + public CartItemBindingModel GetBindingModel() => new() + { + Id = Id, + UserId = UserId, + DateCreated = DateCreated, + ProductId = ProductId, + ProductName = ProductName, + Count = Count, + PurchaseId = PurchaseId, + }; + } +} diff --git a/DatabaseImplement/Models/Product.cs b/DatabaseImplement/Models/Product.cs index 552b6cd..84dd390 100644 --- a/DatabaseImplement/Models/Product.cs +++ b/DatabaseImplement/Models/Product.cs @@ -15,19 +15,21 @@ namespace DatabaseImplement.Models public class Product : IProduct { [Required] - public Guid Id { get; set; } + public Guid Id { get; set; } + public Guid? SaleId { get; set; } [Required] public string Name { get; set; } = string.Empty; [Required] - public double Price { get; set; } + public double Price { get; set; } [Required] public double Rate { get; set; } [Required] public bool IsBeingSold { get; set; } - [Required] + public string? Category { get; set; } + public string? Description { get; set; } + public virtual Sale? Sale { get; set; } + [Required] public int Amount { get; set; } - [ForeignKey("ProductId")] - public virtual List PurchaseProducts { get; set; } = new(); [ForeignKey("ProductId")] public virtual List SellProducts { get; set; } = new(); public ProductBindingModel GetBindingModel() => new() @@ -37,8 +39,11 @@ namespace DatabaseImplement.Models Price = Price, Rate = Rate, IsBeingSold = IsBeingSold, - Amount = Amount - }; + Amount = Amount, + Category = Category, + Description = Description, + SaleId = SaleId + }; public static Product ToProductFromView(ProductViewModel model, Product product) => new() { @@ -47,8 +52,10 @@ namespace DatabaseImplement.Models Price = model.Price, Rate = model.Rate, IsBeingSold = model.IsBeingSold, - Amount = model.Amount - }; + Amount = model.Amount, + Category = model.Category, + SaleId = model.SaleId + }; public static Product ToProductFromBinding(ProductBindingModel model, Product product) => new() { @@ -57,8 +64,11 @@ namespace DatabaseImplement.Models Price = model.Price, Rate = model.Rate, IsBeingSold = model.IsBeingSold, - Amount = model.Amount - }; + Amount = model.Amount, + Description = model.Description, + Category = model.Category, + SaleId = model.SaleId + }; public static Product Create(Database context, ProductBindingModel model) { @@ -69,7 +79,10 @@ namespace DatabaseImplement.Models Price = model.Price, Rate = model.Rate, IsBeingSold = model.IsBeingSold, - Amount = model.Amount + Amount = model.Amount, + Description = model.Description, + Category = model.Category, + SaleId = model.SaleId }; } @@ -86,21 +99,30 @@ namespace DatabaseImplement.Models Rate = model.Rate; IsBeingSold = model.IsBeingSold; Amount = model.Amount; - } + Description = model.Description; + Category = model.Category; + SaleId = model.SaleId; + } public ProductViewModel GetViewModel { get { - var context = new Database(); - return new() - { - Id = Id, - Name = Name, - Price = Price, - IsBeingSold = IsBeingSold, - Rate = Rate, - Amount = Amount - }; + double saleValue = 0; + if (Sale is not null) + saleValue = Sale.Value; + return new() + { + Id = Id, + Name = Name, + Price = Price, + IsBeingSold = IsBeingSold, + Rate = Rate, + Amount = Amount, + Description = Description, + Category = Category, + SaleId = SaleId, + ActualPrice = Price / 100 * (100 - saleValue) + }; } } } diff --git a/DatabaseImplement/Models/Purchase.cs b/DatabaseImplement/Models/Purchase.cs index e02aec8..721d4ef 100644 --- a/DatabaseImplement/Models/Purchase.cs +++ b/DatabaseImplement/Models/Purchase.cs @@ -19,79 +19,77 @@ namespace DatabaseImplement.Models public class Purchase : IPurchase { public Guid Id { get; set; } - [Required] - public DateTime DatePurchase { get; set; } + [Required] + public DateTime DateCreated { get; set; } + public DateTime? DateClosed { get; set; } [Required] public Guid UserId { get; set; } public double Cost { get; set; } + public int ProductCount { get; set; } [Required] public PurchaseStatus Status { get; private set; } = PurchaseStatus.Unknown; - private Dictionary? _purchaseProducts = null; + [Required] + public bool IsPaid { get; set; } public virtual User? User { get; set; } - [DataMember] [NotMapped] - public Dictionary PurchaseProducts - { - get - { - if (_purchaseProducts == null) - { - _purchaseProducts = Products.ToDictionary(e => e.ProductId, e => (e.Product as IProduct, e.Count)); - } - return _purchaseProducts; - } - set { } - } - [ForeignKey("PurchaseId")] - public virtual List Products { get; set; } = new(); + public List Products { get; set; } public static Purchase Create(Database context, PurchaseBindingModel model) { return new Purchase() { - DatePurchase = DateTime.Now, - UserId = Guid.NewGuid(), - Status = PurchaseStatus.Unknown, - + DateCreated = model.DateCreated, + UserId = model.UserId, + Status = model.Status, + Cost = model.Cost, + ProductCount = model.ProductCount, + IsPaid = model.IsPaid, }; } public PurchaseBindingModel GetBindingModel => new() { Id = Id, - DatePurchase = DatePurchase, + DateCreated = DateCreated, UserId = UserId, - PurchaseProducts = PurchaseProducts, Status = Status, - Cost = Cost - }; + Cost = Cost, + ProductCount = ProductCount, + IsPaid = IsPaid, + }; public PurchaseViewModel GetViewModel => new() { Id = Id, - DatePurchase = DatePurchase, + DateCreated = DateCreated, + DateClosed = DateClosed, UserId = UserId, - PurchaseProducts = PurchaseProducts, Status = Status, - Cost = Cost + ProductCount = ProductCount, + Cost = Cost, + IsPaid = IsPaid, }; public static Purchase ToPurchaseFromView(PurchaseViewModel model, Purchase purchase) => new() { Id = model.Id, - DatePurchase = model.DatePurchase, + DateCreated = model.DateCreated, + DateClosed = model.DateClosed, UserId = model.UserId, - PurchaseProducts = model.PurchaseProducts, Status = model.Status, - Cost = model.Cost + ProductCount = model.ProductCount, + Cost = model.Cost, + IsPaid = model.IsPaid, }; public static Purchase ToPurchaseFromBinding(PurchaseBindingModel model, Purchase purchase) => new() { Id = model.Id, - DatePurchase = model.DatePurchase, + DateCreated = model.DateCreated, + DateClosed = model.DateClosed, UserId = model.UserId, - PurchaseProducts = model.PurchaseProducts, Status = model.Status, - Cost = model.Cost + ProductCount = model.ProductCount, + Cost = model.Cost, + IsPaid = model.IsPaid, }; public void Update(PurchaseBindingModel model) @@ -101,43 +99,11 @@ namespace DatabaseImplement.Models throw new ArgumentNullException("Update purchase: binding model is null"); } - DatePurchase = model.DatePurchase; - UserId = model.UserId; - PurchaseProducts = model.PurchaseProducts; + DateClosed = model.DateClosed; Status = model.Status; + ProductCount = model.ProductCount; Cost = model.Cost; - + IsPaid = model.IsPaid; } - public void UpdateProducts(Database context, PurchaseBindingModel model) - { - var purchaseProducts = context.PurchaseProducts.Where(rec => - rec.Id == model.Id).ToList(); - if (purchaseProducts != null && purchaseProducts.Count > 0) - { // удалили те, которых нет в модели - context.PurchaseProducts.RemoveRange(purchaseProducts.Where(rec - => !model.PurchaseProducts.ContainsKey(rec.ProductId))); - context.SaveChanges(); - // обновили количество у существующих записей - foreach (var updateProduct in purchaseProducts) - { - updateProduct.Count = model.PurchaseProducts[updateProduct.ProductId].Item2; - model.PurchaseProducts.Remove(updateProduct.ProductId); - } - context.SaveChanges(); - } - var purchase = context.Purchases.First(x => x.Id == Id); - foreach (var pc in model.PurchaseProducts) - { - context.PurchaseProducts.Add(new PurchaseProducts - { - Purchase = purchase, - Product = context.Products.First(x => x.Id == pc.Key), - Count = pc.Value.Item2 - }); - context.SaveChanges(); - } - _purchaseProducts = null; - } - } } diff --git a/DatabaseImplement/Models/PurchaseProducts.cs b/DatabaseImplement/Models/PurchaseProducts.cs deleted file mode 100644 index 58049cb..0000000 --- a/DatabaseImplement/Models/PurchaseProducts.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DatabaseImplement.Models -{ - public class PurchaseProducts - { - public Guid Id { get; set; } - [Required] - public Guid PurchaseId { get; set; } - [Required] - public Guid ProductId { get; set; } - [Required] - public int Count { get; set; } - public virtual Product Product { get; set; } = new(); - public virtual Purchase Purchase { get; set; } = new(); - - } -} diff --git a/DatabaseImplement/Models/Sale.cs b/DatabaseImplement/Models/Sale.cs new file mode 100644 index 0000000..7f6b2c9 --- /dev/null +++ b/DatabaseImplement/Models/Sale.cs @@ -0,0 +1,123 @@ +using Contracts.BindingModels; +using Contracts.ViewModels; +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Xml.Linq; + +namespace DatabaseImplement.Models +{ + public class Sale : ISale + { + [Required] + public Guid Id { get; set; } + [Required] + public string Name { get; set; } + public string? Category { get; set; } + [Required] + public string Description { get; set; } = string.Empty; + [Required] + public string FullDescription { get; set; } = string.Empty; + [Required] + public int Value { get; set; } + [Required] + public DateTime Start { get; set; } + [Required] + public DateTime End { get; set; } + + [ForeignKey("SaleId")] + public ICollection Products { get; set; } = new List(); + public SaleBindingModel GetBindingModel() => new() + { + Id = Id, + Category = Category, + Description = Description, + FullDescription = FullDescription, + Name = Name, + Value = Value, + Start = Start, + End = End + }; + + public static Sale ToSaleFromView(SaleBindingModel model, Sale sale) => new() + { + Id = model.Id, + Category = model.Category, + Description = model.Description, + FullDescription = model.FullDescription, + Name = model.Name, + Value = model.Value, + Start = model.Start, + End = model.End + }; + + public static Sale ToProductFromBinding(SaleBindingModel model, Sale sale) => new() + { + Id = model.Id, + Category = model.Category, + Description = model.Description, + FullDescription = model.FullDescription, + Name = model.Name, + Value = model.Value, + Start = model.Start, + End = model.End + }; + + public static Sale Create(Database context, SaleBindingModel model) + { + return new Sale() + { + Id = model.Id, + Category = model.Category, + Description = model.Description, + FullDescription = model.FullDescription, + Name = model.Name, + Value = model.Value, + Start = model.Start, + End = model.End + }; + } + + + public void Update(SaleBindingModel model) + { + if (model is null) + { + throw new ArgumentNullException("Update product: binding model is null"); + } + + Category = model.Category; + Description = model.Description; + FullDescription = model.FullDescription; + Name = model.Name; + Value = model.Value; + Start = model.Start; + End = model.End; + } + public SaleViewModel GetViewModel + { + get + { + var context = new Database(); + return new() + { + Id = Id, + Category = Category, + Description = Description, + FullDescription = FullDescription, + Name = Name, + Value = Value, + Start = Start, + End = End + }; + } + } + } +} diff --git a/DatabaseImplement/Models/SupplierProduct.cs b/DatabaseImplement/Models/SupplierProduct.cs index 95ce3af..14bccd8 100644 --- a/DatabaseImplement/Models/SupplierProduct.cs +++ b/DatabaseImplement/Models/SupplierProduct.cs @@ -19,4 +19,4 @@ namespace DatabaseImplement.Models public virtual Supplier Supplier { get; set; } = new(); public virtual Product Product { get; set; } = new(); } -} +} \ No newline at end of file diff --git a/DatabaseImplement/Models/User.cs b/DatabaseImplement/Models/User.cs index 4de0fd1..174be99 100644 --- a/DatabaseImplement/Models/User.cs +++ b/DatabaseImplement/Models/User.cs @@ -28,6 +28,9 @@ namespace DatabaseImplement.Models [Required] public string Email { get; set; } = string.Empty; + [Required] + public int Bonus { get; set; } + [Required] public DateTime Birthday { get; set; } @@ -44,7 +47,8 @@ namespace DatabaseImplement.Models PasswordHash = PasswordHash, Birthday = Birthday, OnlyImportantMails = OnlyImportantMails, - Role = Role?.GetBindingModel() ?? new() + Role = Role?.GetBindingModel() ?? new(), + Bonus = Bonus, }; public static User ToUserFromView(UserViewModel model, Role role) => new() @@ -54,7 +58,8 @@ namespace DatabaseImplement.Models SecondName = model.SecondName, Email = model.Email, Birthday = model.Birthday, - Role = role + Role = role, + Bonus = model.Bonus }; public static User ToUserFromBinding(UserBindingModel model, Role role) => new() @@ -66,7 +71,8 @@ namespace DatabaseImplement.Models PasswordHash = model.PasswordHash, Birthday = model.Birthday, OnlyImportantMails = model.OnlyImportantMails, - Role = role + Role = role, + Bonus = model.Bonus }; public void Update(UserBindingModel model, Role role) @@ -83,6 +89,7 @@ namespace DatabaseImplement.Models Birthday = model.Birthday; OnlyImportantMails = model.OnlyImportantMails; Role = role ?? Role; - } + Bonus = model.Bonus; + } } } \ No newline at end of file diff --git a/RestAPI/Controllers/CartItemController.cs b/RestAPI/Controllers/CartItemController.cs new file mode 100644 index 0000000..313a926 --- /dev/null +++ b/RestAPI/Controllers/CartItemController.cs @@ -0,0 +1,147 @@ +using BusinessLogic.BusinessLogic; +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.Exceptions; +using Contracts.SearchModels; +using Contracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace RestAPI.Controllers +{ + [Route("[controller]/[action]")] + [ApiController] + public class CartItemController : Controller + { + private readonly ICartItemLogic _cartItemLogic; + private readonly IProductLogic _productLogic; + private readonly ILogger _logger; + public CartItemController(ILogger logger, ICartItemLogic cartItemLogic, IProductLogic productLogic) + { + _logger = logger; + _cartItemLogic = cartItemLogic; + _productLogic = productLogic; + } + [HttpGet] + public List GetFullList(Guid userId) + { + try + { + return _cartItemLogic.ReadElements(new CartItemSearchModel(){ UserId = userId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка"); + throw; + } + } + [HttpGet] + public CartItemViewModel GetElement(Guid id) + { + try + { + return _cartItemLogic.ReadElement(new CartItemSearchModel() { Id = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения элемента корзины"); + throw; + } + } + [HttpGet] + public ProductViewModel GetProduct(Guid cartItemId) + { + try + { + var item = _cartItemLogic.ReadElement(new CartItemSearchModel() { Id = cartItemId }); + return _productLogic.ReadElement(new ProductSearchModel() { Id = item.ProductId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения продукта"); + throw; + } + } + [HttpPost] + public IResult Create([FromBody] CartItemBindingModel model) + { + try + { + var res = _cartItemLogic.Create(model); + return Results.Ok(res); + } + catch (AccountException ex) + { + _logger.LogWarning(ex, "Wrong data"); + return Results.BadRequest(ex.Message); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error create item"); + return Results.Problem(ex.Message); + } + } + [HttpPatch] + public IResult Update([FromBody] CartItemBindingModel model) + { + try + { + var res = _cartItemLogic.Update(model); + return Results.Ok(res); + } + catch (AccountException ex) + { + _logger.LogWarning(ex, "Wrong update data"); + return Results.BadRequest(ex.Message); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error update cart item"); + return Results.Problem(ex.Message); + } + } + [HttpDelete] + public IResult Delete(Guid id) + { + try + { + var res = _cartItemLogic.Delete(new() { Id = id }); + return Results.Ok(res); + } + catch (ElementNotFoundException ex) + { + _logger.LogInformation(ex, "Item not found"); + return Results.NoContent(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete item"); + return Results.Problem(ex.Message); + } + } + [HttpDelete] + public IResult DeleteAll() + { + try + { + var list = _cartItemLogic.ReadElements(null); + var res = new List(); + + foreach (var element in list) + { + _cartItemLogic.Delete(new() { Id = element.Id }); + } + return Results.Ok(res); + } + catch (ElementNotFoundException ex) + { + _logger.LogInformation(ex, "Item not found"); + return Results.NoContent(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error delete item"); + return Results.Problem(ex.Message); + } + } + } +} diff --git a/RestAPI/Controllers/MediaFileController.cs b/RestAPI/Controllers/MediaFileController.cs index d6f1445..61cc0eb 100644 --- a/RestAPI/Controllers/MediaFileController.cs +++ b/RestAPI/Controllers/MediaFileController.cs @@ -30,7 +30,7 @@ namespace RestAPI.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка продуктов"); + _logger.LogError(ex, "Ошибка получения списка"); throw; } } diff --git a/RestAPI/Controllers/ProductController.cs b/RestAPI/Controllers/ProductController.cs index e9feeb3..d1dd71a 100644 --- a/RestAPI/Controllers/ProductController.cs +++ b/RestAPI/Controllers/ProductController.cs @@ -22,17 +22,18 @@ namespace RestAPI.Controllers _product = productLogic; } [HttpGet] - public List? GetList(string? search, double? pricefrom, double? priceto) + public List? GetList(string? search, string? category, double? pricefrom, double? priceto) { try { - if (search == null && pricefrom == null && priceto == null) + if (string.IsNullOrEmpty(search) && string.IsNullOrEmpty(category) && pricefrom == null && priceto == null) return _product.ReadList(null); else return _product.ReadList(new ProductSearchModel() { Name = search, + Category = category, PriceFrom = pricefrom, PriceTo = priceto }); diff --git a/RestAPI/Controllers/PurchaseController.cs b/RestAPI/Controllers/PurchaseController.cs index 3be2e5c..81bf079 100644 --- a/RestAPI/Controllers/PurchaseController.cs +++ b/RestAPI/Controllers/PurchaseController.cs @@ -5,6 +5,7 @@ using Contracts.Exceptions; using Contracts.SearchModels; using Contracts.ViewModels; using DatabaseImplement.Models; +using DataModels.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -17,23 +18,27 @@ namespace RestAPI.Controllers { private readonly ILogger _logger; private readonly IPurchaseLogic _purchaseLogic; + private readonly IBillLogic _billLogic; - public PurchaseController(ILogger logger, IPurchaseLogic purchaseLogic) + public PurchaseController(ILogger logger, IPurchaseLogic purchaseLogic, IBillLogic billLogic) { _logger = logger; _purchaseLogic = purchaseLogic; + _billLogic = billLogic; } [HttpGet] - public List? GetList(double? costfrom, double? costto, DateTime? datefrom, DateTime? dateto) + public List? GetList(Guid id, Guid userId, double? costfrom, double? costto, DateTime? datefrom, DateTime? dateto) { try { - if (costfrom == null && costto == null && datefrom == null && dateto == null) + if (id == Guid.Empty && userId == Guid.Empty && costfrom == null && costto == null && datefrom == null && dateto == null) return _purchaseLogic.ReadElements(null); else return _purchaseLogic.ReadElements(new PurchaseSearchModel() { + Id = id, + UserId = userId, CostFrom = costfrom, CostTo = costto, DateFrom = datefrom, @@ -42,7 +47,7 @@ namespace RestAPI.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка продуктов"); + _logger.LogError(ex, "Ошибка получения списка покупок"); throw; } } @@ -55,37 +60,57 @@ namespace RestAPI.Controllers return _purchaseLogic.ReadElement(new PurchaseSearchModel() { Id = id }); } catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения покупки"); + throw; + } + } + + [HttpGet] + public List GetProducts(Guid purchaseid) + { + try + { + return _purchaseLogic.GetProducts(new PurchaseSearchModel() { Id = purchaseid }); + } + catch (Exception ex) { _logger.LogError(ex, "Ошибка получения продукта"); throw; } } [HttpPost] - public PurchaseViewModel Create(Guid UserId) + public IResult Create([FromBody] PurchaseBindingModel model) { try { - var purchase = _purchaseLogic.Create(new PurchaseBindingModel() - { - Cost = 0, - DatePurchase = DateTime.Now, - UserId = UserId - }); + var purchase = _purchaseLogic.Create(model); - return new PurchaseViewModel() - { - DatePurchase = purchase.DatePurchase, - UserId = purchase.UserId, - Cost = purchase.Cost, - }; + return Results.Ok(purchase); } catch (Exception ex) { - _logger.LogError(ex, "Error update purchase"); - return null; + _logger.LogError(ex, "Error create purchase"); + return Results.Problem(ex.Message); } } - + + [HttpPost] + public IResult CreateBill([FromBody] BillViewModel model) + { + try + { + _billLogic.CreateBill(model); + + return Results.Ok(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error create bill"); + throw; + } + } + [HttpPatch] public PurchaseViewModel Update([FromBody] PurchaseBindingModel model) { @@ -96,8 +121,7 @@ namespace RestAPI.Controllers { Id = res.Id, Cost = res.Cost, - DatePurchase = res.DatePurchase, - PurchaseProducts = res.PurchaseProducts, + DateClosed = res.DateClosed, UserId = res.UserId, }; } @@ -108,45 +132,5 @@ namespace RestAPI.Controllers return null; } } - [HttpPatch] - public PurchaseViewModel AddProducts(Guid purchaseId, Guid productId, int count) - { - try - { - var purchase = _purchaseLogic.AddProduct( - new PurchaseSearchModel() - { - Id = purchaseId - }, - new ProductSearchModel() - { - Id = productId - }, - count); - - return new PurchaseViewModel() - { - Id = purchase.Id, - Cost = purchase.Cost, - DatePurchase = purchase.DatePurchase, - PurchaseProducts = purchase.PurchaseProducts, - UserId = purchase.UserId, - }; - } - - catch (Exception ex) - { - _logger.LogError(ex, "Error update purchase"); - return null; - } - } - [HttpGet] - public Dictionary GetProducts(Guid productId) - { - return _purchaseLogic.GetProducts(new PurchaseSearchModel - { - Id = productId, - }); - } } } diff --git a/RestAPI/Controllers/SaleController.cs b/RestAPI/Controllers/SaleController.cs new file mode 100644 index 0000000..1be0e9b --- /dev/null +++ b/RestAPI/Controllers/SaleController.cs @@ -0,0 +1,100 @@ +using BusinessLogic.BusinessLogic; +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.Exceptions; +using Contracts.SearchModels; +using Contracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace RestAPI.Controllers +{ + [Route("[controller]/[action]")] + [ApiController] + public class SaleController : Controller + { + private readonly ILogger _logger; + private readonly ISaleLogic _saleLogic; + private readonly IProductLogic _productLogic; + + public SaleController(ILogger logger, ISaleLogic saleLogic, IProductLogic productLogic) + { + _logger = logger; + _saleLogic = saleLogic; + _productLogic = productLogic; + } + + [HttpGet] + public List? GetList(string? category) + { + try + { + if (string.IsNullOrEmpty(category)) + return _saleLogic.ReadElements(null); + + else + return _saleLogic.ReadElements(new SaleSearchModel() + { + Category = category + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка акций"); + throw; + } + } + + [HttpGet] + public SaleViewModel GetSale(Guid id) + { + try + { + return _saleLogic.ReadElement(new SaleSearchModel() { Id = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения акции"); + throw; + } + } + + [HttpGet] + public SaleViewModel GetSaleByProduct(Guid id) + { + try + { + var product = _productLogic.ReadElement(new ProductSearchModel() { Id = id }); + if (product.SaleId == null) + { + return null; + } + return _saleLogic.ReadElement(new SaleSearchModel() { Id = product.SaleId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения акции"); + throw; + } + } + + [HttpPost] + public IResult CreateSale([FromBody] SaleBindingModel model) + { + try + { + var res = _saleLogic.Create(model); + return Results.Ok(res); + } + catch (AccountException ex) + { + _logger.LogWarning(ex, "Wrong data"); + return Results.BadRequest(ex.Message); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error create sale"); + return Results.Problem(ex.Message); + } + } + } +} diff --git a/RestAPI/Controllers/UserController.cs b/RestAPI/Controllers/UserController.cs index 0047df3..f10e082 100644 --- a/RestAPI/Controllers/UserController.cs +++ b/RestAPI/Controllers/UserController.cs @@ -4,6 +4,7 @@ using Contracts.BindingModels; using Contracts.BusinessLogicContracts; using Contracts.Exceptions; using Contracts.SearchModels; +using Contracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace RestAPI.Controllers @@ -140,7 +141,22 @@ namespace RestAPI.Controllers return Results.Problem(ex.Message); } } - } + + [HttpPatch] + public void UpdateBonus([FromBody] BonusUpdateBindingModel model) + { + try + { + _userLogic.UpdateBonus(model); + } + + catch (Exception ex) + { + _logger.LogError(ex, "Error update purchase"); + return; + } + } + } public record class UserData(string email, string password); public record class VerifyCodeData(string code); diff --git a/RestAPI/Program.cs b/RestAPI/Program.cs index 19c5492..a1747ab 100644 --- a/RestAPI/Program.cs +++ b/RestAPI/Program.cs @@ -19,20 +19,25 @@ builder.Logging.AddLog4Net("log4net.config"); #region DI builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddSingleton(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -69,6 +74,8 @@ mailSender?.SetupMailOptions(new() #endregion Setup config + +System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/WebApp/Pages/Cart.cshtml b/WebApp/Pages/Cart.cshtml index 93f400c..fdb5ebb 100644 --- a/WebApp/Pages/Cart.cshtml +++ b/WebApp/Pages/Cart.cshtml @@ -6,10 +6,10 @@

Корзина

- @* @if (Model.Amount == 0) + @if (Model.cartItemsView == null! || Model.cartItemsView.Count == 0) {

Ваша корзина пуста.

- } *@ + } else { @@ -23,34 +23,102 @@ - @* @foreach (var item in Model.CartItems) + + @foreach (var item in Model.cartItemsView) { + - + + - + + + + + + + - } *@ + }
@item.Product.Price.ToString("C")@Model.GetProduct(item.Id).ActualPrice - + @item.Count @((item.Product.Price * item.Quantity).ToString("C"))@(item.Count * @Model.GetProduct(item.Id).ActualPrice) - +
+ + +
- @*

Итого: @Model.TotalPrice.ToString("C")

*@ +

Сумма заказа: руб.

- Оформить заказ +
+ + + + +
} -
\ No newline at end of file + + + + \ No newline at end of file diff --git a/WebApp/Pages/Cart.cshtml.cs b/WebApp/Pages/Cart.cshtml.cs index 72928b1..89f8711 100644 --- a/WebApp/Pages/Cart.cshtml.cs +++ b/WebApp/Pages/Cart.cshtml.cs @@ -1,7 +1,10 @@ +using Contracts.BindingModels; using Contracts.ViewModels; +using DataModels.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Routing.Constraints; using System.Diagnostics.Eventing.Reader; using WebApp.Helpers; @@ -10,26 +13,49 @@ namespace WebApp.Pages [Authorize(Roles = Roles.User)] public class CartModel : PageModel { - public PurchaseViewModel purchaseModel = null; - public Dictionary Products { get; set; } - public void OnGet(Guid id, int count) + [BindProperty] + public List cartItems { get; set; } + public List cartItemsView { get; set; } + public PaymentViewModel paymentViewModel { get; set; } + public void OnGet() { - if (purchaseModel == null) + var id = this.GetUserId(); + if (id is null) { - purchaseModel = APIClient.GetRequest($"Purchase/Create/{this.GetUserId()}"); - - APIClient.GetRequest($"Purchase/AddProducts?purchaseId={purchaseModel.Id}?productId={id}?count={count}"); + return; } - purchaseModel = APIClient.GetRequest($"Purchase/Get/"); - Products = APIClient.GetRequest>($"Purchase/GetProducts?id={purchaseModel.Id}"); + cartItemsView = APIClient.GetRequest>($"cartitem/GetFullList?userId={id}"); } - public IActionResult OnPostAsync() + public ProductViewModel GetProduct(Guid cartItemId) { + return APIClient.GetRequest($"CartItem/GetProduct?cartItemId={cartItemId}"); + } + public void OnPostDeleteCartItem(Guid Id) + { + var response = APIClient.DeleteRequest($"CartItem/Delete?id={Id}"); + if (response is null) + { + throw new Exception("Something wrong LOL!"); + } + OnGet(); - - - return RedirectToAction(""); + } + public IActionResult OnPostGoToPayment(int ProductCount, Guid UserId, double Cost) + { + paymentViewModel = new PaymentViewModel() + { + UserId = UserId, + Cost = Cost, + ProductCount = ProductCount, + UserFirstName = string.Empty, + UserSecondName = string.Empty, + }; + if (ProductCount <= 0 || UserId == Guid.Empty || Cost <= 0) + { + throw new Exception("Something wrong LOL!"); + } + return RedirectToPage("Purchase", paymentViewModel); } } } \ No newline at end of file diff --git a/WebApp/Pages/Index.cshtml b/WebApp/Pages/Index.cshtml index c8411ec..ac51bb5 100644 --- a/WebApp/Pages/Index.cshtml +++ b/WebApp/Pages/Index.cshtml @@ -12,34 +12,80 @@ @@ -53,7 +99,21 @@ @weapon.Name
@weapon.Name
-

Цена: @weapon.Price руб.

+

+ + @foreach (var sale in Model.SalesModel) + if (sale.Category == weapon.Category) + { + Цена: @weapon.Price руб. + @(weapon.Price / 100 * (100 - sale.Value)) руб. + break; + } + else + { + Цена: @weapon.Price руб. + } +

+
@for (int i = 0; i < (int)Math.Round(@weapon.Rate); i++) @@ -67,18 +127,8 @@ (@weapon.Rate)
- @if (User.Identity.IsAuthenticated) - { - To cart - } - else - { - To cart - } - View Product - + Подробнее -
@@ -91,12 +141,33 @@ // СЛАЙДЕРЫ document.getElementById("priceFrom").addEventListener("input", function () { var price = this.value; - document.getElementById("priceLabelFrom").textContent = price + " р."; + document.getElementById("priceLabelFrom").value = price + " р."; }); document.getElementById("priceTo").addEventListener("input", function () { var price = this.value; - document.getElementById("priceLabelTo").textContent = price + " р."; + document.getElementById("priceLabelTo").value = price + " р."; + }); + + document.getElementById("search").addEventListener("input", function () { + var text = this.value; + document.getElementById("search_hidden").value = text; + }); + + $('#saleDetailModal').on('show.bs.modal', function (event) { + var button = $(event.relatedTarget); // Кнопка, которая активировала модальное окно + var saleId = button.data('sale-id'); // Экземпляр saleId из атрибута data-sale-id кнопки + + // Загрузка данных о продаже с сервера (пример с использованием AJAX) + $.ajax({ + url: '/api/sales/' + saleId, // URL API для получения данных о продаже + type: 'GET', + success: function (data) { + var modal = $(this); + modal.find('.modal-title').text('Дата проведения акции: ' + data.date); + modal.find('.modal-body').text('Описание акции: ' + data.description); + } + }); }); } \ No newline at end of file diff --git a/WebApp/Pages/Index.cshtml.cs b/WebApp/Pages/Index.cshtml.cs index fe78f42..6c983bf 100644 --- a/WebApp/Pages/Index.cshtml.cs +++ b/WebApp/Pages/Index.cshtml.cs @@ -10,22 +10,28 @@ namespace WebApp.Pages public class IndexModel : PageModel { public List ProductsModel { get; set; } + public List SalesModel { get; set; } public Dictionary> MediaByProductsModel { get; set; } - public void OnGet(double? pricefrom, double? priceto, string? search) + public void OnGet(double? pricefrom, double? priceto, string? search, string? category) { string request = "Product/GetList"; if (!string.IsNullOrEmpty(search)) - request += $"?search={search}"; + request += $"?search={search}&"; + + if (!string.IsNullOrEmpty(category)) + request += $"?category={category}&"; if (pricefrom != null) - request += $"?pricefrom={pricefrom}"; + request += $"?pricefrom={pricefrom}&"; if (priceto != null) request += $"?priceto={priceto}"; ProductsModel = APIClient.GetRequest>(request); MediaByProductsModel = APIClient.GetRequest>>($"MediaFile/GetByProducts"); + + SalesModel = APIClient.GetRequest>($"Sale/GetList"); } public byte[] GetMediaByProduct(ProductViewModel productModel) { diff --git a/WebApp/Pages/Login.cshtml.cs b/WebApp/Pages/Login.cshtml.cs index 46144ad..4e565e1 100644 --- a/WebApp/Pages/Login.cshtml.cs +++ b/WebApp/Pages/Login.cshtml.cs @@ -22,7 +22,9 @@ namespace WebApp.Pages TempData["jwt"] = (string)response; - return RedirectToPage("TwoFactor"); + //return RedirectToPage("TwoFactor"); + this.SetJWT((string)TempData["jwt"]); + return RedirectToPage("Index"); } } } \ No newline at end of file diff --git a/WebApp/Pages/ProductPage.cshtml b/WebApp/Pages/ProductPage.cshtml index c4e93b8..cb06adc 100644 --- a/WebApp/Pages/ProductPage.cshtml +++ b/WebApp/Pages/ProductPage.cshtml @@ -15,24 +15,12 @@
- @*
- @Model.productModel.Name -
*@ -
-
- -
- PREV - NEXT -
-
-

@Model.productModel.Name

+ @Model.productModel.Name +
+ +
+

@Model.productModel.Name

@for (int i = 0; i < (int)Math.Round(@Model.productModel.Rate); i++) { @@ -44,19 +32,36 @@ } (@Model.productModel.Rate)
-

Цена: @Model.productModel.Price руб.

+

+ @if (Model.saleModel != null) + { + Цена: @Model.productModel.Price руб. + @(Model.productModel.Price / 100 * (100 - @Model.saleModel.Value)) руб. + } + else + { + Цена: @Model.productModel.Price руб. + } +

Количество товара на складе: @Model.productModel.Amount

- + +
+
+
+
+
+ @if (User.Identity.IsAuthenticated) {
- - - + + + +
+
- } else { @@ -64,66 +69,133 @@
- - В корзину - - + В корзину } - + + + +

Описание

-

@Model.productModel.Amount

+

@Model.productModel.Description

- diff --git a/WebApp/Pages/ProductPage.cshtml.cs b/WebApp/Pages/ProductPage.cshtml.cs index 1096357..b82ce24 100644 --- a/WebApp/Pages/ProductPage.cshtml.cs +++ b/WebApp/Pages/ProductPage.cshtml.cs @@ -7,14 +7,16 @@ namespace WebApp.Pages { public class ProductPageModel : PageModel { - public PurchaseViewModel purchaseModel { get; set; } public ProductViewModel productModel { get; set; } + public SaleViewModel saleModel { get; set; } public MediaFileViewModel mediaFileModel { get; set; } public Dictionary> MediaByProductsModel { get; set; } - public int Amount { get; set; } // public void OnGet(Guid id) { productModel = APIClient.GetRequest($"Product/GetProduct?id={id}"); + + saleModel = APIClient.GetRequest($"Sale/GetSaleByProduct?id={id}"); + } public byte[] GetMediaByProduct(ProductViewModel productModel) @@ -31,21 +33,18 @@ namespace WebApp.Pages return models; } - public IActionResult OnPostAsync(Guid id, int count) + public IActionResult OnPostAsync(int count, double price, Guid productId, string productName) { - Amount = count; - if (purchaseModel == null) + var model = new CartItemBindingModel() { - var model = new PurchaseBindingModel() - { - Cost = 0, - DatePurchase = DateTime.Now, - Status = 0, - UserId = new Guid(this.GetUserId()) - }; - //purchaseModel = APIClient.PostRequest($"Purchase/Create", model); - } - APIClient.GetRequest($"Purchase/AddProducts?purchaseId={purchaseModel.Id}?productId={id}?count={count}"); + Id = new Guid(), + DateCreated = DateTime.Now, + ProductId = productId, + ProductName = productName, + Count = count, + UserId = new Guid(this.GetUserId()) + }; + APIClient.PostRequest($"CartItem/Create/", model); return RedirectToPage("Cart"); } } diff --git a/WebApp/Pages/Purchase.cshtml b/WebApp/Pages/Purchase.cshtml new file mode 100644 index 0000000..ebfa379 --- /dev/null +++ b/WebApp/Pages/Purchase.cshtml @@ -0,0 +1,63 @@ +@page +@model WebApp.Pages.PurchaseModel +@{ + ViewData["Title"] = "Оплата заказа"; +} +

Оплата заказа

+ +
+
+
+
+
+ + + + + +
+ +
+
+ + +
+ +
+ + + + +
+
+
+
+ + + +
+
+ + \ No newline at end of file diff --git a/WebApp/Pages/Purchase.cshtml.cs b/WebApp/Pages/Purchase.cshtml.cs new file mode 100644 index 0000000..3bdc050 --- /dev/null +++ b/WebApp/Pages/Purchase.cshtml.cs @@ -0,0 +1,98 @@ +using Contracts.BindingModels; +using Contracts.Converters; +using Contracts.ViewModels; +using DataModels.Enums; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using WebApp.Helpers; +using WebApp.Pages.User; + +namespace WebApp.Pages +{ + [Authorize(Roles = Roles.User)] + public class PurchaseModel : PageModel + { + [BindProperty] + public PurchaseBindingModel purchaseModel { get; set; } + public PaymentViewModel paymentViewModel { get; set; } + public UserViewModel userModel { get; set; } + [BindProperty] + public bool bonus { get; set; } + public void OnGet(PaymentViewModel model) + { + var id = this.GetUserId(); + if (id is null) + { + return; + } + + userModel = APIClient.GetRequest($"user/get?id={id}"); + if (userModel is null) + { + throw new Exception("User is not found."); + } + + paymentViewModel = model; + paymentViewModel.Bonus = userModel.Bonus; + paymentViewModel.UserFirstName = userModel.FirstName; + paymentViewModel.UserSecondName = userModel.SecondName; + paymentViewModel.Email = userModel.Email; + } + + public IActionResult OnPostAsync(Guid userId, double cost, string PaymentMethod) + { + purchaseModel.Cost = cost; + if (PaymentMethod == "Online") + purchaseModel.IsPaid = true; + else + purchaseModel.IsPaid = false; + + userModel = APIClient.GetRequest($"user/get?id={userId}"); + UserBindingModel userBinding = UserConverter.ToBinding(userModel); + + var bonusModel = new BonusUpdateBindingModel(); + bonusModel.UserId = userId; + bonusModel.BonusPlus = Convert.ToInt32(purchaseModel.Cost) / 100; + + if (bonus) + { + bonusModel.BonusMinus = userModel.Bonus; + purchaseModel.Cost -= userModel.Bonus; + + var response_update1 = APIClient.PatchRequest($"user/updatebonus", bonusModel); + + if (response_update1 is null || response_update1 is not string) + { + throw new Exception("Something wrong LOL!"); + } + } + var response_update = APIClient.PatchRequest($"user/updatebonus", bonusModel); + + if (response_update is null || response_update is not string) + { + throw new Exception("Something wrong LOL!"); + } + + purchaseModel.Id = new Guid(); + purchaseModel.Status = PurchaseStatus.Processing; + purchaseModel.DateCreated = DateTime.Now; + + var response_create = APIClient.PostRequest($"Purchase/Create/", purchaseModel); + + if (response_create is null || response_create is not string) + { + throw new Exception("Something wrong LOL!"); + } + + var response_delete = APIClient.DeleteRequest($"CartItem/DeleteAll/"); + + if (response_delete is null || response_delete is not string) + { + throw new Exception("Something wrong LOL!"); + } + + return RedirectToPage("/User/Purchases"); + } + } +} diff --git a/WebApp/Pages/Shared/_Layout.cshtml b/WebApp/Pages/Shared/_Layout.cshtml index 420ed43..c970b86 100644 --- a/WebApp/Pages/Shared/_Layout.cshtml +++ b/WebApp/Pages/Shared/_Layout.cshtml @@ -8,9 +8,29 @@ - + + + + + + + + + + + + + + + + + + + + +
@@ -24,7 +44,7 @@ - \ No newline at end of file + + + diff --git a/WebApp/Pages/User/Index.cshtml b/WebApp/Pages/User/Index.cshtml index 5f119a4..29b619f 100644 --- a/WebApp/Pages/User/Index.cshtml +++ b/WebApp/Pages/User/Index.cshtml @@ -9,15 +9,23 @@

@Model.UserModel.FirstName @Model.UserModel.SecondName

@Model.UserModel.Email

+

Бонусы за покупки: @Model.UserModel.Bonus шт.


-
- Settings -
- -
- +
+
+ + + +
+ +
+
- +
diff --git a/WebApp/Pages/User/Purchases.cshtml b/WebApp/Pages/User/Purchases.cshtml new file mode 100644 index 0000000..884784c --- /dev/null +++ b/WebApp/Pages/User/Purchases.cshtml @@ -0,0 +1,172 @@ +@page +@model WebApp.Pages.User.PurchasesModel +@{ + ViewData["Title"] = "Покупки"; +} + + + +
+

Покупки

+ @if (Model.purchaseViewModels == null! || Model.purchaseViewModels.Count == 0) + { +

Вы ещё не совершали покупок.

+ } + else + { +
+ + + +
+ + + + + + + + + + + + + + @foreach (var item in Model.purchaseViewModels) + { + + + + + + + + + + + + + + } + +
Дата покупкиДата полученияКоличество товаровТовары на суммуОплачено
+
+ @item.DateCreated +
+
+
+ @if (item.DateClosed != null) + { + @item.DateClosed + } + else + { + @item.Status + } +
+
+
+ @item.ProductCount +
+
+
+ @item.Cost +
+
+
+ @if (@item.IsPaid) + { + Оплачено + } + else + { + Ждёт оплаты + } +
+
+
+
+ +
+
+
+ } +
+ + + + + \ No newline at end of file diff --git a/WebApp/Pages/User/Purchases.cshtml.cs b/WebApp/Pages/User/Purchases.cshtml.cs new file mode 100644 index 0000000..83f9a76 --- /dev/null +++ b/WebApp/Pages/User/Purchases.cshtml.cs @@ -0,0 +1,82 @@ +using BusinessLogic.BusinessLogic; +using Contracts.BusinessLogicContracts; +using Contracts.SearchModels; +using Contracts.ViewModels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Reflection; +using WebApp.Helpers; + +namespace WebApp.Pages.User +{ + [Authorize(Roles = Roles.User)] + public class PurchasesModel : PageModel + { + public List purchaseViewModels { get; set; } + public UserViewModel userViewModel { get; set; } + public BillViewModel billViewModel { get; set; } + [BindProperty] + public PurchaseSearchModel purchaseSearchModel { get; set; } + public void OnGet(DateTime? datefrom, DateTime? dateto) + { + var UserId = this.GetUserId(); + if (UserId is null) + { + return; + } + + userViewModel = APIClient.GetRequest($"user/get?id={UserId}"); + + string request = "Purchase/GetList"; + + request += $"?userid={UserId}&"; + + if (datefrom != null) + request += $"?datefrom={datefrom}&"; + + if (dateto != null) + request += $"?datefrom={dateto}&"; + + purchaseViewModels = APIClient.GetRequest>(request); + } + + public void OnGetStatistics() + { + + } + + public void SendBill() + { + + } + + public void OnPostSendBill(Guid id) + { + var UserId = this.GetUserId(); + if (UserId is null) + { + OnGet(null, null); + } + userViewModel = APIClient.GetRequest($"user/get?id={UserId}"); + + var purchase = APIClient.GetRequest($"purchase/get?id={id}"); + var products = APIClient.GetRequest>($"purchase/getproducts?purchaseid={id}"); + + billViewModel = new BillViewModel(); + billViewModel.UserId = new Guid(this.GetUserId()); + billViewModel.PurchaseId = id; + billViewModel.Products = products; + billViewModel.Count = purchase.ProductCount; + billViewModel.Cost = purchase.Cost; + billViewModel.DateCreated = purchase.DateCreated; + billViewModel.UserFirstName = userViewModel.FirstName; + billViewModel.UserLastName = userViewModel.SecondName; + billViewModel.UserEmail = userViewModel.Email; + + APIClient.PostRequest($"purchase/createbill", billViewModel); + + OnGet(null, null); + } + } +} diff --git a/WebApp/Pages/_Header.cshtml b/WebApp/Pages/_Header.cshtml new file mode 100644 index 0000000..0c773e5 --- /dev/null +++ b/WebApp/Pages/_Header.cshtml @@ -0,0 +1,5 @@ +@page +@model WebApp.Pages._HeaderModel +@{ + +} diff --git a/WebApp/Pages/_Header.cshtml.cs b/WebApp/Pages/_Header.cshtml.cs new file mode 100644 index 0000000..64dc485 --- /dev/null +++ b/WebApp/Pages/_Header.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace WebApp.Pages +{ + public class _HeaderModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/WebApp/WebApp.csproj b/WebApp/WebApp.csproj index 8cc73e5..cd4cbec 100644 --- a/WebApp/WebApp.csproj +++ b/WebApp/WebApp.csproj @@ -6,12 +6,17 @@ enable + + + + + @@ -22,4 +27,16 @@ + + + + + + <_ContentIncludedByDefault Remove="Pages\_Header.cshtml" /> + + + + + + diff --git a/WebApp/wwwroot/big-sale.png b/WebApp/wwwroot/big-sale.png new file mode 100644 index 0000000000000000000000000000000000000000..3ed2d3329824f48d23ed96837e74a6a741329f07 GIT binary patch literal 33090 zcmX_n1yqz@(EhtiE3MKcEFmBuT>{FI64D?oCEX=$(6zLJAR#Cv-LXiwba!|6!v0@> z-}n8`(X*WQy?gK6nYqtAGj}%ZwTc|UJ*s;E01zn1!_@%*3jPTNaIwLUQ?Jo$@B`0D zUe6T(2wVUChjcprGzTA2y2=lR;l~qQ~odh(}}Hm-B(!Yf%Yr5p=U_4MO7qgP~_!j7Dh(K;?F@5LDfM`x2T5uG{kunGH`esf_IU{gzqNc z@BmegkwP6~^6%jQ+hU#+HO7Ar$-1JwN5L<@HHSF~{f(OX7_gB+ZAM)e8XAf}&a)^d zMSf0n7ZWfaxyH=^4#NdguboNZ>oAn`qP7tridh+ zL=cTPL%xRrC=Hra<5zGv{Cv%6(f#eo;sH~fIXJg`+9))D#pB=9>EZ3%tl-r3J%9vJ z1?f#l0KJp#X@JbXnWktK36@V5(U%)JKha6xAgGkYp`;Yik>BM7a~(cD3g|jG*l7BBdk#La-i(*R zISN2tT)660+yVc_z{oFYpLu!3v z93^VH_2~Qg6o!V&z+$lG? z7c^z5ZpD@8$>KU6JMJY;^T!fU2}R0tx%6`wh5YuMjNPhufn9eN&=}%h#~Vt250=JV zIYjJLnw;r(cIr3z<{@1+$ovnnp)et4fbk{?4}~Y(W|1c|CE@QbBTz19@#d_&sm10p z;LBJ@g#0kL$1+cUM%L?o&nas|nb-vbEqnfj=K83pj#e~4{|1MFQ9&78aDEP(X0NPO zy2HYG;)is1Z-r>%fn-(n`6U0sE)17M;SH#V^HYmO-elTz5uptI!J@Y2jC}u(mD&B< z#LY#;%b>b*Ky~ZnJrJ4f{1QR-@OY1p-RW`{=lidI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