From 0d3bd525813d7e8184d79d9f5faaf1fef2f13ff7 Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Wed, 20 May 2026 21:18:41 +0200 Subject: [PATCH] Moved CreateProductModel to shared Features library --- ShopAdmin/Components/CreateProduct.razor.cs | 40 +-------------------- ShopAdmin/ShopAdmin.csproj | 2 +- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/ShopAdmin/Components/CreateProduct.razor.cs b/ShopAdmin/Components/CreateProduct.razor.cs index 8f75892..87cbfa6 100644 --- a/ShopAdmin/Components/CreateProduct.razor.cs +++ b/ShopAdmin/Components/CreateProduct.razor.cs @@ -1,4 +1,5 @@ using LiteCharms.Features.S3.Abstractions; +using LiteCharms.Features.Shop.Products.Models; using static LiteCharms.Features.S3.Constants; namespace ShopAdmin.Components; @@ -184,43 +185,4 @@ public partial class CreateProduct([FromKeyedServices(BookshopBucketName)] IS3Se isCalendarOpen = false; // Collapse popup smoothly on successful selection StateHasChanged(); } -} - -public class CreateProductModel -{ - [MaxLength(128)] - [Required(ErrorMessage = "Product name is required.")] - public string? Name { get; set; } - - [MaxLength(512)] - [Required(ErrorMessage = "Summary is required.")] - public string? Summary { get; set; } - - [MaxLength(2048)] - [Required(ErrorMessage = "Description is required.")] - public string? Description { get; set; } - - [Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than zero.")] - public decimal Price { get; set; } - - [MaxLength(128)] - [Required(ErrorMessage = "Author metadata is required.")] - public string? Author { get; set; } - - [Required(ErrorMessage = "Publication Date is required.")] - public DateTime PublishDate { get; set; } = DateTime.Today; - - [MaxLength(255)] - [Required(ErrorMessage = "Copyright Information field is required.")] - public string? CopyrightInfo { get; set; } - - [MaxLength(128)] - [Required(ErrorMessage = "ISBN code is required.")] - [RegularExpression(@"^(?=(?:\D*\d){10}(?:(?:\D*\d){3})?$)[\d-]+$", ErrorMessage = "Please enter a valid ISBN-10 or ISBN-13 string.")] - public string? Isbn { get; set; } - - [Required(ErrorMessage = "Primary image is required.")] - public string? ImageUrl { get; set; } - - public List Thumbnails { get; set; } = []; } \ No newline at end of file diff --git a/ShopAdmin/ShopAdmin.csproj b/ShopAdmin/ShopAdmin.csproj index 7ec4ff7..dadf1c8 100644 --- a/ShopAdmin/ShopAdmin.csproj +++ b/ShopAdmin/ShopAdmin.csproj @@ -16,7 +16,7 @@ - +