Compare commits

..

No commits in common. "main" and "dev" have entirely different histories.
main ... dev

207 changed files with 374 additions and 21801 deletions

View File

@ -11,18 +11,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BarCode" Version="2024.6.1" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="IronPrint" Version="2024.6.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Contracts.BindingModels;
using IronBarCode;
namespace BusinessLogic.BusinessLogic
{
public class BarcodeLogic
{
public GeneratedBarcode CreateBarcode(ProductBindingModel model, bool save)
{
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128);
var path = $"product{model.Id}.png";
if (save) return barCode.SaveAsPng(path);
return barCode;
}
}
}

View File

@ -1,122 +0,0 @@
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));
}
}
}

View File

@ -1,105 +0,0 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Implements;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class CartItemLogic : ICartItemLogic
{
private readonly ICartItemStorage _cartItemStorage;
private readonly ILogger _logger;
public CartItemLogic(ICartItemStorage cartItemStorage, ILogger<CartItemLogic> logger)
{
_cartItemStorage = cartItemStorage;
_logger = logger;
}
public bool Create(CartItemBindingModel model)
{
CheckModel(model);
if (_cartItemStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(CartItemBindingModel model)
{
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_cartItemStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public CartItemViewModel ReadElement(CartItemSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _cartItemStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<CartItemViewModel> ReadElements(CartItemSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _cartItemStorage.GetFullList() : _cartItemStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(CartItemBindingModel model)
{
CheckModel(model);
if (_cartItemStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public void CheckModel(CartItemBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ProductName))
{
throw new ArgumentNullException("Нет категории", nameof(model.ProductName));
}
_logger.LogInformation("Cart Item. Id: { Id}", model.Id);
}
}
}

View File

@ -1,107 +0,0 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Implements;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class MediaFileLogic : IMediaFileLogic
{
private readonly IMediaFileStorage _mediafileStorage;
private readonly ILogger _logger;
public MediaFileLogic(IMediaFileStorage mediafileStorage, ILogger<MediaFileLogic> logger)
{
_mediafileStorage = mediafileStorage;
_logger = logger;
}
public bool Create(MediaFileBindingModel model)
{
CheckModel(model);
_logger.LogInformation("Работа идёт нормально, криэйт в логике");
if (_mediafileStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(MediaFileBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_mediafileStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public MediaFileViewModel? ReadElement(MediaFileSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement .Id:{ Id}", model.Id);
var element = _mediafileStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<MediaFileViewModel>? ReadList(MediaFileSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _mediafileStorage.GetFullList() : _mediafileStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(MediaFileBindingModel model)
{
CheckModel(model);
if (_mediafileStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(MediaFileBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.Image == null)
{
//throw new ArgumentNullException("Нет изображения", nameof(model.Name));
}
_logger.LogError("Проверка модели медиа файла выдала ошибку.");
}
}
}

View File

@ -23,7 +23,6 @@ namespace BusinessLogic.BusinessLogic
}
public bool Create(ProductBindingModel model)
{
CheckModel(model);
if (_productStorage.Insert(model) == null)
{

View File

@ -1,127 +0,0 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.Converters;
using Contracts.Exceptions;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Implements;
using DatabaseImplement.Migrations;
using DatabaseImplement.Models;
using DataModels.Enums;
using DataModels.Models;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class PurchaseLogic : IPurchaseLogic
{
private readonly IPurchaseStorage _purchaseStorage;
private readonly IProductStorage _productStorage;
private readonly ILogger _logger;
public PurchaseLogic(IPurchaseStorage purchaseStorage, IProductStorage productStorage, ILogger<PurchaseLogic> logger)
{
_purchaseStorage = purchaseStorage;
_logger = logger;
_productStorage = productStorage;
}
public PurchaseViewModel Create(PurchaseBindingModel model)
{
ArgumentNullException.ThrowIfNull(model);
var purchase = _purchaseStorage.Insert(model);
if (purchase is null)
{
throw new Exception("Insert operation failed.");
}
return purchase;
}
public PurchaseViewModel Delete(PurchaseSearchModel model)
{
ArgumentNullException.ThrowIfNull(model);
_logger.LogInformation("Delete purchase. Id: {0}", model.Id);
var purchase = _purchaseStorage.Delete(model);
if (purchase is null)
{
throw new Exception("Delete operation failed.");
}
return purchase;
}
public PurchaseViewModel ReadElement(PurchaseSearchModel model)
{
ArgumentNullException.ThrowIfNull(model);
_logger.LogInformation("ReadElement. Id: {0}", model.Id);
var purchase = _purchaseStorage.GetElement(model);
if (purchase is null)
{
throw new ElementNotFoundException();
}
_logger.LogInformation("ReadElement find. Id: {0}", purchase.Id);
return purchase;
}
public List<PurchaseViewModel> ReadElements(PurchaseSearchModel? model)
{
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
var purchase_list = model == null ? _purchaseStorage.GetFullList(model) : _purchaseStorage.GetFilteredList(model);
if (purchase_list is null || purchase_list.Count() == 0)
{
_logger.LogWarning("ReadList return null list");
return [];
}
_logger.LogInformation("ReadList. Count: {Count}", purchase_list.Count());
return purchase_list;
}
public PurchaseViewModel Update(PurchaseBindingModel model)
{
ArgumentNullException.ThrowIfNull(model);
var purchase = _purchaseStorage.Update(model);
if (purchase is null)
{
throw new Exception("Update operation failed.");
}
return purchase;
}
public List<CartItemViewModel> GetCartItems(PurchaseSearchModel model)
{
var items = _purchaseStorage.GetCartItems(model);
if (items is null)
{
throw new Exception("Get operation failed.");
}
return items;
}
public List<ProductViewModel> GetProducts(PurchaseSearchModel model)
{
var products = _purchaseStorage.GetProducts(model);
if (products is null)
{
throw new Exception("Get operation failed.");
}
return products;
}
}
}

View File

@ -1,104 +0,0 @@
using BusinessLogic.OfficePackage.HelperModels;
using BusinessLogic.OfficePackage;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using Contracts.SearchModels;
namespace BusinessLogic.BusinessLogic
{
public class ReportLogic : IReportLogic
{
private readonly IProductStorage _productStorage;
private readonly ISupplyStorage _supplyStorage;
private readonly IMediaFileStorage _mediaFileStorage;
private readonly AbstractSaveToPdf _saveToPdf;
private readonly AbstractSaveToPdfCheque _saveToCheque;
private readonly AbstractSaveToPdfPricelist _savePricelist;
public ReportLogic(IProductStorage productStorage, ISupplyStorage supplyStorage, AbstractSaveToPdf saveToPdf, AbstractSaveToPdfCheque saveToPdfCheque, IMediaFileStorage mediaFileStorage, AbstractSaveToPdfPricelist savePricelist)
{
_productStorage = productStorage;
_supplyStorage = supplyStorage;
_saveToPdf = saveToPdf;
_saveToCheque = saveToPdfCheque;
_mediaFileStorage = mediaFileStorage;
_savePricelist = savePricelist;
}
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
public List<ReportSupplyProductViewModel> GetSupplyProduct()
{
var products = _productStorage.GetFullList();
var supplies = _supplyStorage.GetFullList();
var list = new List<ReportSupplyProductViewModel>();
foreach (var supply in supplies)
{
var record = new ReportSupplyProductViewModel
{
SupplyName = supply.Name,
Products = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var product in products)
{
if (supply.Products.ContainsKey(product.Id))
{
record.Products.Add(new Tuple<string, int>(product.Name, supply.Products[product.Id].Item2));
record.TotalCount += supply.Products[product.Id].Item2;
}
}
list.Add(record);
}
return list;
}
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
public void SaveSuppliesToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Накладная",
Date = model.Date!.Value,
Supply = _supplyStorage.GetElement(new SupplySearchModel()
{
Id = model.SupplyId,
})
});
}
public void SaveProductToPdfFile(ReportBindingModel model)
{
_saveToCheque.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Чек на товар",
Product = _productStorage.GetElement(new ProductSearchModel()
{
Id = model.ProductId
}),
//MediaFiles = _mediaFileStorage.GetFilteredList(new MediaFileSearchModel() { ProductId = model.ProductId })
});
}
public void SavePriceListToPdfFile(ReportBindingModel model)
{
_savePricelist.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Прайс-лист",
Date = model.Date,
Products = _productStorage.GetFullList()
});
}
}
}

View File

@ -1,116 +0,0 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Implements;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class SaleLogic : ISaleLogic
{
private readonly ISaleStorage _saleStorage;
private readonly ILogger _logger;
public SaleLogic(ISaleStorage saleStorage, ILogger<SaleLogic> logger)
{
_saleStorage = saleStorage;
_logger = logger;
}
public bool Create(SaleBindingModel model)
{
CheckModel(model);
if (_saleStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(SaleBindingModel model)
{
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_saleStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public SaleViewModel ReadElement(SaleSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _saleStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<SaleViewModel> ReadElements(SaleSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _saleStorage.GetFullList() : _saleStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(SaleBindingModel model)
{
CheckModel(model);
if (_saleStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public void CheckModel(SaleBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Category))
{
throw new ArgumentNullException("Нет категории", nameof(model.Category));
}
_logger.LogInformation("Sale. Id: { Id}", model.Id);
var element = _saleStorage.GetElement(new SaleSearchModel
{
Description = model.Description
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Акция с таким описанием уже есть");
}
}
}
}

View File

@ -1,80 +0,0 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.Converters;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class SellLogic : ISellLogic
{
private readonly ISellStorage _sellStorage;
private readonly ILogger _logger;
public SellLogic(ISellStorage sellStorage, ILogger<SellLogic> logger)
{
_sellStorage = sellStorage;
_logger = logger;
}
public SellViewModel Create(SellBindingModel model)
{
ArgumentNullException.ThrowIfNull(model);
var sell = _sellStorage.Insert(model);
if (sell is null)
{
throw new Exception("Insert operation failed.");
}
return sell;
}
public SellViewModel ReadElement(SellSearchModel model)
{
ArgumentNullException.ThrowIfNull(model);
var sell = _sellStorage.GetElement(model);
if (sell is null)
{
throw new Exception("Get element operation failed.");
}
return sell;
}
public IEnumerable<SellViewModel> ReadElements(SellSearchModel? model)
{
var sell_list = _sellStorage.GetFullList(model);
if (sell_list is null || sell_list.Count() == 0)
{
_logger.LogWarning("ReadList return null list");
return [];
}
return sell_list;
}
public SellViewModel Update(SellSearchModel model)
{
ArgumentNullException.ThrowIfNull(model);
var sell = _sellStorage.GetElement(model);
if (sell is null)
{
throw new Exception("Update operation failed.");
}
return sell;
}
public SellViewModel Delete(SellSearchModel model)
{
ArgumentNullException.ThrowIfNull(model);
var sell = _sellStorage.Delete(model);
if (sell is null)
{
throw new Exception("Update operation failed.");
}
return sell;
}
}
}

View File

@ -3,7 +3,6 @@ using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -102,30 +101,5 @@ namespace BusinessLogic.BusinessLogic
throw new ArgumentNullException("Нет названия поставки", nameof(model.Name));
}
}
public bool StatusUpdate(SupplyBindingModel model, SupplyStatus newStatus)
{
if (model.Status + 1 != newStatus)
{
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Supply status incorrect.");
return false;
}
model.Status = newStatus;
if (newStatus == SupplyStatus.Arriving)
{
model.DateArriving = DateTime.UtcNow;
}
if (newStatus == SupplyStatus.Completed)
{
model.DateComplete = DateTime.UtcNow;
}
if (_supplyStorage.Update(model) == null)
{
model.Status--;
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
}
}

View File

@ -181,10 +181,5 @@ namespace BusinessLogic.BusinessLogic
{
return _twoFactorAuthService.Verify(code);
}
public void UpdateBonus(BonusUpdateBindingModel model)
{
_userStorage.UpdateBonus(model);
}
}
}

View File

@ -1,80 +0,0 @@
using BusinessLogic.BusinessLogic;
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdf
{
public void CreateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = $"{info.Title}\nОт {DateTime.UtcNow}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
string dateArriving = info.Supply.DateArriving.HasValue ? info.Supply.DateArriving.ToString() : "-";
string dateComplete = info.Supply.DateComplete.HasValue ? info.Supply.DateComplete.ToString() : "-";
CreateParagraph(new PdfParagraph
{
Text = $"Поставщик: {info.Supply.SupplierName}\nДата создания поставки: {info.Supply.Date}\nДата отправления поставки: {dateArriving}\nДата получения поставки: {dateComplete}\nСтатус: {info.Supply.Status}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
CreateTable(new List<string> { "5cm", "10cm"});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Id", "Информация" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { info.Supply.Id.ToString(), info.Supply.Name, },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateParagraph(new PdfParagraph
{
Text = "Товары",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var product in info.Supply.Products.Values)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { product.Item1.Id.ToString(), product.Item1.Name, product.Item1.Price.ToString(), product.Item2.ToString() },
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.Supply.Price.ToString("0.00")} руб.",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void CreateImage(string path);
protected abstract void SavePdf(PdfInfo info);
}
}

View File

@ -1,57 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfCheque
{
public void CreateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = $"{info.Title}\n{info.Product.Name}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = $"Id: {info.Product.Id}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
//CreateParagraph(new PdfParagraph
//{
// Text = "Список прилагаемых файлов",
// Style = "NormalTitle",
// ParagraphAlignment = PdfParagraphAlignmentType.Center
//});
//CreateTable(new List<string> { "10cm", "5cm" });
//CreateRow(new PdfRowParameters
//{
// Texts = new List<string> { "Название", "расширение" },
// Style = "NormalTitle",
// ParagraphAlignment = PdfParagraphAlignmentType.Center
//});
CreateImage($"product{info.Product.Id}.png");
CreateParagraph(new PdfParagraph
{
Text = $"Цена: {info.Product.Price.ToString("0.00")} руб.",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void CreateImage(string path);
protected abstract void SavePdf(PdfInfo info);
}
}

View File

@ -1,51 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfPricelist
{
public void CreateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = $"{info.Title}\nОт {info.Date}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = "Товары",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во на складе" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var product in info.Products)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { product.Id.ToString(), product.Name, product.Price.ToString(), product.Amount.ToString() },
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void CreateImage(string path);
protected abstract void SavePdf(PdfInfo info);
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{
Center,
Left,
Right
}
}

View File

@ -1,20 +0,0 @@
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public DateTime? Date { get; set; }
public SupplyViewModel? Supply { get; set; } = new();
public ProductViewModel? Product { get; set; } = new();
public List<MediaFileViewModel>? MediaFiles { get; set; } = new();
public List<ProductViewModel>? Products { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.HelperModels
{
public class PdfParagraph
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.HelperModels
{
public class PdfRowParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,111 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using System.Text;
namespace BusinessLogic.OfficePackage.Implements
{
public class SaveToPdf : AbstractSaveToPdf
{
private Document? _document;
private Section? _section;
private Table? _table;
private Image _image;
private static ParagraphAlignment
GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
/// <summary>
/// Создание стилей для документа
/// </summary>
/// <param name="document"></param>
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
protected override void CreatePdf(PdfInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List<string> columns)
{
if (_document == null)
{
return;
}
_table = _document.LastSection.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment =
GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
protected override void CreateImage(string path)
{
if (_document == null)
{
return;
}
_document.LastSection.AddImage(path);
}
protected override void SavePdf(PdfInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,118 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.Implements
{
public class SaveToPdfCheque : AbstractSaveToPdfCheque
{
private Document? _document;
private Section? _section;
private PdfPage? _page;
private Table? _table;
private Image _image;
private static ParagraphAlignment
GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
/// <summary>
/// Создание стилей для документа
/// </summary>
/// <param name="document"></param>
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
protected override void CreatePdf(PdfInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List<string> columns)
{
if (_document == null)
{
return;
}
_table = _document.LastSection.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment =
GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
protected override void CreateImage(string path)
{
if (_document == null)
{
return;
}
_document.LastSection.AddImage(path);
}
protected override void SavePdf(PdfInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,115 +0,0 @@
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage.Implements
{
public class SaveToPdfPricelist : AbstractSaveToPdfPricelist
{
private Document? _document;
private Section? _section;
private Table? _table;
private Image _image;
private static ParagraphAlignment
GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
/// <summary>
/// Создание стилей для документа
/// </summary>
/// <param name="document"></param>
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
protected override void CreatePdf(PdfInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List<string> columns)
{
if (_document == null)
{
return;
}
_table = _document.LastSection.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment =
GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
protected override void CreateImage(string path)
{
if (_document == null)
{
return;
}
_document.LastSection.AddImage(path);
}
protected override void SavePdf(PdfInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
@ -13,6 +12,5 @@ namespace BusinessLogic.Tools.Mail
public string Title { get; set; } = null!;
public string Body { get; set; } = null!;
public bool IsSendable { get; set; } = true;
public List<Attachment>? Attachments { get; set; } = new List<Attachment>();
}
}

View File

@ -42,11 +42,6 @@ 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);
}
}

View File

@ -1,28 +0,0 @@
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);
}
}
}

View File

@ -15,7 +15,7 @@ namespace BusinessLogic.Tools.Mail.MailTemplates
Title = "Ваш код для подтверждения";
Body = $"Здравствуйте, {user.SecondName} {user.FirstName}! Вот Ваш код для подтверждения:\n" +
$"{code}\n" +
$"Если это не Вы, игнорируйте это сообщение.";
$"Если это не Вы, игноритруйте это сообщение.";
}
}
}

View File

@ -1,15 +0,0 @@
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; }
}
}

View File

@ -1,20 +0,0 @@
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; }
}
}

