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