2025-02-12 22:16:56 +04:00

27 lines
839 B
C#

using CandyHouseBase.Exceptions;
using CandyHouseBase.Extensions;
using CandyHouseBase.Infrastructure;
namespace CandyHouseBase.DataModels
{
public class ProductDataModel : IValidation
{
public string Id { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public ProductDataModel(string id, string name, string description)
{
Id = id;
Name = name;
Description = description;
}
public void Validate()
{
if (Id.IsEmpty()) throw new ValidationException("Field Id is empty");
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
if (Name.IsEmpty()) throw new ValidationException("Field Name is empty");
}
}
}