littleshop/LittleShop.Client/Models/Order.cs
SysAdmin d9efababa6 Feature: Add product variant price override support
Enables individual variants to have their own prices, overriding the base product price.

**Database Changes:**
- Added Price (decimal?, nullable) to ProductVariants table
- Added ProductVariantId to OrderItems table with foreign key relationship
- Created index on OrderItems.ProductVariantId for performance

**API Changes:**
- ProductVariantDto: Added Price field
- CreateProductVariantDto: Added Price field with validation
- UpdateProductVariantDto: Added Price field
- OrderItemDto: Added ProductVariantId and ProductVariantName
- CreateOrderItemDto: Added ProductVariantId

**Business Logic:**
- OrderService: Variant price overrides base price (but multi-buy takes precedence)
- ProductService: All variant CRUD operations support Price field

**Admin UI:**
- CreateVariant: Price input with £ symbol and base price placeholder
- EditVariant: Price editing with £ symbol
- ProductVariants list: Shows variant price or "(base)" indicator

**Client Library:**
- Updated all DTOs to match server-side changes
- Full support for variant pricing in order creation

**Migration:**
- EF Core migration: 20251003173458_AddVariantPricing
- Backward compatible: NULL values supported for existing data

**Use Case:**
Products with size/color variants can now have different prices:
- Small T-shirt: £15.00 (variant override)
- Medium T-shirt: £18.00 (uses base price)
- Large T-shirt: £20.00 (variant override)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-03 18:35:43 +01:00

63 lines
2.6 KiB
C#

namespace LittleShop.Client.Models;
public class Order
{
public Guid Id { get; set; }
public Guid? CustomerId { get; set; }
public string? IdentityReference { get; set; }
public int Status { get; set; }
public decimal TotalAmount { get; set; }
public string Currency { get; set; } = string.Empty;
public string ShippingName { get; set; } = string.Empty;
public string ShippingAddress { get; set; } = string.Empty;
public string ShippingCity { get; set; } = string.Empty;
public string ShippingPostCode { get; set; } = string.Empty;
public string ShippingCountry { get; set; } = string.Empty;
public string? Notes { get; set; }
public string? TrackingNumber { get; set; }
public List<OrderItem> Items { get; set; } = new();
public List<CryptoPayment> Payments { get; set; } = new();
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public DateTime? PaidAt { get; set; }
public DateTime? ShippedAt { get; set; }
}
public class OrderItem
{
public Guid Id { get; set; }
public Guid ProductId { get; set; }
public Guid? ProductVariantId { get; set; }
public string? ProductName { get; set; }
public string? ProductVariantName { get; set; }
public int Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal TotalPrice { get; set; }
}
public class CreateOrderRequest
{
// Either Customer ID (for registered customers) OR Identity Reference (for anonymous)
public Guid? CustomerId { get; set; }
public string? IdentityReference { get; set; }
// Customer Information (collected at checkout for new customers)
public CreateCustomerRequest? CustomerInfo { get; set; }
public string ShippingName { get; set; } = string.Empty;
public string ShippingAddress { get; set; } = string.Empty;
public string ShippingCity { get; set; } = string.Empty;
public string ShippingPostCode { get; set; } = string.Empty;
public string ShippingCountry { get; set; } = "United Kingdom";
public string? Notes { get; set; }
public List<CreateOrderItem> Items { get; set; } = new();
}
public class CreateOrderItem
{
public Guid ProductId { get; set; }
public Guid? ProductMultiBuyId { get; set; } // Optional: if specified, use multi-buy pricing
public Guid? ProductVariantId { get; set; } // Optional: specific variant (used for variant price override)
public string? SelectedVariant { get; set; } // Optional: variant choice (color/flavor) - deprecated, use ProductVariantId
public int Quantity { get; set; }
}