Files
Pibd-21_Semin_D.A._SmallSof…/SmallSoftwareProject/SmallSoftwareContracts/DataModels/StorageSoftwareDataModel.cs
2025-04-24 11:19:47 +04:00

30 lines
1.2 KiB
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 StorageSoftwareDataModel(string storageId, string softwareId, int count) : IValidation
{
public string StorageId { get; private set; } = storageId;
public string SoftwareId { get; private set; } = softwareId;
public int Count { get; private set; } = count;
public void Validate()
{
if (StorageId.IsEmpty())
throw new ValidationException("Field StorageId is empty");
if (!StorageId.IsGuid())
throw new ValidationException("The value in the field StorageId is not a unique identifier");
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 (Count <= 0)
throw new ValidationException("Field Count is less than or equal to 0");
}
}