View File

@ -11,6 +11,7 @@ namespace Contracts.BindingModels
{
public Guid Id { get; set; }
public Guid ProductId { get; set; }
public required byte[] Image { get; set; }
public string Name { get; set; } = string.Empty;
public string Location { get; set; } = string.Empty;
}
}

View File

@ -15,8 +15,5 @@ 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; }
}
}

View File

@ -1,6 +1,4 @@
using DataModels.Enums;
using DataModels.Models;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -11,12 +9,6 @@ namespace Contracts.BindingModels
public class PurchaseBindingModel
{
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public DateTime? DateClosed { get; set; }
public Guid UserId { get; set; }
public PurchaseStatus Status { get; set; }
public int ProductCount { get; set; }
public double Cost { get; set; }
public bool IsPaid { get; set; }
public DateTime DatePurchase { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? Date { get; set; }
public Guid? SupplyId { get; set; }
public Guid? ProductId { get; set; }
}
}

View File

@ -1,21 +0,0 @@
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; }
}
}

View File

@ -1,5 +1,4 @@
using DataModels.Models;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -11,7 +10,5 @@ namespace Contracts.BindingModels
{
public Guid Id { get; set; }
public DateTime DateSell { get; set; }
public Guid? UserId { get; set; }
public Dictionary<Guid, (IProduct, int)> SellProducts { get; set; } = new();
}
}

