43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using YAPContracts.Enums;
|
|
using YAPContracts.Exceptions;
|
|
using YAPContracts.Extentions;
|
|
using YAPContracts.Infrastructure;
|
|
|
|
namespace YAPContracts.DataModels;
|
|
|
|
public class ComponentDataModel(string id, string name, ComponentType componentType, bool IsDeleted) : IValidation
|
|
{
|
|
public string Id { get; private set; } = id;
|
|
public string Name { get; private set; } = name;
|
|
public ComponentType ComponentType { get; private set; } = componentType;
|
|
public bool IsDeleted { get; private set; } = IsDeleted;
|
|
|
|
// public List<ComponentInProductDataModel> Products = products;
|
|
// public List<ComponentInProductSetDataModel> ProductSets = productSets;
|
|
|
|
public void Validate()
|
|
{
|
|
if (!Id.IsGuid())
|
|
{
|
|
throw new ValidationException("Id value is not valid");
|
|
}
|
|
if (Id.IsEmpty())
|
|
{
|
|
throw new ValidationException("Id is empty");
|
|
}
|
|
if (Name.IsEmpty())
|
|
{
|
|
throw new ValidationException("Name is empty");
|
|
}
|
|
if (componentType == ComponentType.None)
|
|
{
|
|
throw new ValidationException("Product type is empty");
|
|
}
|
|
}
|
|
}
|