2025-02-13 18:16:23 +04:00
|
|
|
|
using ElectricalRepairServiceContract.Exceptions;
|
|
|
|
|
using ElectricalRepairServiceContract.Extensions;
|
|
|
|
|
using ElectricalRepairServiceContract.Interfaces;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ElectricalRepairServiceContract.DataModels
|
|
|
|
|
{
|
|
|
|
|
public class DetailsDataModel : IValidation
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; private set; }
|
|
|
|
|
public string Name { get; private set; }
|
|
|
|
|
public int Count { get; private set; }
|
|
|
|
|
public int OldCount { get; private set; }
|
|
|
|
|
public DateTime UpdateDate { get; private set; }
|
2025-02-13 18:55:25 +04:00
|
|
|
|
public List<DetailDeliveryDataModel>? DetailsDelivery { get; private set; }
|
|
|
|
|
public List<DetailsUseDataModel>? DetailsUses { get; private set; }
|
2025-02-13 18:16:23 +04:00
|
|
|
|
|
2025-02-13 18:55:25 +04:00
|
|
|
|
public DetailsDataModel(string id, string name, int count, int oldCount,
|
|
|
|
|
DateTime updateDate, List<DetailDeliveryDataModel>? detailsDelivery, List<DetailsUseDataModel>? detailsUses)
|
2025-02-13 18:16:23 +04:00
|
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Name = name;
|
|
|
|
|
Count = count;
|
|
|
|
|
OldCount = oldCount;
|
|
|
|
|
UpdateDate = updateDate;
|
2025-02-13 18:55:25 +04:00
|
|
|
|
DetailsDelivery = detailsDelivery;
|
|
|
|
|
DetailsUses = detailsUses;
|
2025-02-13 18:16:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 Description is empty");
|
|
|
|
|
if (Count < 0)
|
2025-02-13 18:55:25 +04:00
|
|
|
|
throw new ValidationException("The count must be positive");
|
2025-02-13 18:16:23 +04:00
|
|
|
|
if (OldCount < 0)
|
2025-02-13 18:55:25 +04:00
|
|
|
|
throw new ValidationException("The count must be positive");
|
2025-02-13 18:16:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|