View File

@ -14,8 +14,6 @@ namespace Contracts.BindingModels
public string Name { get; set; } = string.Empty;
public Guid SupplierId { get; set; }
public DateTime Date { get; set; }
public DateTime? DateArriving { get; set; }
public DateTime? DateComplete { get; set; }
public double Price { get; set; }
public SupplyStatus Status { get; set; }
public Dictionary<Guid, (IProduct, int)> SupplyProducts { get; set; } = new();

View File

@ -17,6 +17,5 @@ namespace Contracts.BindingModels
public DateTime Birthday { get; set; }
public bool OnlyImportantMails { get; set; }
public RoleBindingModel Role { get; set; } = null!;
public int Bonus { get; set; }
}
}

View File

@ -1,14 +0,0 @@
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);
}
}

View File

@ -1,24 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface ICartItemLogic
{
bool Create(CartItemBindingModel model);
bool Update(CartItemBindingModel model);
CartItemViewModel ReadElement(CartItemSearchModel model);
List<CartItemViewModel> ReadElements(CartItemSearchModel? model);
bool Delete(CartItemBindingModel model);
}
}

View File

@ -1,20 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IMediaFileLogic
{
bool Create(MediaFileBindingModel model);
bool Update(MediaFileBindingModel model);
bool Delete(MediaFileBindingModel model);
List<MediaFileViewModel>? ReadList(MediaFileSearchModel? model);
MediaFileViewModel? ReadElement(MediaFileSearchModel model);
}
}

