29 lines
1.3 KiB
C#
29 lines
1.3 KiB
C#
using SmallSoftwareContracts.Exceptions;
|
|
using SmallSoftwareContracts.Extensions;
|
|
using SmallSoftwareContracts.Infrastructure;
|
|
|
|
namespace SmallSoftwareContracts.DataModels;
|
|
|
|
public class InstallationRequestDataModel(string softwareId, string requestId, int count, double price) : IValidation
|
|
{
|
|
public string SoftwareId { get; private set; } = softwareId;
|
|
public string RequestId { get; private set; } = requestId;
|
|
public int Count { get; private set; } = count;
|
|
public double Price { get; private set; } = price;
|
|
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 (RequestId.IsEmpty())
|
|
throw new ValidationException("Field RequestId is empty");
|
|
if (!RequestId.IsGuid())
|
|
throw new ValidationException("The value in the field RequestId is not a unique identifier");
|
|
if (Count <= 0)
|
|
throw new ValidationException("Field Count is less than or equal to 0");
|
|
if (Price <= 0)
|
|
throw new ValidationException("Field Price is less than or equal to 0");
|
|
}
|
|
}
|