36 lines
1.2 KiB
C#
Raw Normal View History

2025-02-13 12:42:06 +04:00
using TwoFromTheCaseContracts.Enums;
using TwoFromTheCaseContracts.Exceptions;
using TwoFromTheCaseContracts.Extensions;
using TwoFromTheCaseContracts.Infrastructure;
namespace TwoFromTheCaseContracts.DataModels;
2025-02-13 14:18:53 +04:00
public class PremisesDataModel(string id, PremisesType premisesType, string customerId, bool isDeleted) : IValidation
2025-02-13 12:42:06 +04:00
{
public string Id { get; private set; } = id;
public PremisesType PremisesType { get; private set; } = premisesType;
public string CustomerId { get; private set; } = customerId;
public bool IsDeleted { get; private set; } = isDeleted;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Field Id is empty");
if (!Id.IsGuid())
throw new ValidationException("The value in the field Id is not a unique identifier");
if (PremisesType == PremisesType.None)
throw new ValidationException("Field PremisesType is empty");
if (CustomerId.IsEmpty())
throw new ValidationException("Field CustomerId is empty");
if (!CustomerId.IsGuid())
throw new ValidationException("The value in the field CustomerId is not a unique identifier");
}
}