39 lines
1.4 KiB
C#
Raw Permalink Normal View History

2025-02-09 12:45:02 +04:00
using MagicCarpetContracts.Enums;
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.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MagicCarpetContracts.DataModels;
public class TourDataModel(string id, string tourName, string tourCountry, double price, TourType tourType) : IValidation
{
public string Id { get; private set; } = id;
public string TourName { get; private set; } = tourName;
public string TourCountry { get; private set; } = tourCountry;
public double Price { get; private set; } = price;
public TourType Type { get; private set; } = tourType;
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 (TourName.IsEmpty())
throw new ValidationException("Field TourName is empty");
if (TourCountry.IsEmpty())
throw new ValidationException("Field TourCountry is empty");
if (Price <= 0)
throw new ValidationException("Field Price is less than or equal to 0");
if (Type == TourType.None)
throw new ValidationException("Field Type is empty");
}
}