View File

@ -1,7 +1,6 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -18,10 +17,8 @@ namespace Contracts.BusinessLogicContracts
PurchaseViewModel ReadElement(PurchaseSearchModel model);
List<PurchaseViewModel> ReadElements(PurchaseSearchModel? model);
IEnumerable<PurchaseViewModel> ReadElements(PurchaseSearchModel? model);
PurchaseViewModel Delete(PurchaseSearchModel model);
List<CartItemViewModel> GetCartItems(PurchaseSearchModel model);
List<ProductViewModel> GetProducts(PurchaseSearchModel model);
}
}

View File

@ -1,26 +0,0 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IReportLogic
{
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
List<ReportSupplyProductViewModel> GetSupplyProduct();
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveSuppliesToPdfFile(ReportBindingModel model);
void SaveProductToPdfFile(ReportBindingModel model);
void SavePriceListToPdfFile(ReportBindingModel model);
}
}

View File

@ -1,24 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface ISaleLogic
{
bool Create(SaleBindingModel model);
bool Update(SaleBindingModel model);
SaleViewModel ReadElement(SaleSearchModel model);
List<SaleViewModel> ReadElements(SaleSearchModel? model);
bool Delete(SaleBindingModel model);
}
}

View File

@ -13,7 +13,7 @@ namespace Contracts.BusinessLogicContracts
{
SellViewModel Create(SellBindingModel model);
SellViewModel Update(SellSearchModel model);
SellViewModel Update(SellBindingModel model);
SellViewModel ReadElement(SellSearchModel model);

View File

@ -1,7 +1,6 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using DataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@ -17,6 +16,5 @@ namespace Contracts.BusinessLogicContracts
bool Create(SupplyBindingModel model);
bool Update(SupplyBindingModel model);
bool Delete(SupplyBindingModel model);
bool StatusUpdate(SupplyBindingModel model, SupplyStatus status);
}
}

View File

@ -25,6 +25,5 @@ namespace Contracts.BusinessLogicContracts
IEnumerable<UserViewModel> ReadElements(UserSearchModel? model);
UserViewModel Delete(UserSearchModel model);
void UpdateBonus(BonusUpdateBindingModel model);
}
}

View File

@ -1,33 +0,0 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.Converters
{
public class PurchaseConverter
{
public static PurchaseViewModel ToView(PurchaseBindingModel model) => new()
{
Id = model.Id,
DateCreated = model.DateCreated,
UserId = model.UserId,
Status = model.Status,
ProductCount = model.ProductCount,
Cost = model.Cost
};
public static PurchaseBindingModel ToBinding(PurchaseViewModel model) => new()
{
Id = model.Id,
DateCreated = model.DateCreated,
UserId = model.UserId,
Status = model.Status,
ProductCount = model.ProductCount,
Cost = model.Cost
};
}
}

View File

@ -19,7 +19,6 @@ namespace Contracts.Converters
Birthday = model.Birthday,
OnlyImportantMails = model.OnlyImportantMails,
Role = RoleConverter.ToView(model.Role),
Bonus = model.Bonus,
};
public static UserBindingModel ToBinding(UserViewModel model) => new()
@ -31,7 +30,6 @@ namespace Contracts.Converters
Birthday = model.Birthday,
OnlyImportantMails = model.OnlyImportantMails,
Role = RoleConverter.ToBinding(model.Role),
Bonus = model.Bonus,
};
}
}

View File

@ -1,16 +0,0 @@
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; }
}
}

View File

@ -11,11 +11,8 @@ namespace Contracts.SearchModels
public Guid? Id { get; set; }
public string? Name { get; set; }
public double? Price { get; set; }
public double? PriceFrom { get; set; }
public double? PriceTo { get; set; }
public double? Rate { get; set; }
public int? Amount { get; set; }
public bool? IsBeingSold { get; set; }
public string? Category { get; set; }
}
}

View File

@ -13,9 +13,8 @@ namespace Contracts.SearchModels
public Guid? Id { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public double? CostFrom { get; set; }
public double? CostTo { get; set; }
public double? PriceFrom { get; set; }
public double? PriceTo { get; set; }
public PurchaseStatus? Status { get; set; }
public Guid UserId { get; set; }
}
}

View File

@ -1,15 +0,0 @@
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; }
}
}

View File

@ -1,21 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface ICartItemStorage
{
List<CartItemViewModel> GetFullList();
List<CartItemViewModel> GetFilteredList(CartItemSearchModel model);
CartItemViewModel? GetElement(CartItemSearchModel model);
CartItemViewModel? Insert(CartItemBindingModel model);
CartItemViewModel? Update(CartItemBindingModel model);
CartItemViewModel? Delete(CartItemBindingModel model);
}
}

View File

@ -1,21 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IMediaFileStorage
{
List<MediaFileViewModel> GetFullList();
List<MediaFileViewModel> GetFilteredList(MediaFileSearchModel model);
MediaFileViewModel? GetElement(MediaFileSearchModel model);
MediaFileViewModel? Insert(MediaFileBindingModel model);
MediaFileViewModel? Update(MediaFileBindingModel model);
MediaFileViewModel? Delete(MediaFileBindingModel model);
}
}

View File

