2025-02-26 14:36:59 +03:00

37 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WingsOfTheWorldContratcs.Enums;
using WingsOfTheWorldContratcs.Exceptions;
using WingsOfTheWorldContratcs.Exstensions;
using WingsOfTheWorldContratcs.Infrastructure;
namespace WingsOfTheWorldContratcs.DataModels;
public class AccessoriesDataModel(string id, string name, AccessoriesType accessoriesType) : IValidation
{
public string Id { get; private set; } = id;
public string Name { get; private set; } = name;
public AccessoriesType AccessoriesType { get; private set; } = accessoriesType;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Field Id is empty");
if (!Id.IsGuid())
throw new ValidationException("The value in the field Id is not a unique identifier");
if (Name.IsEmpty())
throw new ValidationException("Field PostName is empty");
if (AccessoriesType == AccessoriesType.None)
throw new ValidationException("Field PostType is empty");
}
}