Product-enhancements-and-validation-fixes
This commit is contained in:
@@ -11,6 +11,7 @@ public class ProductDto
|
||||
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; }
|
||||
@@ -34,17 +35,23 @@ public class CreateProductDto
|
||||
[StringLength(200)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[Required(AllowEmptyStrings = true)]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[Range(0.01, double.MaxValue)]
|
||||
[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; }
|
||||
public ProductWeightUnit WeightUnit { get; set; } = ProductWeightUnit.Grams;
|
||||
|
||||
[Required]
|
||||
[Range(0, int.MaxValue)]
|
||||
public int StockQuantity { get; set; } = 0;
|
||||
|
||||
[Required(ErrorMessage = "Please select a category")]
|
||||
public Guid CategoryId { get; set; }
|
||||
}
|
||||
|
||||
@@ -62,6 +69,9 @@ public class UpdateProductDto
|
||||
|
||||
public ProductWeightUnit? WeightUnit { get; set; }
|
||||
|
||||
[Range(0, int.MaxValue)]
|
||||
public int? StockQuantity { get; set; }
|
||||
|
||||
public Guid? CategoryId { get; set; }
|
||||
|
||||
public bool? IsActive { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user