2025-02-13 13:07:31 +04:00

41 lines
1.4 KiB
C#

using TwoFromTheCaseContracts.Enums;
using TwoFromTheCaseContracts.Exceptions;
using TwoFromTheCaseContracts.Extensions;
using TwoFromTheCaseContracts.Infrastructure;
namespace TwoFromTheCaseContracts.DataModels;
public class PremisesDataModel(string id, string premisesName, PremisesType premisesType, string customerId, bool isDeleted) : IValidation
{
public string Id { get; private set; } = id;
public string PremisesName { get; private set; } = premisesName;
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 (PremisesName.IsEmpty())
throw new ValidationException("Field PremisesName is empty");
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");
}
}