32 lines
949 B
C#
Raw Normal View History

2025-02-09 15:17:40 +04:00
using MagicCarpetContracts.Exceptions;
2025-02-09 12:45:02 +04:00
using MagicCarpetContracts.Extensions;
using MagicCarpetContracts.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MagicCarpetContracts.DataModels;
2025-02-09 15:17:40 +04:00
public class TourHistoryDataModel(string tourId, double oldPrice) : IValidation
2025-02-09 12:45:02 +04:00
{
2025-02-09 15:17:40 +04:00
public string TourId { get; private set; } = tourId;
2025-02-09 12:45:02 +04:00
public double OldPrice { get; private set; } = oldPrice;
public DateTime ChangeDate { get; private set; } = DateTime.UtcNow;
public void Validate()
{
if (TourId.IsEmpty())
throw new ValidationException("Field TourId is empty");
if (!TourId.IsGuid())
throw new ValidationException("The value in the field TourId is not a unique identifier");
if (OldPrice <= 0)
throw new ValidationException("Field OldPrice is less than or equal to 0");
}
}