39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using ElectricalRepairServiceContract.Enums;
|
|
using ElectricalRepairServiceContract.Exceptions;
|
|
using ElectricalRepairServiceContract.Extensions;
|
|
using ElectricalRepairServiceContract.Interfaces;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace ElectricalRepairServiceContract.DataModels
|
|
{
|
|
public class PostDataModel : IValidation
|
|
{
|
|
public string Id { get; private set; }
|
|
public PostType PostType { get; private set; }
|
|
|
|
public string Description { get; private set; }
|
|
|
|
public bool IsActual { get; private set; }
|
|
public DateTime ChangeDate { get; private set; }
|
|
|
|
public PostDataModel(string id, PostType name, bool isActual, DateTime changeDate, string description)
|
|
{
|
|
Id = id;
|
|
PostType = name;
|
|
IsActual = isActual;
|
|
ChangeDate = changeDate;
|
|
Description = description;
|
|
}
|
|
|
|
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 (Description.IsEmpty())
|
|
throw new ValidationException("Field Description is empty");
|
|
}
|
|
}
|
|
}
|