1
This commit is contained in:
parent
82308fd351
commit
d402b05d5f
@ -40,6 +40,7 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
h1Paragraph.Format.Font.Bold = true;
|
h1Paragraph.Format.Font.Bold = true;
|
||||||
h1Paragraph.Format.Font.Size = 16;
|
h1Paragraph.Format.Font.Size = 16;
|
||||||
h1Paragraph.AddText(h1); // Текст заголовка
|
h1Paragraph.AddText(h1); // Текст заголовка
|
||||||
|
h1Paragraph.Format.Alignment = ParagraphAlignment.Center;
|
||||||
|
|
||||||
Paragraph h2Paragraph = section.AddParagraph();
|
Paragraph h2Paragraph = section.AddParagraph();
|
||||||
h2Paragraph.Format.Font.Bold = true;
|
h2Paragraph.Format.Font.Bold = true;
|
||||||
@ -64,18 +65,19 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
table.Borders.Width = 0.75;
|
table.Borders.Width = 0.75;
|
||||||
|
|
||||||
// Определение колонок
|
// Определение колонок
|
||||||
Column columnProduct = table.AddColumn(Unit.FromCentimeter(1));
|
Column columnProduct = table.AddColumn(Unit.FromCentimeter(3));
|
||||||
columnProduct.Format.Alignment = ParagraphAlignment.Left;
|
|
||||||
|
|
||||||
Column columnPrice = table.AddColumn(Unit.FromCentimeter(1));
|
Column columnPrice = table.AddColumn(Unit.FromCentimeter(2));
|
||||||
columnPrice.Format.Alignment = ParagraphAlignment.Right;
|
|
||||||
|
|
||||||
// Добавление строк с товарами
|
// Добавление строк с товарами
|
||||||
foreach (var product in model.Products)
|
foreach (var product in model.Products)
|
||||||
{
|
{
|
||||||
Row row = table.AddRow();
|
var row = table.AddRow();
|
||||||
row.Cells[0].AddParagraph(product.Name);
|
var cell0 = row[0];
|
||||||
row.Cells[1].AddParagraph($"{product.ActualPrice} руб.");
|
cell0.AddParagraph(product.Name);
|
||||||
|
|
||||||
|
var cell1 = row[1];
|
||||||
|
cell1.AddParagraph($"{product.ActualPrice} руб.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Paragraph totalParagraph = section.AddParagraph();
|
Paragraph totalParagraph = section.AddParagraph();
|
||||||
|
@ -101,5 +101,13 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
_logger.LogInformation("Cart Item. Id: { Id}", model.Id);
|
_logger.LogInformation("Cart Item. Id: { Id}", model.Id);
|
||||||
}
|
}
|
||||||
|
public void CloseItem(CartItemViewModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_cartItemStorage.CloseItem(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,12 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
public class PurchaseLogic : IPurchaseLogic
|
public class PurchaseLogic : IPurchaseLogic
|
||||||
{
|
{
|
||||||
private readonly IPurchaseStorage _purchaseStorage;
|
private readonly IPurchaseStorage _purchaseStorage;
|
||||||
private readonly IProductStorage _productStorage;
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public PurchaseLogic(IPurchaseStorage purchaseStorage, IProductStorage productStorage, ILogger<PurchaseLogic> logger)
|
public PurchaseLogic(IPurchaseStorage purchaseStorage, ILogger<PurchaseLogic> logger)
|
||||||
{
|
{
|
||||||
_purchaseStorage = purchaseStorage;
|
_purchaseStorage = purchaseStorage;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_productStorage = productStorage;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,5 +16,7 @@ namespace Contracts.BindingModels
|
|||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
public Guid? PurchaseId { get; set; }
|
public Guid? PurchaseId { get; set; }
|
||||||
|
public IPurchase? Purchase { get; set; }
|
||||||
|
public bool IsClosed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,6 @@ namespace Contracts.BusinessLogicContracts
|
|||||||
List<CartItemViewModel> ReadElements(CartItemSearchModel? model);
|
List<CartItemViewModel> ReadElements(CartItemSearchModel? model);
|
||||||
|
|
||||||
bool Delete(CartItemBindingModel model);
|
bool Delete(CartItemBindingModel model);
|
||||||
|
void CloseItem(CartItemViewModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ namespace Contracts.SearchModels
|
|||||||
public Guid? ProductId { get; set; }
|
public Guid? ProductId { get; set; }
|
||||||
public string? ProductName { get; set; }
|
public string? ProductName { get; set; }
|
||||||
public Guid? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
|
public bool? isClosed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,6 @@ namespace Contracts.StorageContracts
|
|||||||
CartItemViewModel? Insert(CartItemBindingModel model);
|
CartItemViewModel? Insert(CartItemBindingModel model);
|
||||||
CartItemViewModel? Update(CartItemBindingModel model);
|
CartItemViewModel? Update(CartItemBindingModel model);
|
||||||
CartItemViewModel? Delete(CartItemBindingModel model);
|
CartItemViewModel? Delete(CartItemBindingModel model);
|
||||||
|
void CloseItem(CartItemViewModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,6 @@ namespace DataModels.Models
|
|||||||
DateTime DateCreated { get; set; }
|
DateTime DateCreated { get; set; }
|
||||||
Guid ProductId { get; set; }
|
Guid ProductId { get; set; }
|
||||||
string ProductName { get; set; }
|
string ProductName { get; set; }
|
||||||
|
bool IsClosed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,23 @@ namespace DatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<CartItemViewModel> GetFilteredList(CartItemSearchModel model)
|
public List<CartItemViewModel> GetFilteredList(CartItemSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.UserId == Guid.Empty && string.IsNullOrEmpty(model.ProductName))
|
|
||||||
|
if (model.UserId == Guid.Empty && string.IsNullOrEmpty(model.ProductName) && model.isClosed == null)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine();
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
|
|
||||||
|
if (model.UserId != Guid.Empty && model.isClosed != null)
|
||||||
|
{
|
||||||
|
return context.CartItems
|
||||||
|
.Where(x => x.UserId == model.UserId).Where(x => x.IsClosed == model.isClosed)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
if (model.UserId != Guid.Empty)
|
if (model.UserId != Guid.Empty)
|
||||||
{
|
{
|
||||||
return context.CartItems
|
return context.CartItems
|
||||||
@ -53,6 +65,14 @@ namespace DatabaseImplement.Implements
|
|||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
if (model.isClosed != null)
|
||||||
|
{
|
||||||
|
return context.CartItems
|
||||||
|
.Where(x => x.IsClosed == model.isClosed)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
return context.CartItems
|
return context.CartItems
|
||||||
.Where(x => x.ProductName.Contains(model.ProductName))
|
.Where(x => x.ProductName.Contains(model.ProductName))
|
||||||
.ToList()
|
.ToList()
|
||||||
@ -108,5 +128,41 @@ namespace DatabaseImplement.Implements
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void CloseItem(CartItemViewModel 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
var product = context.Products.FirstOrDefault(x => x.Id == model.ProductId);
|
||||||
|
|
||||||
|
if (product == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var binding = product.GetBindingModel();
|
||||||
|
binding.Amount -= item.Count;
|
||||||
|
product.Update(binding);
|
||||||
|
|
||||||
|
item.IsClosed = true;
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace DatabaseImplement.Implements
|
|||||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model)
|
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel? model)
|
||||||
{
|
{
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
if (model.UserId == Guid.Empty && !model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue
|
if (model != null && model.UserId == Guid.Empty && !model.CostFrom.HasValue && !model.CostTo.HasValue && !model.DateTo.HasValue
|
||||||
&& !model.DateFrom.HasValue && !model.Status.HasValue)
|
&& !model.DateFrom.HasValue && !model.Status.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
@ -121,32 +121,58 @@ namespace DatabaseImplement.Implements
|
|||||||
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
var purchase = Purchase.Create(context, model);
|
var purchase = Purchase.Create(context, model);
|
||||||
if (purchase == null)
|
if (purchase == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
var cartItems = context.CartItems
|
var cartItems = context.CartItems
|
||||||
.Where(x => x.PurchaseId == purchase.Id).ToList()
|
.Where(x => !x.IsClosed).ToList();
|
||||||
.Select(x => x.GetViewModel).ToList();
|
var updated = new List<CartItem>();
|
||||||
|
|
||||||
|
|
||||||
var products = new List<Product>();
|
|
||||||
|
|
||||||
foreach (var item in cartItems)
|
foreach (var item in cartItems)
|
||||||
|
{
|
||||||
|
var bitem = item.GetBindingModel();
|
||||||
|
bitem.IsClosed = true;
|
||||||
|
bitem.PurchaseId = purchase.Id;
|
||||||
|
bitem.Purchase = purchase;
|
||||||
|
item.Update(bitem);
|
||||||
|
updated.Add(item);
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
var products = new List<Product>();
|
||||||
|
|
||||||
|
foreach (var item in updated)
|
||||||
{
|
{
|
||||||
var product = context.Products
|
var product = context.Products
|
||||||
.Where(x => x.Id == item.ProductId)
|
.FirstOrDefault(x => x.Id == item.ProductId);
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
products.Add(product);
|
products.Add(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
purchase.Products = products;
|
purchase.Products = products;
|
||||||
context.Purchases.Add(purchase);
|
context.Purchases.Add(purchase);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
return purchase.GetViewModel;
|
return purchase.GetViewModel;
|
||||||
}
|
}
|
||||||
|
catch (DbUpdateException ex)
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw new InvalidOperationException("Не удалось сохранить изменения.", ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
transaction.Dispose();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public PurchaseViewModel? Update(PurchaseBindingModel model)
|
public PurchaseViewModel? Update(PurchaseBindingModel model)
|
||||||
{
|
{
|
||||||
@ -196,17 +222,18 @@ namespace DatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var purchase = context.Purchases
|
|
||||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id));
|
|
||||||
|
|
||||||
var products = new List<ProductViewModel>();
|
var products = new List<ProductViewModel>();
|
||||||
|
var cartItems = GetCartItems(model);
|
||||||
if (purchase.Products == null)
|
if (cartItems != null)
|
||||||
return null;
|
{
|
||||||
|
foreach (var item in cartItems)
|
||||||
foreach (var product in purchase.Products)
|
{
|
||||||
products.Add(product.GetViewModel);
|
var product = context.Products
|
||||||
|
.FirstOrDefault(x => x.Id == item.ProductId)?.GetViewModel;
|
||||||
|
if (product != null) products.Add(product) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
571
DatabaseImplement/Migrations/20240730191618_closeitem.Designer.cs
generated
Normal file
571
DatabaseImplement/Migrations/20240730191618_closeitem.Designer.cs
generated
Normal file
@ -0,0 +1,571 @@
|
|||||||
|
// <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("20240730191618_closeitem")]
|
||||||
|
partial class closeitem
|
||||||
|
{
|
||||||
|
/// <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.CartItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreated")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("IsClosed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("PurchaseId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.HasIndex("PurchaseId");
|
||||||
|
|
||||||
|
b.ToTable("CartItems");
|
||||||
|
});
|
||||||
|
|
||||||
|
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<string>("Category")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
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.Property<Guid?>("SaleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SaleId");
|
||||||
|
|
||||||
|
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?>("DateClosed")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreated")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("IsPaid")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<int>("ProductCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
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.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.Sale", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Category")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("End")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<string>("FullDescription")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("Value")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sales");
|
||||||
|
});
|
||||||
|
|
||||||
|
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<int>("Bonus")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
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.CartItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("PurchaseId");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Purchase");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Sale", "Sale")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SaleId");
|
||||||
|
|
||||||
|
b.Navigation("Sale");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("SellProducts")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SellId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Sell");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SupplierId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Supplier");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SupplierId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Supplier");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SupplyId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Supply");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId");
|
||||||
|
|
||||||
|
b.Navigation("Role");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("SellProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sale", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
DatabaseImplement/Migrations/20240730191618_closeitem.cs
Normal file
29
DatabaseImplement/Migrations/20240730191618_closeitem.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class closeitem : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsClosed",
|
||||||
|
table: "CartItems",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsClosed",
|
||||||
|
table: "CartItems");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,9 @@ namespace DatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("timestamp without time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("IsClosed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<Guid>("ProductId")
|
b.Property<Guid>("ProductId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("PurchaseId");
|
b.HasIndex("PurchaseId");
|
||||||
|
|
||||||
b.ToTable("CartItems");
|
b.ToTable("CartItems", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||||
@ -73,7 +76,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ProductId");
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
b.ToTable("MediaFiles");
|
b.ToTable("MediaFiles", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||||
@ -111,7 +114,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SaleId");
|
b.HasIndex("SaleId");
|
||||||
|
|
||||||
b.ToTable("Products");
|
b.ToTable("Products", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
@ -145,7 +148,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
b.ToTable("Purchases");
|
b.ToTable("Purchases", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||||
@ -160,7 +163,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Roles");
|
b.ToTable("Roles", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Sale", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Sale", b =>
|
||||||
@ -195,7 +198,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Sales");
|
b.ToTable("Sales", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
@ -214,7 +217,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
b.ToTable("Sells");
|
b.ToTable("Sells", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||||
@ -238,7 +241,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SellId");
|
b.HasIndex("SellId");
|
||||||
|
|
||||||
b.ToTable("SellProducts");
|
b.ToTable("SellProducts", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||||
@ -256,7 +259,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Suppliers");
|
b.ToTable("Suppliers", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||||
@ -280,7 +283,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SupplierId");
|
b.HasIndex("SupplierId");
|
||||||
|
|
||||||
b.ToTable("SupplierProducts");
|
b.ToTable("SupplierProducts", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
@ -315,7 +318,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SupplierId");
|
b.HasIndex("SupplierId");
|
||||||
|
|
||||||
b.ToTable("Supplies");
|
b.ToTable("Supplies", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||||
@ -333,7 +336,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("SupplyDocs");
|
b.ToTable("SupplyDocs", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||||
@ -357,7 +360,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SupplyId");
|
b.HasIndex("SupplyId");
|
||||||
|
|
||||||
b.ToTable("SupplyProducts");
|
b.ToTable("SupplyProducts", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||||
@ -398,7 +401,7 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("RoleId");
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
b.ToTable("Users");
|
b.ToTable("Users", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.CartItem", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.CartItem", b =>
|
||||||
|
@ -27,6 +27,8 @@ namespace DatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public Guid ProductId { get; set; }
|
public Guid ProductId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
public bool IsClosed { get; set; }
|
||||||
|
[Required]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
public virtual Product? Product { get; set; }
|
public virtual Product? Product { get; set; }
|
||||||
public virtual Purchase? Purchase { get; set; }
|
public virtual Purchase? Purchase { get; set; }
|
||||||
@ -41,6 +43,7 @@ namespace DatabaseImplement.Models
|
|||||||
ProductId = model.ProductId,
|
ProductId = model.ProductId,
|
||||||
ProductName = model.ProductName,
|
ProductName = model.ProductName,
|
||||||
PurchaseId = model.PurchaseId,
|
PurchaseId = model.PurchaseId,
|
||||||
|
IsClosed = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(CartItemBindingModel model)
|
public void Update(CartItemBindingModel model)
|
||||||
@ -51,6 +54,7 @@ namespace DatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
PurchaseId = model.PurchaseId;
|
PurchaseId = model.PurchaseId;
|
||||||
|
IsClosed = model.IsClosed;
|
||||||
}
|
}
|
||||||
public CartItemViewModel GetViewModel
|
public CartItemViewModel GetViewModel
|
||||||
{
|
{
|
||||||
|
@ -32,11 +32,12 @@ namespace DatabaseImplement.Models
|
|||||||
public bool IsPaid { get; set; }
|
public bool IsPaid { get; set; }
|
||||||
public virtual User? User { get; set; }
|
public virtual User? User { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public List<Product> Products { get; set; }
|
public List<Product>? Products { get; set; }
|
||||||
public static Purchase Create(Database context, PurchaseBindingModel model)
|
public static Purchase Create(Database context, PurchaseBindingModel model)
|
||||||
{
|
{
|
||||||
return new Purchase()
|
return new Purchase()
|
||||||
{
|
{
|
||||||
|
Id = model.Id,
|
||||||
DateCreated = model.DateCreated,
|
DateCreated = model.DateCreated,
|
||||||
UserId = model.UserId,
|
UserId = model.UserId,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
|
@ -4,6 +4,7 @@ using Contracts.BusinessLogicContracts;
|
|||||||
using Contracts.Exceptions;
|
using Contracts.Exceptions;
|
||||||
using Contracts.SearchModels;
|
using Contracts.SearchModels;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
|
using DatabaseImplement.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace RestAPI.Controllers
|
namespace RestAPI.Controllers
|
||||||
@ -35,6 +36,19 @@ namespace RestAPI.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
public List<CartItemViewModel> GetFilteredList(Guid userId, bool? isclosed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _cartItemLogic.ReadElements(new CartItemSearchModel() { UserId = userId, isClosed = isclosed });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
public CartItemViewModel GetElement(Guid id)
|
public CartItemViewModel GetElement(Guid id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -118,30 +132,6 @@ namespace RestAPI.Controllers
|
|||||||
return Results.Problem(ex.Message);
|
return Results.Problem(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpDelete]
|
|
||||||
public IResult DeleteAll()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _cartItemLogic.ReadElements(null);
|
|
||||||
var res = new List<IResult>();
|
|
||||||
|
|
||||||
foreach (var element in list)
|
|
||||||
{
|
|
||||||
_cartItemLogic.Delete(new() { Id = element.Id });
|
|
||||||
}
|
|
||||||
return Results.Ok(res);
|
|
||||||
}
|
|
||||||
catch (ElementNotFoundException ex)
|
|
||||||
{
|
|
||||||
_logger.LogInformation(ex, "Item not found");
|
|
||||||
return Results.NoContent();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error delete item");
|
|
||||||
return Results.Problem(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace WebApp.Pages
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cartItemsView = APIClient.GetRequest<List<CartItemViewModel>>($"cartitem/GetFullList?userId={id}");
|
cartItemsView = APIClient.GetRequest<List<CartItemViewModel>>($"cartitem/GetFilteredList?userId={id}&isclosed={false}");
|
||||||
}
|
}
|
||||||
public ProductViewModel GetProduct(Guid cartItemId)
|
public ProductViewModel GetProduct(Guid cartItemId)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<form class="d-flex" method="get">
|
<form class="d-flex" method="get">
|
||||||
<input asp-for="ProductsModel" type="search" placeholder="Поиск" name="search" value="" id="search">
|
<input asp-for="ProductsModel" type="search" placeholder="Поиск" name="search" value="" id="search">
|
||||||
<button class="btn btn-outline-success" type="submit"><i class="fas fa-search"></i></button>
|
<button class="btn btn-outline-success" style="margin-left: 5px" type="submit"><i class="fas fa-search"></i></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
@ -110,7 +110,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<span>Цена: @weapon.Price руб.</span>
|
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@
|
|||||||
<label for="quantity" class="me-2">Количество:</label>
|
<label for="quantity" class="me-2">Количество:</label>
|
||||||
<input type="number" id="quantity" name="quantity" min="1" max="@Model.productModel.Amount" value="1" class="form-control w-auto">
|
<input type="number" id="quantity" name="quantity" min="1" max="@Model.productModel.Amount" value="1" class="form-control w-auto">
|
||||||
</div>
|
</div>
|
||||||
<a asp-page="Login" asp-route-count=1 class="btn btn-primary" data-toggle="modal" data-target="#loginPromptModal">В корзину</a>
|
<a asp-page="Login" asp-route-count=1 class="btn btn-primary" style="margin-top: 5px" data-toggle="modal" data-target="#loginPromptModal">В корзину</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#shareModal">
|
<button type="button" class="btn btn-primary" style="margin-top: 5px" data-bs-toggle="modal" data-bs-target="#shareModal">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-share" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-share" viewBox="0 0 16 16">
|
||||||
<path d="M13.5 1a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.5 2.5 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5m-8.5 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m11 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3"></path>
|
<path d="M13.5 1a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.5 2.5 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5m-8.5 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m11 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using Babel.Licensing;
|
||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.Converters;
|
using Contracts.Converters;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
@ -38,6 +39,7 @@ namespace WebApp.Pages
|
|||||||
paymentViewModel.UserFirstName = userModel.FirstName;
|
paymentViewModel.UserFirstName = userModel.FirstName;
|
||||||
paymentViewModel.UserSecondName = userModel.SecondName;
|
paymentViewModel.UserSecondName = userModel.SecondName;
|
||||||
paymentViewModel.Email = userModel.Email;
|
paymentViewModel.Email = userModel.Email;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult OnPostAsync(Guid userId, double cost, string PaymentMethod)
|
public IActionResult OnPostAsync(Guid userId, double cost, string PaymentMethod)
|
||||||
@ -74,7 +76,7 @@ namespace WebApp.Pages
|
|||||||
throw new Exception("Something wrong LOL!");
|
throw new Exception("Something wrong LOL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
purchaseModel.Id = new Guid();
|
purchaseModel.Id = Guid.NewGuid();
|
||||||
purchaseModel.Status = PurchaseStatus.Processing;
|
purchaseModel.Status = PurchaseStatus.Processing;
|
||||||
purchaseModel.DateCreated = DateTime.Now;
|
purchaseModel.DateCreated = DateTime.Now;
|
||||||
|
|
||||||
@ -85,13 +87,6 @@ namespace WebApp.Pages
|
|||||||
throw new Exception("Something wrong LOL!");
|
throw new Exception("Something wrong LOL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
var response_delete = APIClient.DeleteRequest($"CartItem/DeleteAll/");
|
|
||||||
|
|
||||||
if (response_delete is null || response_delete is not string)
|
|
||||||
{
|
|
||||||
throw new Exception("Something wrong LOL!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return RedirectToPage("/User/Purchases");
|
return RedirectToPage("/User/Purchases");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>@ViewData["Title"] - 21 GUNS</title>
|
<title>@ViewData["Title"] - 21 GUNS</title>
|
||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" />
|
||||||
<link rel="stylesheet" href="~/WebApp.styles.css" asp-append-version="true" />
|
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[emailprotected]/dist/umd/popper.min.js"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
|
||||||
<script src="https://api-maps.yandex.ru/2.0-stable/?apikey=69ff7f14-0c56-41b5-814c-ce13b64021f5&load=package.standard&lang=ru-RU" type="text/javascript"></script>
|
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-5/3.0.0-alpha14/css/tempus-dominus.css" rel="stylesheet" />
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-5/3.0.0-alpha14/js/tempus-dominus.min.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
@ -83,6 +80,12 @@
|
|||||||
|
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
|
||||||
|
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
|
||||||
@await RenderSectionAsync("Scripts", required: false)
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
@ -102,9 +102,6 @@ button.accept-policy {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*DROPDOWN*/
|
/*DROPDOWN*/
|
||||||
|
|
||||||
.dropdown .form-group {
|
.dropdown .form-group {
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<img src="data:image/png;base64,@Convert.ToBase64String(Model.GetStatistics())" class="card-img-top" alt="Статистика">
|
@* <img src="data:image/png;base64,@Convert.ToBase64String(Model.GetStatistics())" class="card-img-top" alt="Статистика"> *@
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="navbarDropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="btn btn-secondary dropdown-toggle" style="margin-right: 5px" type="button" id="navbarDropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
Фильтр
|
Фильтр
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||||
@ -40,10 +40,10 @@
|
|||||||
<form class="px-3 py-2" method="get">
|
<form class="px-3 py-2" method="get">
|
||||||
<h6>Фильтр даты</h6>
|
<h6>Фильтр даты</h6>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
От: <input type="datetime" class="form-control datetimepicker-input" id="dateFrom" name="datefrom" data-bs-target="#datetimepicker1" />
|
От: <input type="datetime" class="form-control datepicker" id="dateFrom" name="datefrom" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
До: <input type="datetime" class="form-control datetimepicker-input" id="dateTo" name="dateto" data-bs-target="#datetimepicker2" />
|
До: <input class="form-control datepicker" id="dateTo" name="dateto"/>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-outline-success w-100" type="submit">Применить</button>
|
<button class="btn btn-outline-success w-100" type="submit">Применить</button>
|
||||||
</form>
|
</form>
|
||||||
@ -123,11 +123,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<button class="btn-primary" type="submit" asp-page-handler="SendBill" asp-route-id="@item.Id">Получить чек</button>
|
<button id="sendCheckButton-@item.Id" class="btn-primary" style="width: 140px" type="submit" asp-page-handler="SendBill" asp-route-id="@item.Id" onclick="changeButtonState('sendCheckButton-@item.Id')">Получить чек</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -137,13 +138,12 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function changeButtonState(buttonId) {
|
||||||
function changeButtonState() {
|
// Получаем элемент кнопки по переданному ID
|
||||||
// Получаем элемент кнопки по ID
|
var button = document.getElementById(buttonId);
|
||||||
var button = document.getElementById('sendCheckButton');
|
|
||||||
|
|
||||||
// Меняем текст кнопки
|
// Меняем текст кнопки
|
||||||
button.innerHTML = 'Отправлено на почту';
|
button.innerHTML = 'Отправлено';
|
||||||
|
|
||||||
// Добавляем класс disabledButton для изменения стилей
|
// Добавляем класс disabledButton для изменения стилей
|
||||||
button.classList.add('disabledButton');
|
button.classList.add('disabledButton');
|
||||||
@ -152,22 +152,11 @@
|
|||||||
button.onclick = null;
|
button.onclick = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
<script type="text/javascript" >
|
$(document).ready(function () {
|
||||||
$(function () {
|
$('.datepicker').datepicker({
|
||||||
$('#datetimepicker1').datetimepicker({
|
format: 'yyyy-mm-dd',
|
||||||
format: 'L'
|
autoclose: true
|
||||||
});
|
|
||||||
$('#datetimepicker2').datetimepicker({
|
|
||||||
format: 'L',
|
|
||||||
useCurrent: false //Important! See issue #1075
|
|
||||||
});
|
|
||||||
$("#datetimepicker1").on("change.datetimepicker", function (e) {
|
|
||||||
$('#datetimepicker2').datetimepicker('minDate', e.date);
|
|
||||||
});
|
|
||||||
$("#datetimepicker2").on("change.datetimepicker", function (e) {
|
|
||||||
$('#datetimepicker1').datetimepicker('maxDate', e.date);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user