udelani detail objednavek a pokracovat v objednavce
This commit is contained in:
@@ -1,5 +1,410 @@
|
||||
<h3>DetailObjednavky</h3>
|
||||
@page "/objednavka/{Code}"
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using System.Security.Cryptography
|
||||
@using System.Text
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext DbContext
|
||||
|
||||
<PageTitle>Detail objednávky | Školní jarmark</PageTitle>
|
||||
|
||||
<main class="market-shell order-detail-page">
|
||||
|
||||
@if (isLoading)
|
||||
{
|
||||
<div class="order-message">
|
||||
Načítám objednávku...
|
||||
</div>
|
||||
}
|
||||
else if (order == null)
|
||||
{
|
||||
<div class="order-message order-error">
|
||||
<h1>Objednávku se nepodařilo najít</h1>
|
||||
<p>Odkaz může být neplatný nebo již není dostupný.</p>
|
||||
<a href="/" class="order-button">Zpět do katalogu</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="order-success-icon">✓</div>
|
||||
|
||||
<div class="order-heading">
|
||||
<span class="order-eyebrow">ŠKOLNÍ JARMARK</span>
|
||||
<h1>Děkujeme za objednávku!</h1>
|
||||
<p>Tvoje objednávka byla úspěšně přijata.</p>
|
||||
</div>
|
||||
|
||||
<section class="order-card">
|
||||
<div class="order-card-header">
|
||||
<div>
|
||||
<span class="order-muted">Číslo objednávky</span>
|
||||
<h2>#@order.Code</h2>
|
||||
</div>
|
||||
|
||||
<span class="order-status">
|
||||
@GetStatusText(order.Status)
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="order-info-grid">
|
||||
<div>
|
||||
<span class="order-muted">Datum vytvoření</span>
|
||||
<strong>@order.CreatedAt.ToLocalTime().ToString("d. M. yyyy HH:mm")</strong>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="order-muted">Způsob platby</span>
|
||||
<strong>@GetPaymentText(order.PreferredPayment)</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="order-divider"></div>
|
||||
|
||||
<h3>Objednané produkty</h3>
|
||||
|
||||
<div class="order-products">
|
||||
@foreach (var item in order.OrderItems)
|
||||
{
|
||||
<div class="order-product" @key="item.Id">
|
||||
<div>
|
||||
<strong>@item.ProductName</strong>
|
||||
<span>@item.Quantity ks × @item.UnitPrice.ToString("N0") Kč</span>
|
||||
</div>
|
||||
|
||||
<strong>
|
||||
@((item.UnitPrice * item.Quantity).ToString("N0")) Kč
|
||||
</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="order-total">
|
||||
<span>Celkem k zaplacení</span>
|
||||
<strong>@order.TotalAmount.ToString("N0") Kč</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="order-next-step">
|
||||
<h3>Co bude dál?</h3>
|
||||
|
||||
@if (order.PreferredPayment == PaymentMethod.BankTransfer)
|
||||
{
|
||||
<p>
|
||||
Zvolil/a sis QR platbu. Platební údaje budou doplněny
|
||||
po nastavení školního bankovního účtu.
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>
|
||||
Zvolil/a sis platbu v hotovosti.
|
||||
Objednávku zaplatíš při osobním převzetí.
|
||||
</p>
|
||||
}
|
||||
|
||||
<p>
|
||||
Číslo objednávky si uschovej, může se hodit při vyzvednutí.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div class="order-actions">
|
||||
<a href="/" class="order-button">
|
||||
Zpět do katalogu
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
|
||||
</main>
|
||||
|
||||
<style>
|
||||
.order-detail-page {
|
||||
max-width: 850px;
|
||||
margin: 0 auto;
|
||||
padding: 55px 20px 70px;
|
||||
}
|
||||
|
||||
.order-heading {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.order-eyebrow {
|
||||
color: #2878ff;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.order-heading h1 {
|
||||
margin: 12px 0 8px;
|
||||
font-size: clamp(27px, 5vw, 38px);
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.order-heading p {
|
||||
opacity: .65;
|
||||
}
|
||||
|
||||
.order-success-icon {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
margin: 0 auto 22px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 50%;
|
||||
background: #e3f8eb;
|
||||
color: #159447;
|
||||
font-size: 38px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.order-card,
|
||||
.order-next-step,
|
||||
.order-message {
|
||||
padding: 26px;
|
||||
border: 1px solid rgba(128,128,128,.2);
|
||||
border-radius: 18px;
|
||||
background: var(--bs-body-bg, #fff);
|
||||
color: var(--bs-body-color, #222);
|
||||
box-shadow: 0 5px 22px rgba(0,0,0,.045);
|
||||
}
|
||||
|
||||
.order-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.order-card-header h2 {
|
||||
margin: 5px 0 0;
|
||||
font-size: 25px;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.order-muted {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-size: 13px;
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
padding: 8px 13px;
|
||||
border-radius: 20px;
|
||||
background: #fff3d6;
|
||||
color: #996500;
|
||||
font-size: 13px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.order-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.order-info-grid strong {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.order-divider {
|
||||
height: 1px;
|
||||
margin: 25px 0;
|
||||
background: rgba(128,128,128,.2);
|
||||
}
|
||||
|
||||
.order-card h3,
|
||||
.order-next-step h3 {
|
||||
margin: 0 0 15px;
|
||||
font-size: 19px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.order-products {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.order-product {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
padding: 16px 0;
|
||||
border-top: 1px solid rgba(128,128,128,.15);
|
||||
}
|
||||
|
||||
.order-product div {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.order-product span {
|
||||
font-size: 13px;
|
||||
opacity: .65;
|
||||
}
|
||||
|
||||
.order-product > strong {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-total {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
margin-top: 15px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid rgba(128,128,128,.2);
|
||||
}
|
||||
|
||||
.order-total strong {
|
||||
font-size: 25px;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.order-next-step {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.order-next-step p {
|
||||
line-height: 1.6;
|
||||
opacity: .75;
|
||||
}
|
||||
|
||||
.order-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
.order-button {
|
||||
display: inline-block;
|
||||
padding: 14px 24px;
|
||||
border-radius: 12px;
|
||||
background: #2878ff;
|
||||
color: white;
|
||||
font-weight: 750;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-message {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-error {
|
||||
color: #c33;
|
||||
}
|
||||
|
||||
@@media (max-width: 550px) {
|
||||
.order-card,
|
||||
.order-next-step {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.order-info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.order-card-header {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.order-total {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? Code { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "token")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
private Order? order;
|
||||
private bool isLoading = true;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
order = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Code) ||
|
||||
string.IsNullOrWhiteSpace(Token))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var foundOrder = await DbContext.Orders
|
||||
.AsNoTracking()
|
||||
.Include(o => o.OrderItems)
|
||||
.FirstOrDefaultAsync(o => o.Code == Code);
|
||||
|
||||
if (foundOrder == null ||
|
||||
string.IsNullOrWhiteSpace(foundOrder.AccessTokenHash))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var suppliedHash = Convert.ToHexString(
|
||||
SHA256.HashData(
|
||||
Encoding.UTF8.GetBytes(Token)));
|
||||
|
||||
var expectedBytes = Encoding.UTF8.GetBytes(
|
||||
foundOrder.AccessTokenHash);
|
||||
|
||||
var suppliedBytes = Encoding.UTF8.GetBytes(suppliedHash);
|
||||
|
||||
if (expectedBytes.Length != suppliedBytes.Length ||
|
||||
!CryptographicOperations.FixedTimeEquals(
|
||||
expectedBytes, suppliedBytes))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
order = foundOrder;
|
||||
}
|
||||
catch
|
||||
{
|
||||
order = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetStatusText(OrderStatus status)
|
||||
{
|
||||
return status switch
|
||||
{
|
||||
OrderStatus.Pending => "Čeká na zaplacení",
|
||||
OrderStatus.Paid => "Zaplaceno",
|
||||
OrderStatus.Shipped => "Odesláno",
|
||||
OrderStatus.Delivered => "Dokončeno",
|
||||
OrderStatus.Cancelled => "Zrušeno",
|
||||
_ => "Neznámý stav"
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetPaymentText(PaymentMethod method)
|
||||
{
|
||||
return method switch
|
||||
{
|
||||
PaymentMethod.BankTransfer => "QR platba",
|
||||
PaymentMethod.Cash => "Hotově na místě",
|
||||
PaymentMethod.CreditCard => "Platební karta",
|
||||
PaymentMethod.PayPal => "PayPal",
|
||||
_ => "Neznámý způsob"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@page "/kosik"
|
||||
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Web_Jarmark.Data.Models
|
||||
@using Web_Jarmark.Data
|
||||
@@ -139,9 +138,10 @@
|
||||
<strong>@totalPrice.ToString("N0") Kč</strong>
|
||||
</div>
|
||||
|
||||
<button class="cart-primary-button" disabled>
|
||||
<a href="/nova-objednavka"
|
||||
class="cart-primary-button">
|
||||
Pokračovat k objednávce
|
||||
</button>
|
||||
</a>
|
||||
|
||||
<p class="cart-summary-note">
|
||||
Objednávku dokončíš v dalším kroku.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@using System.Security.Cryptography
|
||||
@using System.Text
|
||||
@inject ApplicationDbContext DbContext
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject PersistentComponentState ApplicationState
|
||||
@@ -10,72 +12,407 @@
|
||||
|
||||
<PageTitle>Dokončení objednávky | Školní jarmark</PageTitle>
|
||||
|
||||
<main class="market-shell">
|
||||
<main class="market-shell checkout-page">
|
||||
<div class="checkout-heading">
|
||||
<a href="/kosik" class="checkout-back">← Zpět do košíku</a>
|
||||
<h1>Dokončení objednávky</h1>
|
||||
<p>Už jen poslední krok a tvoje objednávka bude hotová.</p>
|
||||
</div>
|
||||
|
||||
@if (isLoading)
|
||||
{
|
||||
<p>Načítám objednávku...</p>
|
||||
<div class="checkout-message">
|
||||
Načítám obsah košíku...
|
||||
</div>
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(errorMessage))
|
||||
{
|
||||
<p>@errorMessage</p>
|
||||
<div class="checkout-message checkout-error">
|
||||
@errorMessage
|
||||
<a href="/kosik">Zpět do košíku</a>
|
||||
</div>
|
||||
}
|
||||
else if (cartItems.Count == 0)
|
||||
{
|
||||
<p>Košík je prázdný.</p>
|
||||
<a href="/">Zpět do katalogu</a>
|
||||
<div class="checkout-message">
|
||||
<h2>Tvůj košík je prázdný</h2>
|
||||
<p>Nejdříve si vyber nějaké produkty v katalogu.</p>
|
||||
<a href="/" class="cart-primary-button">Přejít do katalogu</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section>
|
||||
<h2>Vybrané produkty</h2>
|
||||
<div class="checkout-layout">
|
||||
<section class="checkout-main">
|
||||
<div class="checkout-card">
|
||||
<div class="checkout-card-heading">
|
||||
<span class="checkout-step">1</span>
|
||||
<div>
|
||||
<h2>Souhrn objednávky</h2>
|
||||
<p>Zkontroluj vybrané produkty.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkout-products">
|
||||
@foreach (var item in cartItems)
|
||||
{
|
||||
<p>
|
||||
@item.Product.Name – @item.Quantity ks –
|
||||
<div class="checkout-product" @key="item.Id">
|
||||
<div class="checkout-product-info">
|
||||
<strong>@item.Product.Name</strong>
|
||||
<span>@item.Quantity ks × @item.Product.Price.ToString("N0") Kč</span>
|
||||
</div>
|
||||
<strong class="checkout-product-price">
|
||||
@((item.Product.Price * item.Quantity).ToString("N0")) Kč
|
||||
</p>
|
||||
</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Celkem: @totalPrice.ToString("N0") Kč</h3>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div class="checkout-card">
|
||||
<div class="checkout-card-heading">
|
||||
<span class="checkout-step">2</span>
|
||||
<div>
|
||||
<h2>Způsob platby</h2>
|
||||
<p>Vyber, jak chceš za objednávku zaplatit.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<div class="payment-options">
|
||||
<label class="payment-option @(selectedPayment == PaymentMethod.BankTransfer ? "selected" : "")">
|
||||
<input type="radio"
|
||||
name="payment"
|
||||
checked="@(selectedPayment == PaymentMethod.BankTransfer)"
|
||||
@onchange="@(() => selectedPayment = PaymentMethod.BankTransfer)" />
|
||||
QR platba
|
||||
<span class="payment-icon">▦</span>
|
||||
<span class="payment-text">
|
||||
<strong>QR platba</strong>
|
||||
<small>Zaplatíš jednoduše pomocí QR kódu.</small>
|
||||
</span>
|
||||
<span class="payment-check"></span>
|
||||
</label>
|
||||
|
||||
<br />
|
||||
|
||||
<label>
|
||||
<label class="payment-option @(selectedPayment == PaymentMethod.Cash ? "selected" : "")">
|
||||
<input type="radio"
|
||||
name="payment"
|
||||
checked="@(selectedPayment == PaymentMethod.Cash)"
|
||||
@onchange="@(() => selectedPayment = PaymentMethod.Cash)" />
|
||||
Hotově na místě
|
||||
<span class="payment-icon">Kč</span>
|
||||
<span class="payment-text">
|
||||
<strong>Hotově na místě</strong>
|
||||
<small>Zaplatíš při osobním převzetí.</small>
|
||||
</span>
|
||||
<span class="payment-check"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@if (selectedPayment == PaymentMethod.BankTransfer)
|
||||
{
|
||||
<p class="payment-note">
|
||||
QR platba bude připravena po nastavení skutečného čísla účtu.
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<button class="cart-primary-button"
|
||||
<aside class="checkout-summary">
|
||||
<h2>Celkem k zaplacení</h2>
|
||||
|
||||
<div class="summary-line">
|
||||
<span>Počet položek</span>
|
||||
<strong>@cartItems.Sum(item => item.Quantity)</strong>
|
||||
</div>
|
||||
|
||||
<div class="summary-line">
|
||||
<span>Způsob platby</span>
|
||||
<strong>@(selectedPayment == PaymentMethod.BankTransfer ? "QR platba" : "Hotově")</strong>
|
||||
</div>
|
||||
|
||||
<div class="summary-total">
|
||||
<span>Celková cena</span>
|
||||
<strong>@totalPrice.ToString("N0") Kč</strong>
|
||||
</div>
|
||||
|
||||
<button class="cart-primary-button checkout-submit"
|
||||
@onclick="CreateOrder"
|
||||
disabled="@isSaving">
|
||||
@(isSaving ? "Vytvářím objednávku..." : "Potvrdit objednávku")
|
||||
@(isSaving ? "Vytvářím objednávku..." : "Potvrdit objednávku →")
|
||||
</button>
|
||||
|
||||
<p>@saveError</p>
|
||||
<p><a href="/kosik">Zpět do košíku</a></p>
|
||||
@if (!string.IsNullOrWhiteSpace(saveError))
|
||||
{
|
||||
<p class="checkout-error-text">@saveError</p>
|
||||
}
|
||||
|
||||
<p class="checkout-secure">
|
||||
✓ Objednávka bude uložena do systému.
|
||||
</p>
|
||||
</aside>
|
||||
</div>
|
||||
}
|
||||
</main>
|
||||
|
||||
<style>
|
||||
.checkout-page {
|
||||
padding-top: 35px;
|
||||
padding-bottom: 60px;
|
||||
}
|
||||
|
||||
.checkout-heading {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.checkout-back {
|
||||
display: inline-block;
|
||||
margin-bottom: 18px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.checkout-heading h1 {
|
||||
margin: 0 0 8px;
|
||||
font-size: clamp(28px, 4vw, 38px);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.checkout-heading p,
|
||||
.checkout-card-heading p {
|
||||
margin: 0;
|
||||
opacity: .65;
|
||||
}
|
||||
|
||||
.checkout-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 340px;
|
||||
gap: 24px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.checkout-main {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.checkout-card,
|
||||
.checkout-summary,
|
||||
.checkout-message {
|
||||
background: var(--bs-body-bg, #fff);
|
||||
color: var(--bs-body-color, #222);
|
||||
border: 1px solid rgba(128,128,128,.2);
|
||||
border-radius: 18px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 5px 22px rgba(0,0,0,.045);
|
||||
}
|
||||
|
||||
.checkout-card-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.checkout-card-heading h2,
|
||||
.checkout-summary h2 {
|
||||
margin: 0 0 5px;
|
||||
font-size: 20px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.checkout-step {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
border-radius: 12px;
|
||||
background: rgba(40,120,255,.12);
|
||||
color: #2878ff;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.checkout-products {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.checkout-product {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
padding: 17px 0;
|
||||
border-top: 1px solid rgba(128,128,128,.17);
|
||||
}
|
||||
|
||||
.checkout-product-info {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.checkout-product-info span {
|
||||
font-size: 14px;
|
||||
opacity: .65;
|
||||
}
|
||||
|
||||
.checkout-product-price {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.payment-options {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.payment-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 17px;
|
||||
border: 1px solid rgba(128,128,128,.25);
|
||||
border-radius: 14px;
|
||||
cursor: pointer;
|
||||
transition: border-color .2s, background .2s;
|
||||
}
|
||||
|
||||
.payment-option.selected {
|
||||
border: 2px solid #2878ff;
|
||||
background: rgba(40,120,255,.055);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.payment-option input {
|
||||
accent-color: #2878ff;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
.payment-icon {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 12px;
|
||||
background: rgba(128,128,128,.12);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.payment-text {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.payment-text small {
|
||||
opacity: .65;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.payment-check {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.payment-option.selected .payment-check {
|
||||
background: #2878ff;
|
||||
}
|
||||
|
||||
.payment-note {
|
||||
margin: 15px 0 0;
|
||||
font-size: 13px;
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.checkout-summary {
|
||||
position: sticky;
|
||||
top: 20px;
|
||||
}
|
||||
|
||||
.checkout-summary h2 {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.summary-line,
|
||||
.summary-total {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.summary-line span {
|
||||
opacity: .65;
|
||||
}
|
||||
|
||||
.summary-total {
|
||||
border-top: 1px solid rgba(128,128,128,.2);
|
||||
padding-top: 20px;
|
||||
margin-top: 22px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-total strong {
|
||||
font-size: 24px;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.checkout-submit {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkout-submit:disabled {
|
||||
opacity: .6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.checkout-secure {
|
||||
margin: 15px 0 0;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.checkout-message {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.checkout-error,
|
||||
.checkout-error-text {
|
||||
color: #d33;
|
||||
}
|
||||
|
||||
.checkout-error-text {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@@media (max-width: 800px) {
|
||||
.checkout-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.checkout-summary {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
|
||||
@@media (max-width: 480px) {
|
||||
.checkout-card,
|
||||
.checkout-summary {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.checkout-product {
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
private string? cartToken;
|
||||
private List<CartItem> cartItems = new();
|
||||
@@ -160,13 +497,26 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Vygenerování náhodného přístupového tokenu
|
||||
var tokenBytes = RandomNumberGenerator.GetBytes(32);
|
||||
var accessToken = Convert.ToBase64String(tokenBytes)
|
||||
.Replace("+", "-")
|
||||
.Replace("/", "_")
|
||||
.TrimEnd('=');
|
||||
|
||||
// Uložíme pouze hash tokenu
|
||||
var tokenHash = Convert.ToHexString(
|
||||
SHA256.HashData(
|
||||
Encoding.UTF8.GetBytes(accessToken)));
|
||||
|
||||
var order = new Order
|
||||
{
|
||||
PreferredPayment = selectedPayment,
|
||||
Status = OrderStatus.Pending,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
TotalAmount = cart.CartItems.Sum(
|
||||
item => item.Product.Price * item.Quantity)
|
||||
item => item.Product.Price * item.Quantity),
|
||||
AccessTokenHash = tokenHash
|
||||
};
|
||||
|
||||
foreach (var item in cart.CartItems)
|
||||
@@ -183,12 +533,14 @@
|
||||
}
|
||||
|
||||
DbContext.Orders.Add(order);
|
||||
|
||||
DbContext.CartItems.RemoveRange(cart.CartItems);
|
||||
|
||||
await DbContext.SaveChangesAsync();
|
||||
|
||||
Navigation.NavigateTo($"/objednavka/{order.Id}");
|
||||
var orderUrl =
|
||||
$"/objednavka/{order.Code}?token={Uri.EscapeDataString(accessToken)}";
|
||||
|
||||
Navigation.NavigateTo(orderUrl);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Web_Jarmark.Data;
|
||||
using Web_Jarmark.Data.Models;
|
||||
|
||||
namespace Web_Jarmark.Data
|
||||
@@ -50,6 +49,13 @@ namespace Web_Jarmark.Data
|
||||
.HasIndex(c => c.Token)
|
||||
.IsUnique();
|
||||
|
||||
// Zachování původních názvů tabulek objednávek
|
||||
modelBuilder.Entity<Order>()
|
||||
.ToTable("Order");
|
||||
|
||||
modelBuilder.Entity<OrderItem>()
|
||||
.ToTable("OrderItem");
|
||||
|
||||
// Objednávka a její položky
|
||||
modelBuilder.Entity<Order>()
|
||||
.HasMany(o => o.OrderItems)
|
||||
@@ -59,9 +65,8 @@ namespace Web_Jarmark.Data
|
||||
// Položka objednávky odkazuje na produkt
|
||||
modelBuilder.Entity<OrderItem>()
|
||||
.HasOne(oi => oi.Product)
|
||||
.WithMany()
|
||||
.WithMany(p => p.OrderItems)
|
||||
.HasForeignKey(oi => oi.ProductId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Web_Jarmark.Data.Models
|
||||
|
||||
namespace Web_Jarmark.Data.Models
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
@@ -21,20 +22,35 @@
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Code { get; set; } = Guid.NewGuid().ToString("N")[..8].ToUpper();
|
||||
public string Code { get; set; } =
|
||||
Guid.NewGuid().ToString("N")[..8].ToUpper();
|
||||
|
||||
// Bezpečný přístup k detailu objednávky
|
||||
public string AccessTokenHash { get; set; } = string.Empty;
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Pending;
|
||||
|
||||
// Původní údaje zachované kvůli databázi
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Note { get; set; } = string.Empty;
|
||||
|
||||
public PaymentMethod PreferredPayment { get; set; }
|
||||
|
||||
public string? PaymentReference { get; set; }
|
||||
public string PaymentReference { get; set; } = string.Empty;
|
||||
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
public DateTime? PaidAt { get; set; }
|
||||
public DateTime? IssuedAt { get; set; }
|
||||
public string IssuedByUserId { get; set; } = string.Empty;
|
||||
public DateTime? CancelledAt { get; set; }
|
||||
|
||||
public ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
|
||||
public ICollection<OrderItem> OrderItems { get; set; }
|
||||
= new List<OrderItem>();
|
||||
}
|
||||
}
|
||||
628
Web-Jarmark/Web-Jarmark/Migrations/20261106180726_AddOrderAccessTokenHash.Designer.cs
generated
Normal file
628
Web-Jarmark/Web-Jarmark/Migrations/20261106180726_AddOrderAccessTokenHash.Designer.cs
generated
Normal file
@@ -0,0 +1,628 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Web_Jarmark.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20261106180726_AddOrderAccessTokenHash")]
|
||||
partial class AddOrderAccessTokenHash
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.13");
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.Property<byte[]>("CredentialId")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CredentialId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserPasskeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Token")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Carts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CartId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("CartId", "ProductId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AccessTokenHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CustomerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("ExpiresAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("IssuedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IssuedByUserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("PaidAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PaymentReference")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("PreferredPayment")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("TotalAmount")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Order", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("UnitPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderItem", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsVisible")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StockQuantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsOne("Microsoft.AspNetCore.Identity.IdentityPasskeyData", "Data", b1 =>
|
||||
{
|
||||
b1.Property<byte[]>("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.Property<byte[]>("AttestationObject")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<byte[]>("ClientDataJson")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<DateTimeOffset>("CreatedAt");
|
||||
|
||||
b1.Property<bool>("IsBackedUp");
|
||||
|
||||
b1.Property<bool>("IsBackupEligible");
|
||||
|
||||
b1.Property<bool>("IsUserVerified");
|
||||
|
||||
b1.Property<string>("Name");
|
||||
|
||||
b1.Property<byte[]>("PublicKey")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<uint>("SignCount");
|
||||
|
||||
b1.PrimitiveCollection<string>("Transports");
|
||||
|
||||
b1.HasKey("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.ToTable("AspNetUserPasskeys");
|
||||
|
||||
b1
|
||||
.ToJson("Data")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("IdentityUserPasskeyCredentialId");
|
||||
});
|
||||
|
||||
b.Navigation("Data")
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Cart", "Cart")
|
||||
.WithMany("CartItems")
|
||||
.HasForeignKey("CartId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cart");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Order", "Order")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Category", "Category")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Navigation("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddOrderAccessTokenHash : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AccessTokenHash",
|
||||
table: "Order",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AccessTokenHash",
|
||||
table: "Order");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,6 +317,10 @@ namespace Web_Jarmark.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AccessTokenHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -371,7 +375,7 @@ namespace Web_Jarmark.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Order");
|
||||
b.ToTable("Order", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
@@ -402,7 +406,7 @@ namespace Web_Jarmark.Migrations
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderItem");
|
||||
b.ToTable("OrderItem", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user