From 2e59f4d8ed2e33b297cdd539302ee4411618f254 Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Wed, 20 May 2026 17:47:53 +0200 Subject: [PATCH] Fixed input model attributes --- ShopAdmin/Components/CreateProduct.razor | 1 + ShopAdmin/Components/CreateProduct.razor.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ShopAdmin/Components/CreateProduct.razor b/ShopAdmin/Components/CreateProduct.razor index 227a2f9..ea6b2bd 100644 --- a/ShopAdmin/Components/CreateProduct.razor +++ b/ShopAdmin/Components/CreateProduct.razor @@ -93,6 +93,7 @@
+ @if (string.IsNullOrEmpty(ProductModel.ImageUrl)) { diff --git a/ShopAdmin/Components/CreateProduct.razor.cs b/ShopAdmin/Components/CreateProduct.razor.cs index a8b7565..8f75892 100644 --- a/ShopAdmin/Components/CreateProduct.razor.cs +++ b/ShopAdmin/Components/CreateProduct.razor.cs @@ -8,7 +8,6 @@ public partial class CreateProduct([FromKeyedServices(BookshopBucketName)] IS3Se private bool isCalendarOpen = false; private DateTime calendarViewingMonth = DateTime.Today; private List calendarDays = new(); - private string currentCalendarMonthYearText => calendarViewingMonth.ToString("MMMM yyyy"); private readonly CancellationTokenSource cancellationTokenSource = new(); private CancellationToken cancellationToken; @@ -189,27 +188,33 @@ public partial class CreateProduct([FromKeyedServices(BookshopBucketName)] IS3Se 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; }