Major restructuring of product variations: - Renamed ProductVariation to ProductMultiBuy for quantity-based pricing (e.g., "3 for £25") - Added new ProductVariant model for string-based options (colors, flavors) - Complete separation of multi-buy pricing from variant selection Features implemented: - Multi-buy deals with automatic price-per-unit calculation - Product variants for colors/flavors/sizes with stock tracking - TeleBot checkout supports both multi-buys and variant selection - Shopping cart correctly calculates multi-buy bundle prices - Order system tracks selected variants and multi-buy choices - Real-time bot activity monitoring with SignalR - Public bot directory page with QR codes for Telegram launch - Admin dashboard shows multi-buy and variant metrics Technical changes: - Updated all DTOs, services, and controllers - Fixed cart total calculation for multi-buy bundles - Comprehensive test coverage for new functionality - All existing tests passing with new features Database changes: - Migrated ProductVariations to ProductMultiBuys - Added ProductVariants table - Updated OrderItems to track variants 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
199 lines
5.3 KiB
C#
199 lines
5.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using LittleShop.Enums;
|
|
|
|
namespace LittleShop.DTOs;
|
|
|
|
public class ProductDto
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Description { get; set; } = string.Empty;
|
|
public decimal Price { get; set; }
|
|
public decimal Weight { get; set; }
|
|
public ProductWeightUnit WeightUnit { get; set; }
|
|
public int StockQuantity { get; set; }
|
|
public Guid CategoryId { get; set; }
|
|
public string CategoryName { get; set; } = string.Empty;
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
public bool IsActive { get; set; }
|
|
public List<ProductPhotoDto> Photos { get; set; } = new();
|
|
public List<ProductMultiBuyDto> MultiBuys { get; set; } = new();
|
|
public List<ProductVariantDto> Variants { get; set; } = new();
|
|
}
|
|
|
|
public class ProductPhotoDto
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string FileName { get; set; } = string.Empty;
|
|
public string FilePath { get; set; } = string.Empty;
|
|
public string? AltText { get; set; }
|
|
public int SortOrder { get; set; }
|
|
}
|
|
|
|
public class CreateProductDto
|
|
{
|
|
[Required]
|
|
[StringLength(200)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[Required(AllowEmptyStrings = true)]
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
[Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than 0")]
|
|
public decimal Price { get; set; }
|
|
|
|
[Required]
|
|
[Range(0.01, double.MaxValue, ErrorMessage = "Weight must be greater than 0")]
|
|
public decimal Weight { get; set; }
|
|
|
|
public ProductWeightUnit WeightUnit { get; set; } = ProductWeightUnit.Grams;
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int StockQuantity { get; set; } = 0;
|
|
|
|
[Required(ErrorMessage = "Please select a category")]
|
|
public Guid CategoryId { get; set; }
|
|
}
|
|
|
|
public class UpdateProductDto
|
|
{
|
|
[StringLength(200)]
|
|
public string? Name { get; set; }
|
|
|
|
public string? Description { get; set; }
|
|
|
|
[Range(0.01, double.MaxValue)]
|
|
public decimal? Price { get; set; }
|
|
|
|
public decimal? Weight { get; set; }
|
|
|
|
public ProductWeightUnit? WeightUnit { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int? StockQuantity { get; set; }
|
|
|
|
public Guid? CategoryId { get; set; }
|
|
|
|
public bool? IsActive { get; set; }
|
|
}
|
|
|
|
public class CreateProductPhotoDto
|
|
{
|
|
[Required]
|
|
public Guid ProductId { get; set; }
|
|
|
|
[Required]
|
|
public string PhotoUrl { get; set; } = string.Empty;
|
|
|
|
public string? AltText { get; set; }
|
|
|
|
public int DisplayOrder { get; set; }
|
|
}
|
|
|
|
public class ProductMultiBuyDto
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid ProductId { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Description { get; set; } = string.Empty;
|
|
public int Quantity { get; set; }
|
|
public decimal Price { get; set; }
|
|
public decimal PricePerUnit { get; set; }
|
|
public int SortOrder { get; set; }
|
|
public bool IsActive { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class ProductVariantDto
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid ProductId { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string VariantType { get; set; } = "Standard";
|
|
public int SortOrder { get; set; }
|
|
public int StockLevel { get; set; }
|
|
public bool IsActive { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class CreateProductMultiBuyDto
|
|
{
|
|
[Required]
|
|
public Guid ProductId { get; set; }
|
|
|
|
[Required]
|
|
[StringLength(100)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
[Range(1, int.MaxValue, ErrorMessage = "Quantity must be at least 1")]
|
|
public int Quantity { get; set; }
|
|
|
|
[Required]
|
|
[Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than 0")]
|
|
public decimal Price { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int SortOrder { get; set; }
|
|
}
|
|
|
|
public class CreateProductVariantDto
|
|
{
|
|
[Required]
|
|
public Guid ProductId { get; set; }
|
|
|
|
[Required]
|
|
[StringLength(100)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[StringLength(50)]
|
|
public string VariantType { get; set; } = "Standard";
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int SortOrder { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int StockLevel { get; set; } = 0;
|
|
}
|
|
|
|
public class UpdateProductMultiBuyDto
|
|
{
|
|
[StringLength(100)]
|
|
public string? Name { get; set; }
|
|
|
|
public string? Description { get; set; }
|
|
|
|
[Range(1, int.MaxValue)]
|
|
public int? Quantity { get; set; }
|
|
|
|
[Range(0.01, double.MaxValue)]
|
|
public decimal? Price { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int? SortOrder { get; set; }
|
|
|
|
public bool? IsActive { get; set; }
|
|
}
|
|
|
|
public class UpdateProductVariantDto
|
|
{
|
|
[StringLength(100)]
|
|
public string? Name { get; set; }
|
|
|
|
[StringLength(50)]
|
|
public string? VariantType { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int? SortOrder { get; set; }
|
|
|
|
[Range(0, int.MaxValue)]
|
|
public int? StockLevel { get; set; }
|
|
|
|
public bool? IsActive { get; set; }
|
|
} |