@ -1,7 +1,5 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -12,17 +10,14 @@ namespace Contracts.StorageContracts
{
public interface IPurchaseStorage
{
PurchaseViewModel? Insert(PurchaseBindingModel model);
PurchaseBindingModel? Insert(PurchaseBindingModel model);
List<PurchaseViewModel> GetFullList(PurchaseSearchModel? model);
List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model);
IEnumerable<PurchaseBindingModel> GetList(PurchaseSearchModel? model);
PurchaseViewModel? GetElement(PurchaseSearchModel model);
PurchaseBindingModel? GetElement(PurchaseSearchModel model);
PurchaseViewModel? Update(PurchaseBindingModel model);
PurchaseBindingModel? Update(PurchaseBindingModel model);
PurchaseViewModel? Delete(PurchaseSearchModel model);
List<CartItemViewModel> GetCartItems(PurchaseSearchModel purchaseModel);
List<ProductViewModel> GetProducts(PurchaseSearchModel model);
PurchaseBindingModel? Delete(PurchaseSearchModel model);
}
}

View File

@ -1,21 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface ISaleStorage
{
List<SaleViewModel> GetFullList();
List<SaleViewModel> GetFilteredList(SaleSearchModel model);
SaleViewModel? GetElement(SaleSearchModel model);
SaleViewModel? Insert(SaleBindingModel model);
SaleViewModel? Update(SaleBindingModel model);
SaleViewModel? Delete(SaleBindingModel model);
}
}

View File

@ -1,6 +1,5 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@ -11,15 +10,14 @@ namespace Contracts.StorageContracts
{
public interface ISellStorage
{
SellViewModel? Insert(SellBindingModel model);
SellBindingModel? Insert(SellBindingModel model);
IEnumerable<SellViewModel> GetFullList(SellSearchModel? model);
IEnumerable<SellViewModel> GetFilteredList(SellSearchModel? model);
IEnumerable<SellBindingModel> GetList(SellSearchModel? model);
SellViewModel? GetElement(SellSearchModel model);
SellBindingModel? GetElement(SellSearchModel model);
SellViewModel? Update(SellBindingModel model);
SellBindingModel? Update(SellBindingModel model);
SellViewModel? Delete(SellSearchModel model);
SellBindingModel? Delete(SellSearchModel model);
}
}

View File

@ -14,8 +14,8 @@ namespace Contracts.StorageContracts
List<SupplyViewModel> GetFullList();
List<SupplyViewModel> GetFilteredList(SupplySearchModel model);
SupplyViewModel? GetElement(SupplySearchModel model);
bool? Insert(SupplyBindingModel model);
bool? Update(SupplyBindingModel model);
SupplyViewModel? Insert(SupplyBindingModel model);
SupplyViewModel? Update(SupplyBindingModel model);
SupplyViewModel? Delete(SupplyBindingModel model);
}
}

View File

@ -19,7 +19,5 @@ namespace Contracts.StorageContracts
UserBindingModel? Update(UserBindingModel model);
UserBindingModel? Delete(UserSearchModel model);
void UpdateBonus(BonusUpdateBindingModel model);
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class BillViewModel
{
public Guid UserId { get; set; }
public Guid PurchaseId { get; set; }
public List<ProductViewModel> Products { get; set; } = new List<ProductViewModel>();
public int Count { get; set; }
public double Cost { get; set; }
public DateTime DateCreated { get; set; }
public string UserFirstName { get; set; } = string.Empty;
public string UserLastName { get; set; } = string.Empty;
public string UserEmail { get; set; } = string.Empty;
}
}

View File

@ -1,21 +0,0 @@
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; }
}
}

View File

@ -5,22 +5,22 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace Contracts.ViewModels
{
public class MediaFileViewModel
{
public Guid Id { get; set; }
public required byte[] Image { get; set; }
public string Location { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public Guid ProductId { get; set; }
public string ProductName { get; set; } = string.Empty;
public MediaFileBindingModel GetBindingModel()
{
return new MediaFileBindingModel
{
Id = Id,
Image = Image,
Name = Name,
Location = Location,
ProductId = ProductId
};
}

View File

@ -1,19 +0,0 @@
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; }
}
}

View File

@ -7,18 +7,14 @@ using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ProductViewModel : IProduct
public class ProductViewModel
{
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 double Rating { get; set; }
public bool IsBeingSold { get; set; }
public int Amount { get; set; }
public string? Category { get; set; }
public string? Description { get; set; }
public List<MediaFileViewModel> MediaFiles { get; set; } = new();
public Guid? SaleId { get; set; }
}
}

View File

@ -11,12 +11,9 @@ namespace Contracts.ViewModels
public class PurchaseViewModel
{
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public DateTime? DateClosed { get; set; }
public required Guid UserId { get; set; }
public DateTime DatePurchase { get; set; }
public required IUser User { get; set; }
public required List<IProduct> Products { get; set; }
public PurchaseStatus Status { get; set; }
public int ProductCount { get; set; }
public double Cost { get; set; }
public bool IsPaid { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ReportSupplyProductViewModel
{
public string SupplyName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Products { get; set; } = new();
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ReportSupplyViewModel
{
public int Id { get; set; }
public DateTime Date { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public String Status { get; set; } = string.Empty;
}
}

View File

@ -1,21 +0,0 @@
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; }
}
}

View File

@ -11,7 +11,6 @@ namespace Contracts.ViewModels
{
public Guid Id { get; set; }
public DateTime DateSell { get; set; }
public Guid? UserId { get; set; }
public Dictionary<Guid, (IProduct, int)> SellProducts { get; set; } = new();
public ISupplyDoc? SupplyDoc { get; set; }
}
}

View File

@ -11,7 +11,6 @@ namespace Contracts.ViewModels
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public int Deals { get; set; }
public Dictionary<Guid, (IProduct, int)> AvailibleProducts = new();
}
}

View File

@ -18,8 +18,6 @@ namespace Contracts.ViewModels
public double Price { get; set; }
public Dictionary<Guid, (IProduct, int)> Products { get; set; } = new();
public DateTime Date { get; set; }
public DateTime? DateArriving { get; set; }
public DateTime? DateComplete { get; set; }
public SupplyStatus Status { get; set; }
}
}

View File

@ -10,7 +10,6 @@ namespace Contracts.ViewModels
{
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public string Description { get; set; } = string.Empty;
public double Rate { get; set; }
}
}

View File

@ -15,6 +15,5 @@ namespace Contracts.ViewModels
public DateTime Birthday { get; set; }
public bool OnlyImportantMails { get; set; }
public RoleViewModel Role { get; set; } = null!;
public int Bonus { get; set; }
}
}

View File

@ -1,17 +0,0 @@
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; }
}
}

View File

@ -8,7 +8,8 @@ namespace DataModels.Models
{
public interface IMediaFile : IId
{
byte[] Image { get; }
string Name { get; }
string Location { get; }
Guid ProductId { get; }
}
}

View File

