2025-02-11 15:25:07 +04:00

27 lines
954 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PuferFishContracts.Infrastructure;
using PuferFishContracts.Extensions;
using PuferFishContracts.Exceptions;
namespace PuferFishContracts.DataModels;
public class PointsDataModel(string buyerId, DateTime pointsDate, double buyerPoints) : IValidation
{
public string BuyerId { get; private set; } = buyerId;
public DateTime PointsDate { get; private set; } = pointsDate;
public double Points { get; private set; } = buyerPoints;
public void Validate()
{
if (BuyerId.IsEmpty())
throw new ValidationException("Field BuyerId is empty");
if (!BuyerId.IsGuid())
throw new ValidationException("The value in the field BuyerId is not a unique identifier");
if (Points <= 0)
throw new ValidationException("Field Points is less than or equal to 0");
}
}