Compare commits
2 Commits
83488e97a9
...
ce3fa4f689
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce3fa4f689 | ||
|
|
2a2baba4a4 |
@@ -1,17 +1,19 @@
|
|||||||
@page "/kosik"
|
@page "/kosik"
|
||||||
|
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
@using Web_Jarmark.Data.Models
|
@using Web_Jarmark.Data.Models
|
||||||
@using Web_Jarmark.Data
|
@using Web_Jarmark.Data
|
||||||
|
|
||||||
@inject ApplicationDbContext DbContext
|
@inject ApplicationDbContext DbContext
|
||||||
@inject IHttpContextAccessor HttpContextAccessor
|
@inject IHttpContextAccessor HttpContextAccessor
|
||||||
@inject PersistentComponentState ApplicationState
|
@inject PersistentComponentState ApplicationState
|
||||||
|
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<PageTitle>Můj košík | Školní jarmark</PageTitle>
|
<PageTitle>Můj košík | Školní jarmark</PageTitle>
|
||||||
|
|
||||||
<main class="market-shell">
|
|
||||||
|
|
||||||
<main class="market-shell cart-page">
|
<main class="market-shell cart-page">
|
||||||
|
|
||||||
<div class="cart-header">
|
<div class="cart-header">
|
||||||
<div>
|
<div>
|
||||||
<span class="cart-eyebrow">ŠKOLNÍ JARMARK</span>
|
<span class="cart-eyebrow">ŠKOLNÍ JARMARK</span>
|
||||||
@@ -38,7 +40,9 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="cart-layout">
|
<div class="cart-layout">
|
||||||
|
|
||||||
<section class="cart-product-list">
|
<section class="cart-product-list">
|
||||||
|
|
||||||
<div class="cart-list-heading">
|
<div class="cart-list-heading">
|
||||||
<h2>Vybrané produkty</h2>
|
<h2>Vybrané produkty</h2>
|
||||||
<span>@cartItems.Count položek</span>
|
<span>@cartItems.Count položek</span>
|
||||||
@@ -47,6 +51,7 @@
|
|||||||
@foreach (var item in cartItems)
|
@foreach (var item in cartItems)
|
||||||
{
|
{
|
||||||
<article class="cart-product" @key="item.Id">
|
<article class="cart-product" @key="item.Id">
|
||||||
|
|
||||||
<div class="cart-product-image">
|
<div class="cart-product-image">
|
||||||
@if (!string.IsNullOrWhiteSpace(item.Product.ImageUrl))
|
@if (!string.IsNullOrWhiteSpace(item.Product.ImageUrl))
|
||||||
{
|
{
|
||||||
@@ -61,30 +66,60 @@
|
|||||||
|
|
||||||
<div class="cart-product-info">
|
<div class="cart-product-info">
|
||||||
<h3>@item.Product.Name</h3>
|
<h3>@item.Product.Name</h3>
|
||||||
|
|
||||||
@if (item.Product.Category != null)
|
@if (item.Product.Category != null)
|
||||||
{
|
{
|
||||||
<span class="cart-category">
|
<span class="cart-category">
|
||||||
@item.Product.Category.Name
|
@item.Product.Category.Name
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<p>@item.Product.Price.ToString("N0") Kč / ks</p>
|
<p>@item.Product.Price.ToString("N0") Kč / ks</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cart-product-quantity">
|
<div class="cart-product-quantity">
|
||||||
<span>Množství</span>
|
<span>Množství</span>
|
||||||
<strong>@item.Quantity ks</strong>
|
|
||||||
|
<div class="cart-quantity-controls">
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => ChangeQuantity(item, -1)"
|
||||||
|
disabled="@(item.Quantity <= 1)"
|
||||||
|
aria-label="Odebrat jeden kus">
|
||||||
|
−
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<strong>@item.Quantity</strong>
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => ChangeQuantity(item, 1)"
|
||||||
|
disabled="@(item.Quantity >= item.Product.StockQuantity)"
|
||||||
|
aria-label="Přidat jeden kus">
|
||||||
|
+
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cart-product-price">
|
<div class="cart-product-price">
|
||||||
<strong>
|
<strong>
|
||||||
@((item.Product.Price * item.Quantity).ToString("N0")) Kč
|
@((item.Product.Price * item.Quantity).ToString("N0")) Kč
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
class="cart-remove-button"
|
||||||
|
@onclick="() => RemoveFromCart(item)">
|
||||||
|
Odstranit
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
}
|
}
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<aside class="cart-summary">
|
<aside class="cart-summary">
|
||||||
|
|
||||||
<h2>Souhrn objednávky</h2>
|
<h2>Souhrn objednávky</h2>
|
||||||
|
|
||||||
<div class="cart-summary-row">
|
<div class="cart-summary-row">
|
||||||
@@ -111,17 +146,19 @@
|
|||||||
<p class="cart-summary-note">
|
<p class="cart-summary-note">
|
||||||
Objednávku dokončíš v dalším kroku.
|
Objednávku dokončíš v dalším kroku.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</main>
|
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string? cartToken;
|
private string? cartToken;
|
||||||
|
|
||||||
private List<CartItem> cartItems = new();
|
private List<CartItem> cartItems = new();
|
||||||
|
|
||||||
private bool isLoading = true;
|
private bool isLoading = true;
|
||||||
|
|
||||||
private PersistingComponentStateSubscription? subscription;
|
private PersistingComponentStateSubscription? subscription;
|
||||||
@@ -156,6 +193,7 @@
|
|||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(c => c.CartItems)
|
.Include(c => c.CartItems)
|
||||||
.ThenInclude(ci => ci.Product)
|
.ThenInclude(ci => ci.Product)
|
||||||
|
.ThenInclude(p => p.Category)
|
||||||
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||||
|
|
||||||
if (cart != null)
|
if (cart != null)
|
||||||
@@ -169,6 +207,68 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ChangeQuantity(CartItem item, int change)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(cartToken))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cart = await DbContext.Carts
|
||||||
|
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||||
|
|
||||||
|
if (cart == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cartItem = await DbContext.CartItems
|
||||||
|
.Include(ci => ci.Product)
|
||||||
|
.FirstOrDefaultAsync(ci =>
|
||||||
|
ci.Id == item.Id &&
|
||||||
|
ci.CartId == cart.Id);
|
||||||
|
|
||||||
|
if (cartItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int newQuantity = cartItem.Quantity + change;
|
||||||
|
|
||||||
|
if (newQuantity < 1 ||
|
||||||
|
newQuantity > cartItem.Product.StockQuantity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cartItem.Quantity = newQuantity;
|
||||||
|
cart.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await DbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
item.Quantity = newQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RemoveFromCart(CartItem item)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(cartToken))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cart = await DbContext.Carts
|
||||||
|
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||||
|
|
||||||
|
if (cart == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cartItem = await DbContext.CartItems
|
||||||
|
.FirstOrDefaultAsync(ci =>
|
||||||
|
ci.Id == item.Id &&
|
||||||
|
ci.CartId == cart.Id);
|
||||||
|
|
||||||
|
if (cartItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DbContext.CartItems.Remove(cartItem);
|
||||||
|
|
||||||
|
cart.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await DbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
cartItems.Remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
subscription?.Dispose();
|
subscription?.Dispose();
|
||||||
|
|||||||
@@ -1,5 +1,207 @@
|
|||||||
<h3>NovaObjednavka</h3>
|
@page "/nova-objednavka"
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using Web_Jarmark.Data
|
||||||
|
@using Web_Jarmark.Data.Models
|
||||||
|
@inject ApplicationDbContext DbContext
|
||||||
|
@inject IHttpContextAccessor HttpContextAccessor
|
||||||
|
@inject PersistentComponentState ApplicationState
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
|
<PageTitle>Dokončení objednávky | Školní jarmark</PageTitle>
|
||||||
|
|
||||||
|
<main class="market-shell">
|
||||||
|
<h1>Dokončení objednávky</h1>
|
||||||
|
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<p>Načítám objednávku...</p>
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrWhiteSpace(errorMessage))
|
||||||
|
{
|
||||||
|
<p>@errorMessage</p>
|
||||||
|
<a href="/kosik">Zpět do košíku</a>
|
||||||
|
}
|
||||||
|
else if (cartItems.Count == 0)
|
||||||
|
{
|
||||||
|
<p>Košík je prázdný.</p>
|
||||||
|
<a href="/">Zpět do katalogu</a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<section>
|
||||||
|
<h2>Vybrané produkty</h2>
|
||||||
|
|
||||||
|
@foreach (var item in cartItems)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
@item.Product.Name – @item.Quantity ks –
|
||||||
|
@((item.Product.Price * item.Quantity).ToString("N0")) Kč
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Celkem: @totalPrice.ToString("N0") Kč</h3>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Způsob platby</h2>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="radio"
|
||||||
|
name="payment"
|
||||||
|
checked="@(selectedPayment == PaymentMethod.BankTransfer)"
|
||||||
|
@onchange="@(() => selectedPayment = PaymentMethod.BankTransfer)" />
|
||||||
|
QR platba
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="radio"
|
||||||
|
name="payment"
|
||||||
|
checked="@(selectedPayment == PaymentMethod.Cash)"
|
||||||
|
@onchange="@(() => selectedPayment = PaymentMethod.Cash)" />
|
||||||
|
Hotově na místě
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<button class="cart-primary-button"
|
||||||
|
@onclick="CreateOrder"
|
||||||
|
disabled="@isSaving">
|
||||||
|
@(isSaving ? "Vytvářím objednávku..." : "Potvrdit objednávku")
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<p>@saveError</p>
|
||||||
|
<p><a href="/kosik">Zpět do košíku</a></p>
|
||||||
|
}
|
||||||
|
</main>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private string? cartToken;
|
||||||
|
private List<CartItem> cartItems = new();
|
||||||
|
|
||||||
|
private bool isLoading = true;
|
||||||
|
private bool isSaving;
|
||||||
|
private string? errorMessage;
|
||||||
|
private string? saveError;
|
||||||
|
|
||||||
|
private PaymentMethod selectedPayment = PaymentMethod.BankTransfer;
|
||||||
|
|
||||||
|
private PersistingComponentStateSubscription? subscription;
|
||||||
|
|
||||||
|
private decimal totalPrice =>
|
||||||
|
cartItems.Sum(item => item.Product.Price * item.Quantity);
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!ApplicationState.TryTakeFromJson<string>(
|
||||||
|
"CartToken", out cartToken)
|
||||||
|
|| string.IsNullOrWhiteSpace(cartToken))
|
||||||
|
{
|
||||||
|
var context = HttpContextAccessor.HttpContext;
|
||||||
|
|
||||||
|
cartToken = context?.Items["CartToken"] as string
|
||||||
|
?? context?.Request.Cookies["CartToken"];
|
||||||
|
}
|
||||||
|
|
||||||
|
subscription = ApplicationState.RegisterOnPersisting(() =>
|
||||||
|
{
|
||||||
|
ApplicationState.PersistAsJson("CartToken", cartToken);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(cartToken))
|
||||||
|
{
|
||||||
|
errorMessage = "Nepodařilo se najít tvůj košík.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cart = await DbContext.Carts
|
||||||
|
.AsNoTracking()
|
||||||
|
.Include(c => c.CartItems)
|
||||||
|
.ThenInclude(ci => ci.Product)
|
||||||
|
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||||
|
|
||||||
|
if (cart != null)
|
||||||
|
{
|
||||||
|
cartItems = cart.CartItems.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
errorMessage = "Při načítání košíku nastala chyba.";
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateOrder()
|
||||||
|
{
|
||||||
|
if (isSaving || string.IsNullOrWhiteSpace(cartToken))
|
||||||
|
return;
|
||||||
|
|
||||||
|
isSaving = true;
|
||||||
|
saveError = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cart = await DbContext.Carts
|
||||||
|
.Include(c => c.CartItems)
|
||||||
|
.ThenInclude(ci => ci.Product)
|
||||||
|
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||||
|
|
||||||
|
if (cart == null || cart.CartItems.Count == 0)
|
||||||
|
{
|
||||||
|
saveError = "Košík je prázdný.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var order = new Order
|
||||||
|
{
|
||||||
|
PreferredPayment = selectedPayment,
|
||||||
|
Status = OrderStatus.Pending,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
TotalAmount = cart.CartItems.Sum(
|
||||||
|
item => item.Product.Price * item.Quantity)
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in cart.CartItems)
|
||||||
|
{
|
||||||
|
order.OrderItems.Add(new OrderItem
|
||||||
|
{
|
||||||
|
ProductId = item.ProductId,
|
||||||
|
ProductName = item.Product.Name,
|
||||||
|
UnitPrice = item.Product.Price,
|
||||||
|
Quantity = item.Quantity,
|
||||||
|
Order = order,
|
||||||
|
Product = item.Product
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DbContext.Orders.Add(order);
|
||||||
|
|
||||||
|
DbContext.CartItems.RemoveRange(cart.CartItems);
|
||||||
|
|
||||||
|
await DbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
Navigation.NavigateTo($"/objednavka/{order.Id}");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
saveError = "Objednávku se nepodařilo uložit. Zkus to znovu.";
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isSaving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
subscription?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Web_Jarmark.Data;
|
using Web_Jarmark.Data;
|
||||||
@@ -5,35 +6,41 @@ using Web_Jarmark.Data.Models;
|
|||||||
|
|
||||||
namespace Web_Jarmark.Data
|
namespace Web_Jarmark.Data
|
||||||
{
|
{
|
||||||
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
|
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||||
|
: IdentityDbContext<ApplicationUser>(options)
|
||||||
{
|
{
|
||||||
public DbSet<Category> Categories { get; set; }
|
public DbSet<Category> Categories { get; set; }
|
||||||
public DbSet<Product> Products { get; set; }
|
public DbSet<Product> Products { get; set; }
|
||||||
public DbSet<Cart> Carts { get; set; }
|
public DbSet<Cart> Carts { get; set; }
|
||||||
public DbSet<CartItem> CartItems { get; set; }
|
public DbSet<CartItem> CartItems { get; set; }
|
||||||
|
|
||||||
|
// Objednávky
|
||||||
|
public DbSet<Order> Orders { get; set; }
|
||||||
|
public DbSet<OrderItem> OrderItems { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
// Nastavení vazby 1:N mezi Category a Product
|
// Kategorie a produkty
|
||||||
modelBuilder.Entity<Category>()
|
modelBuilder.Entity<Category>()
|
||||||
.HasMany(c => c.Products) // Jedna kategorie obsahuje mnoho produktů
|
.HasMany(c => c.Products)
|
||||||
.WithOne(p => p.Category) // Každý produkt patří ke jedné kategorii
|
.WithOne(p => p.Category)
|
||||||
.HasForeignKey(p => p.CategoryId); // Cizí klíč v tabulce Product
|
.HasForeignKey(p => p.CategoryId);
|
||||||
|
|
||||||
// Jeden košík obsahuje více položek
|
// Košík a položky košíku
|
||||||
modelBuilder.Entity<Cart>()
|
modelBuilder.Entity<Cart>()
|
||||||
.HasMany(c => c.CartItems)
|
.HasMany(c => c.CartItems)
|
||||||
.WithOne(ci => ci.Cart)
|
.WithOne(ci => ci.Cart)
|
||||||
.HasForeignKey(ci => ci.CartId);
|
.HasForeignKey(ci => ci.CartId);
|
||||||
|
|
||||||
// Každá položka odkazuje na jeden produkt
|
// Položka košíku odkazuje na produkt
|
||||||
modelBuilder.Entity<CartItem>()
|
modelBuilder.Entity<CartItem>()
|
||||||
.HasOne(ci => ci.Product)
|
.HasOne(ci => ci.Product)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(ci => ci.ProductId);
|
.HasForeignKey(ci => ci.ProductId);
|
||||||
|
|
||||||
// Jeden produkt může být v košíku pouze jednou
|
// Produkt může být v košíku pouze jednou
|
||||||
modelBuilder.Entity<CartItem>()
|
modelBuilder.Entity<CartItem>()
|
||||||
.HasIndex(ci => new { ci.CartId, ci.ProductId })
|
.HasIndex(ci => new { ci.CartId, ci.ProductId })
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
@@ -42,7 +49,19 @@ namespace Web_Jarmark.Data
|
|||||||
modelBuilder.Entity<Cart>()
|
modelBuilder.Entity<Cart>()
|
||||||
.HasIndex(c => c.Token)
|
.HasIndex(c => c.Token)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
|
// Objednávka a její položky
|
||||||
|
modelBuilder.Entity<Order>()
|
||||||
|
.HasMany(o => o.OrderItems)
|
||||||
|
.WithOne(oi => oi.Order)
|
||||||
|
.HasForeignKey(oi => oi.OrderId);
|
||||||
|
|
||||||
|
// Položka objednávky odkazuje na produkt
|
||||||
|
modelBuilder.Entity<OrderItem>()
|
||||||
|
.HasOne(oi => oi.Product)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(oi => oi.ProductId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
Delivered,
|
Delivered,
|
||||||
Cancelled
|
Cancelled
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PaymentMethod
|
public enum PaymentMethod
|
||||||
{
|
{
|
||||||
CreditCard,
|
CreditCard,
|
||||||
@@ -19,23 +20,21 @@
|
|||||||
public class Order
|
public class Order
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Code { get; set; }
|
|
||||||
public OrderStatus Status { get; set; }
|
|
||||||
public string CustomerName { get; set; }
|
|
||||||
public string Email { get; set; }
|
|
||||||
public string Phone { get; set; }
|
|
||||||
public string Note { get; set; }
|
|
||||||
public PaymentMethod PreferredPayment { get; set; }
|
|
||||||
public string PaymentReference { get; set; }
|
|
||||||
public decimal TotalAmount { get; set; }
|
|
||||||
public DateTime CreatedAt { get; set; }
|
|
||||||
public DateTime? ExpiresAt { get; set; }
|
|
||||||
public DateTime? PaidAt { get; set; }
|
|
||||||
public DateTime? IssuedAt { get; set; }
|
|
||||||
public string IssuedByUserId { get; set; }
|
|
||||||
public DateTime? CancelledAt { get; set; }
|
|
||||||
|
|
||||||
// Navigační vlastnost pro objednávací položky
|
public string Code { get; set; } = Guid.NewGuid().ToString("N")[..8].ToUpper();
|
||||||
|
|
||||||
|
public OrderStatus Status { get; set; } = OrderStatus.Pending;
|
||||||
|
|
||||||
|
public PaymentMethod PreferredPayment { get; set; }
|
||||||
|
|
||||||
|
public string? PaymentReference { get; set; }
|
||||||
|
|
||||||
|
public decimal TotalAmount { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
public DateTime? PaidAt { get; set; }
|
||||||
|
|
||||||
public ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
|
public ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3061,3 +3061,58 @@ textarea.wj-input {
|
|||||||
background: #f0f0f2;
|
background: #f0f0f2;
|
||||||
color: #6e6e73;
|
color: #6e6e73;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ovládání množství v košíku */
|
||||||
|
.cart-quantity-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-quantity-controls strong {
|
||||||
|
min-width: 22px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-quantity-controls button {
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #222;
|
||||||
|
color: white;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-quantity-controls button:hover:not(:disabled) {
|
||||||
|
background: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-quantity-controls button:disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Odstranìní produktu */
|
||||||
|
.cart-remove-button {
|
||||||
|
display: block;
|
||||||
|
margin-top: 12px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #dc3545;
|
||||||
|
color: white;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-remove-button:hover {
|
||||||
|
background: #b02a37;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user