@ -13,7 +13,7 @@ namespace DataModels.Models
bool IsBeingSold { get; }
public double Rate { get; }
int Amount { get; }
string Category { get; }
string Description { get; }
// будут браться через mediafilestorage так что скорее всего это тут не надо
// List<IMediaFile> MediaFiles { get; }
}
}

View File

@ -9,11 +9,7 @@ namespace DataModels.Models
{
public interface IPurchase : IId
{
DateTime DateCreated { get; }
DateTime? DateClosed { get; }
DateTime DatePurchase { get; }
PurchaseStatus Status { get; }
int ProductCount { get; }
double Cost { get; }
bool IsPaid { get; }
}
}

View File

@ -1,19 +0,0 @@
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; }
}
}

View File

@ -13,8 +13,6 @@ namespace DataModels.Models
double Price { get; }
Guid SupplierId { get; }
DateTime Date { get; }
DateTime? DateArriving { get; }
DateTime? DateComplete { get; }
SupplyStatus Status { get; }
Dictionary<Guid, (IProduct, int)> SupplyProducts { get; }
}

View File

@ -14,6 +14,5 @@ namespace DataModels.Models
string Email { get; }
DateTime Birthday { get; }
bool OnlyImportantMails { get; }
int Bonus { get; }
}
}

View File

@ -14,8 +14,6 @@ namespace DatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
optionsBuilder.UseNpgsql("Server=192.168.191.42:32768;Database=gun_market;Username=postgres;Password=7355608;");
}
base.OnConfiguring(optionsBuilder);
@ -30,11 +28,7 @@ namespace DatabaseImplement
public virtual DbSet<SupplyProduct> SupplyProducts { get; set; } = null!;
public virtual DbSet<Supplier> Suppliers { get; set; } = null!;
public virtual DbSet<SupplierProduct> SupplierProducts { get; set; } = null!;
public virtual DbSet<MediaFile> MediaFiles { get; set; } = null!;
public virtual DbSet<SellProducts> SellProducts { get; set; } = null!;
public virtual DbSet<SupplyDoc> SupplyDocs { get; set; } = null!;
public virtual DbSet<CartItem> CartItems { get; set; } = null!;
public virtual DbSet<Sale> Sales { get; set; } = null!;
public virtual DbSet<MediaFile> MediaFiles { get; set; } = null!;
}
}

View File

