diff --git a/src/Basket.API/Model/BasketItem.cs b/src/Basket.API/Model/BasketItem.cs index 55c8a97c2..5af345fa8 100644 --- a/src/Basket.API/Model/BasketItem.cs +++ b/src/Basket.API/Model/BasketItem.cs @@ -16,7 +16,13 @@ public IEnumerable Validate(ValidationContext validationContex if (Quantity < 1) { - results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" })); + results.Add(new ValidationResult("🤌 Numero di unità non valido", new[] { "Quantity" })); + } + + // Validate the URL if it's a valid URL format + if (!string.IsNullOrEmpty(PictureUrl) && !Uri.IsWellFormedUriString(PictureUrl, UriKind.Absolute)) + { + results.Add(new ValidationResult("🤌 Formato URL non valido", new[] { "PictureUrl" })); } return results; diff --git a/src/Basket.API/Model/CustomerBasket.cs b/src/Basket.API/Model/CustomerBasket.cs index 8ec8828bf..32a8cfe34 100644 --- a/src/Basket.API/Model/CustomerBasket.cs +++ b/src/Basket.API/Model/CustomerBasket.cs @@ -1,13 +1,31 @@ namespace eShop.Basket.API.Model; +/// +/// Represents a shopping basket for a specific customer, containing a collection of basket items. +/// public class CustomerBasket { + /// + /// Gets or sets the unique identifier of the buyer associated with this basket. + /// public string BuyerId { get; set; } + /// + /// Gets or sets the list of items in the customer's basket. + /// Initialized as an empty list by default. + /// public List Items { get; set; } = []; + /// + /// Initializes a new instance of the class. + /// public CustomerBasket() { } + /// + /// Initializes a new instance of the class + /// with the specified customer identifier. + /// + /// The unique identifier of the customer. public CustomerBasket(string customerId) { BuyerId = customerId;