27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using FurnitureAssemblyContracts.Exceptions;
|
|
using FurnitureAssemblyContracts.Extentions;
|
|
using FurnitureAssemblyContracts.Infrastructure;
|
|
|
|
namespace FurnitureAssemblyContracts.DataModels;
|
|
|
|
public class ComponentWarehouseDataModel(string warehouseId, string componentId, int count) : IValidation
|
|
{
|
|
public string WarehouseId { get; private set; } = warehouseId;
|
|
public string ComponentId { get; private set; } = componentId;
|
|
public int Count { get; private set; } = count;
|
|
|
|
public void Validate()
|
|
{
|
|
if (WarehouseId.IsEmpty())
|
|
throw new ValidationException("Field WarehouseId is empty");
|
|
if (!WarehouseId.IsGuid())
|
|
throw new ValidationException("The value in the field WarehouseId is not a unique identifier");
|
|
if (ComponentId.IsEmpty())
|
|
throw new ValidationException("Field ComponentId is empty");
|
|
if (!ComponentId.IsGuid())
|
|
throw new ValidationException("The value in the field ComponentId is not a unique identifier");
|
|
if (Count <= 0)
|
|
throw new ValidationException("Field Count is less than or equal to 0");
|
|
}
|
|
}
|