@ -1,112 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class CartItemStorage : ICartItemStorage
{
public CartItemViewModel? Delete(CartItemBindingModel model)
{
using var context = new Database();
var element = context.CartItems
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.CartItems.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public CartItemViewModel? GetElement(CartItemSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.CartItems
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<CartItemViewModel> GetFilteredList(CartItemSearchModel model)
{
if (model.UserId == Guid.Empty && string.IsNullOrEmpty(model.ProductName))
{
return new();
}
using var context = new Database();
if (model.UserId != Guid.Empty)
{
return context.CartItems
.Where(x => x.UserId == model.UserId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
return context.CartItems
.Where(x => x.ProductName.Contains(model.ProductName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<CartItemViewModel> GetFullList()
{
using var context = new Database();
return context.CartItems
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public CartItemViewModel? Insert(CartItemBindingModel model)
{
using var context = new Database();
var newItem = CartItem.Create(context, model);
if (newItem == null)
{
return null;
}
context.CartItems.Add(newItem);
context.SaveChanges();
return newItem.GetViewModel;
}
public CartItemViewModel? Update(CartItemBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
try
{
var item = context.CartItems.FirstOrDefault(rec =>
rec.Id == model.Id);
if (item == null)
{
return null;
}
item.Update(model);
context.SaveChanges();
transaction.Commit();
return new();
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,101 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class MediaFileStorage : IMediaFileStorage
{
public MediaFileViewModel? Delete(MediaFileBindingModel model)
{
using var context = new Database();
var element = context.MediaFiles
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.MediaFiles.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public MediaFileViewModel? GetElement(MediaFileSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.MediaFiles
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<MediaFileViewModel> GetFilteredList(MediaFileSearchModel model)
{
if (!model.ProductId.HasValue && !model.Id.HasValue)
{
return new();
}
using var context = new Database();
if (model.ProductId.HasValue)
{
return context.MediaFiles.Where(x => x.ProductId == model.ProductId).Select(x => x.GetViewModel).ToList();
}
return context.MediaFiles.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
}
public List<MediaFileViewModel> GetFullList()
{
using var context = new Database();
return context.MediaFiles
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public MediaFileViewModel? Insert(MediaFileBindingModel model)
{
using var context = new Database();
var newProduct = MediaFile.Create(model);
if (newProduct == null)
{
return null;
}
context.MediaFiles.Add(newProduct);
context.SaveChanges();
return newProduct.GetViewModel;
}
public MediaFileViewModel? Update(MediaFileBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
try
{
var product = context.MediaFiles.FirstOrDefault(rec =>
rec.Id == model.Id);
if (product == null)
{
return null;
}
product.Update(model);
context.SaveChanges();
transaction.Commit();
return product.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -18,6 +18,11 @@ namespace DatabaseImplement.Implements
{
using var context = new Database();
var element = context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
@ -35,54 +40,43 @@ namespace DatabaseImplement.Implements
return null;
}
using var context = new Database();
return context.Products.Include(x => x.Sale)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<ProductViewModel> 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) && string.IsNullOrEmpty(model.Category))
if (!model.IsBeingSold.HasValue && !model.Price.HasValue && !model.Rate.HasValue && !model.Amount.HasValue && string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
if (model.Price.HasValue)
{
return context.Products.Include(x => x.Sale)
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.Where(x => x.Price <= model.Price)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.PriceFrom.HasValue && model.PriceTo.HasValue)
{
return context.Products.Include(x => x.Sale)
.Where(x => x.Price <= model.PriceTo && x.Price >= model.PriceFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.PriceFrom.HasValue)
{
return context.Products.Include(x => x.Sale)
.Where(x => x.Price >= model.PriceFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.PriceTo.HasValue)
{
return context.Products.Include(x => x.Sale)
.Where(x => x.Price <= model.PriceTo)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.Rate.HasValue)
{
return context.Products.Include(x => x.Sale)
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.Where(x => x.Rate <= model.Rate)
.ToList()
.Select(x => x.GetViewModel)
@ -90,22 +84,24 @@ namespace DatabaseImplement.Implements
}
if (model.Amount.HasValue && model.IsBeingSold.HasValue)
{
return context.Products.Include(x => x.Sale)
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.Where(x => x.IsBeingSold == model.IsBeingSold && x.Amount >= model.Amount)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
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))
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.Where(x => x.Name == model.Name)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
@ -114,7 +110,12 @@ namespace DatabaseImplement.Implements
public List<ProductViewModel> GetFullList()
{
using var context = new Database();
return context.Products.Include(x => x.Sale)
return context.Products
.Include(x => x.Name)
.Include(x => x.Price)
.Include(x => x.IsBeingSold)
.Include(x => x.Rate)
.Include(x => x.Amount)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
@ -124,16 +125,6 @@ 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;
@ -149,7 +140,7 @@ namespace DatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var product = context.Products.Include(x => x.Sale).FirstOrDefault(rec =>
var product = context.Products.FirstOrDefault(rec =>
rec.Id == model.Id);
if (product == null)
{
@ -158,7 +149,7 @@ namespace DatabaseImplement.Implements
product.Update(model);
context.SaveChanges();
transaction.Commit();
return new();
return product.GetViewModel;
}
catch
{

View File

@ -1,214 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using DataModels.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class PurchaseStorage : IPurchaseStorage
{
public PurchaseViewModel? Delete(PurchaseSearchModel model)
{
using var context = new Database();
var element = context.Purchases.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Purchases.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.Purchases
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<PurchaseViewModel> GetFullList(PurchaseSearchModel? model)
{
using var context = new Database();
return context.Purchases
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model)
{
using var context = new Database();
if (model.UserId == Guid.Empty && !model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue
&& !model.DateFrom.HasValue && !model.Status.HasValue)
{
return new();
}
if (model.CostFrom.HasValue && model.CostTo.HasValue)
{
return context.Purchases
.Where(x => x.Cost <= model.CostTo && x.Cost >= model.CostFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.CostFrom.HasValue)
{
return context.Purchases
.Where(x => x.Cost >= model.CostFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.CostTo.HasValue)
{
return context.Purchases
.Where(x => x.Cost <= model.CostTo)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Purchases
.Where(x => x.DateCreated <= model.DateTo && x.DateCreated >= model.DateFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.DateFrom.HasValue)
{
return context.Purchases
.Where(x => x.DateCreated >= model.DateFrom)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.DateTo.HasValue)
{
return context.Purchases
.Where(x => x.DateCreated <= model.DateTo)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.UserId != Guid.Empty)
{
return context.Purchases
.Where(x => x.UserId == model.UserId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
return context.Purchases
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public PurchaseViewModel? Insert(PurchaseBindingModel model)
{
using var context = new Database();
var purchase = Purchase.Create(context, model);
if (purchase == null)
return null;
var cartItems = context.CartItems
.Where(x => x.PurchaseId == purchase.Id).ToList()
.Select(x => x.GetViewModel).ToList();
var products = new List<Product>();
foreach (var item in cartItems)
{
var product = context.Products
.Where(x => x.Id == item.ProductId)
.FirstOrDefault();
products.Add(product);
}
purchase.Products = products;
context.Purchases.Add(purchase);
context.SaveChanges();
return purchase.GetViewModel;
}
public PurchaseViewModel? Update(PurchaseBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
try
{
var purchase = context.Purchases.FirstOrDefault(rec =>
rec.Id == model.Id);
if (purchase == null)
{
return null;
}
purchase.Update(model);
context.SaveChanges();
transaction.Commit();
return purchase.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public List<CartItemViewModel> GetCartItems(PurchaseSearchModel model)
{
using var context = new Database();
var cartItems = context.CartItems
.Where(x => x.PurchaseId == model.Id).ToList()
.Select(x => x.GetViewModel).ToList();
if (cartItems == null)
{
return null;
}
return cartItems;
}
public List<ProductViewModel> GetProducts(PurchaseSearchModel model)
{
using var context = new Database();
if (!model.Id.HasValue)
{
return null;
}
var purchase = context.Purchases
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id));
var products = new List<ProductViewModel>();
if (purchase.Products == null)
return null;
foreach (var product in purchase.Products)
products.Add(product.GetViewModel);
return products;
}
}
}

View File

@ -1,113 +0,0 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class SaleStorage : ISaleStorage
{
public SaleViewModel? Delete(SaleBindingModel model)
{
using var context = new Database();
var element = context.Sales
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Sales.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public SaleViewModel? GetElement(SaleSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.Sales
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<SaleViewModel> GetFilteredList(SaleSearchModel model)
{
if (string.IsNullOrEmpty(model.Category))
{
return new();
}
using var context = new Database();
return context.Sales
.Where(x => x.Category.Contains(model.Category))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<SaleViewModel> GetFullList()
{
using var context = new Database();
return context.Sales
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public SaleViewModel? Insert(SaleBindingModel model)
{
using var context = new Database();
var newSale = Sale.Create(context, model);
if (newSale == null)
{
return null;
}
foreach (var product in context.Products)
{
if (product.Category == newSale.Category)
{
product.Sale = newSale;
product.SaleId = newSale.Id;
}
}
context.Sales.Add(newSale);
context.SaveChanges();
return newSale.GetViewModel;
}
public SaleViewModel? Update(SaleBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
try
{
var sale = context.Sales.FirstOrDefault(rec =>
rec.Id == model.Id);
if (sale == null)
{
return null;
}
sale.Update(model);
context.SaveChanges();
transaction.Commit();
return new();
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,92 +0,0 @@
using Contracts.BindingModels;
using Contracts.Converters;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class SellStorage : ISellStorage
{
public SellViewModel? Delete(SellSearchModel model)
{
using var context = new Database();
var element = context.Sells.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Sells.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public SellViewModel? GetElement(SellSearchModel model)
{
using var context = new Database();
return context.Sells
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public IEnumerable<SellViewModel> GetFilteredList(SellSearchModel? model)
{
throw new NotImplementedException();
}
public IEnumerable<SellViewModel> GetFullList(SellSearchModel? model)
{
using var context = new Database();
return context.Sells
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.ToList()
.Select((Sell sell, int index) => sell.GetViewModel)
.ToList();
}
public SellViewModel? Insert(SellBindingModel model)
{
using var context = new Database();
var sell = Sell.Create(context, model);
if (sell == null)
{
return null;
}
context.Sells.Add(sell);
context.SaveChanges();
return sell.GetViewModel;
}
public SellViewModel? Update(SellBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
try
{
var sell = context.Sells.FirstOrDefault(rec => rec.Id == model.Id);
if (sell == null)
{
return null;
}
sell.Update(model);
context.SaveChanges();
transaction.Commit();
return sell.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -37,7 +37,7 @@ namespace DatabaseImplement.Implements
}
using var context = new Database();
return context.Suppliers
//.Include(x => x.Name)
.Include(x => x.Name)
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;

View File

@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -107,7 +106,7 @@ namespace DatabaseImplement.Implements
.ToList();
}
public bool? Insert(SupplyBindingModel model)
public SupplyViewModel? Insert(SupplyBindingModel model)
{
using var context = new Database();
var newProduct = Supply.Create(context, model);
@ -116,18 +115,11 @@ namespace DatabaseImplement.Implements
return null;
}
context.Supplies.Add(newProduct);
try
{
context.SaveChanges();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
return true;
return newProduct.GetViewModel;
}
public bool? Update(SupplyBindingModel model)
public SupplyViewModel? Update(SupplyBindingModel model)
{
using var context = new Database();
using var transaction = context.Database.BeginTransaction();
@ -137,12 +129,13 @@ namespace DatabaseImplement.Implements
rec.Id == model.Id);
if (product == null)
{
return false;
return null;
}
product.Update(model);
context.SaveChanges();
product.UpdateProducts(context, model);
transaction.Commit();
return true;
return product.GetViewModel;
}
catch
{

View File

@ -106,20 +106,5 @@ 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();
}
}
}

View File

@ -1,395 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240623130351_many-to-many")]
partial class manytomany
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,90 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class manytomany : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "UserId",
table: "Purchases",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.CreateTable(
name: "PurchaseProducts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PurchaseId = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseProducts", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseProducts_Purchases_PurchaseId",
column: x => x.PurchaseId,
principalTable: "Purchases",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Purchases_UserId",
table: "Purchases",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseProducts_ProductId",
table: "PurchaseProducts",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseProducts_PurchaseId",
table: "PurchaseProducts",
column: "PurchaseId");
migrationBuilder.AddForeignKey(
name: "FK_Purchases_Users_UserId",
table: "Purchases",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Purchases_Users_UserId",
table: "Purchases");
migrationBuilder.DropTable(
name: "PurchaseProducts");
migrationBuilder.DropIndex(
name: "IX_Purchases_UserId",
table: "Purchases");
migrationBuilder.DropColumn(
name: "UserId",
table: "Purchases");
}
}
}

View File

@ -1,477 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240624105540_sellproducts")]
partial class sellproducts
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SellId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SellId");
b.ToTable("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("SupplyDocs");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("SellProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
.WithMany("Products")
.HasForeignKey("SellId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Sell");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
b.Navigation("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,104 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class sellproducts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "UserId",
table: "Sells",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "SellProducts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
SellId = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SellProducts", x => x.Id);
table.ForeignKey(
name: "FK_SellProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SellProducts_Sells_SellId",
column: x => x.SellId,
principalTable: "Sells",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SupplyDocs",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
SupplyId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SupplyDocs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Sells_UserId",
table: "Sells",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_SellProducts_ProductId",
table: "SellProducts",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_SellProducts_SellId",
table: "SellProducts",
column: "SellId");
migrationBuilder.AddForeignKey(
name: "FK_Sells_Users_UserId",
table: "Sells",
column: "UserId",
principalTable: "Users",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Sells_Users_UserId",
table: "Sells");
migrationBuilder.DropTable(
name: "SellProducts");
migrationBuilder.DropTable(
name: "SupplyDocs");
migrationBuilder.DropIndex(
name: "IX_Sells_UserId",
table: "Sells");
migrationBuilder.DropColumn(
name: "UserId",
table: "Sells");
}
}
}

View File

@ -1,496 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240625085945_dates_migration")]
partial class dates_migration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SellId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SellId");
b.ToTable("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateArriving")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateComplete")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("SupplyDocs");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("SellProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
.WithMany("Products")
.HasForeignKey("SellId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Sell");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
b.Navigation("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,60 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class dates_migration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "DateArriving",
table: "Supplies",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DateComplete",
table: "Supplies",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_MediaFiles_ProductId",
table: "MediaFiles",
column: "ProductId");
migrationBuilder.AddForeignKey(
name: "FK_MediaFiles_Products_ProductId",
table: "MediaFiles",
column: "ProductId",
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MediaFiles_Products_ProductId",
table: "MediaFiles");
migrationBuilder.DropIndex(
name: "IX_MediaFiles_ProductId",
table: "MediaFiles");
migrationBuilder.DropColumn(
name: "DateArriving",
table: "Supplies");
migrationBuilder.DropColumn(
name: "DateComplete",
table: "Supplies");
}
}
}

View File

@ -1,496 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240625124236_image")]
partial class image
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasColumnType("bytea");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SellId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SellId");
b.ToTable("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateArriving")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateComplete")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("SupplyDocs");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("SellProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
.WithMany("Products")
.HasForeignKey("SellId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Sell");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
b.Navigation("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class image : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Location",
table: "MediaFiles");
migrationBuilder.AddColumn<byte[]>(
name: "Image",
table: "MediaFiles",
type: "bytea",
nullable: false,
defaultValue: new byte[0]);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Image",
table: "MediaFiles");
migrationBuilder.AddColumn<string>(
name: "Location",
table: "MediaFiles",
type: "text",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -1,492 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240625131604_image2")]
partial class image2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasColumnType("bytea");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SellId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SellId");
b.ToTable("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateArriving")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateComplete")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("SupplyDocs");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("SellProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
.WithMany("Products")
.HasForeignKey("SellId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Sell");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
b.Navigation("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,29 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class image2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Name",
table: "MediaFiles");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Name",
table: "MediaFiles",
type: "text",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -1,495 +0,0 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240625215017_purchase")]
partial class purchase
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasColumnType("bytea");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Amount")
.HasColumnType("integer");
b.Property<bool>("IsBeingSold")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<double>("Rate")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("DatePurchase")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("PurchaseId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("PurchaseId");
b.ToTable("PurchaseProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateSell")
.HasColumnType("timestamp without time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Sells");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SellId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SellId");
b.ToTable("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Deals")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplierId");
b.ToTable("SupplierProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateArriving")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateComplete")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<Guid>("SupplierId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("SupplierId");
b.ToTable("Supplies");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("SupplyDocs");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("SupplyId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("SupplyId");
b.ToTable("SupplyProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp without time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("OnlyImportantMails")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("RoleId")
.HasColumnType("uuid");
b.Property<string>("SecondName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("PurchaseProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
.WithMany("Products")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Purchase");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.HasOne("DatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("SellProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
.WithMany("Products")
.HasForeignKey("SellId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Sell");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany("Products")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Supplier");
});
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
.WithMany("Products")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Supply");
});
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
{
b.HasOne("DatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId");
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("PurchaseProducts");
b.Navigation("SellProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

Some files were not shown because too many files have changed in this diff Show More