forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using MagicCarpetContracts.Enums;
|
|
using MagicCarpetContracts.Exceptions;
|
|
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;
|
|
|
|
public class AgencyDataModel(string id, TourType tourType, int count, List<TourAgencyDataModel> tours) : IValidation
|
|
{
|
|
public string Id { get; private set; } = id;
|
|
public TourType Type { get; private set; } = tourType;
|
|
public int Count { get; private set; } = count;
|
|
public List<TourAgencyDataModel> Tours { get; private set; } = tours;
|
|
|
|
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 (Type == TourType.None)
|
|
throw new ValidationException("Field Type is empty");
|
|
if (Count <= 0)
|
|
throw new ValidationException("Field Count is less than or equal to 0");
|
|
if ((Tours?.Count ?? 0) == 0)
|
|
throw new ValidationException("The sale must include tours");
|
|
}
|
|
}
|