32 lines
996 B
C#
32 lines
996 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WingsOfTheWorldContratcs.Exceptions;
|
|
using WingsOfTheWorldContratcs.Exstensions;
|
|
using WingsOfTheWorldContratcs.Infrastructure;
|
|
|
|
namespace WingsOfTheWorldContratcs.DataModels;
|
|
|
|
public class DeliveryHistoryDataModel(string airplaneid, double oldPrice) : IValidation
|
|
{
|
|
public string AirplaneId { get; private set; } = airplaneid;
|
|
|
|
public double OldPrice { get; private set; } = oldPrice;
|
|
|
|
public DateTime ChangeDate { get; private set; } = DateTime.UtcNow;
|
|
|
|
public void Validate()
|
|
{
|
|
if (AirplaneId.IsEmpty())
|
|
throw new ValidationException("Field ProductId is empty");
|
|
|
|
if (!AirplaneId.IsGuid())
|
|
throw new ValidationException("The value in the field ProductId is not a unique identifier");
|
|
|
|
if (OldPrice <= 0)
|
|
throw new ValidationException("Field OldPrice is less than or equal to 0");
|
|
}
|
|
}
|