46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
|
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; }
|
|||
|
|
|||
|
public DetailsDataModel(string id, string name, int count, int oldCount, DateTime updateDate)
|
|||
|
{
|
|||
|
Id = id;
|
|||
|
Name = name;
|
|||
|
Count = count;
|
|||
|
OldCount = oldCount;
|
|||
|
UpdateDate = updateDate;
|
|||
|
}
|
|||
|
|
|||
|
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)
|
|||
|
throw new ValidationException("The count must be more then 0");
|
|||
|
if (OldCount < 0)
|
|||
|
throw new ValidationException("The count must be more then 0");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|