39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using MagicCarpetContracts.Enums;
|
|
using MagicCarpetContracts.Exceptions;
|
|
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");
|
|
}
|
|
}
|