public int Id { get; set; }
[Range(int.MinValue, int.MaxValue)]
public int? CategoryId { get; set; }
public virtual Category Category { get; set; }
[Range(int.MinValue, int.MaxValue)]
public int? BrandId { get; set; }
public virtual Brand Brand { get; set; }
[Range(int.MinValue, int.MaxValue)]
public int? CountryId { get; set; }
public virtual Country Country { get; set; }
[Required]
[StringLength(100, ErrorMessage = StringLengthError, MinimumLength = 2)]
[RegularExpression("[A-zА-яёЁ]{2}", ErrorMessage = NameRegexError)]
public string Name
{
get => _name;
set => _name = value?.Trim();
}
[Required]
[StringLength(1000, ErrorMessage = StringLengthError, MinimumLength = 10)]
[RegularExpression("[A-zА-яёЁ]{10}", ErrorMessage = DescRegexError)]
public string Description
{
get => _description;
set => _description = value?.Trim();
}
/// <summary>
/// Вес в граммах.
/// </summary>
[Range(0, MaxWeightGrams), Required]
public double Weight
{
get => _weight;
set => _weight = value < 0 ? 0 : value;
}
[Range(0, int.MaxValue), Required]
public decimal Price
{
get => _price;
set => _price = value < 0 ? 0 : value;
}
Это модель
Обсуждают сегодня