31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
|
using CandyHouseBase.Exceptions;
|
||
|
using CandyHouseBase.Infrastructure;
|
||
|
using CandyHouseBase.Extensions;
|
||
|
|
||
|
namespace CandyHouseBase.DataModels
|
||
|
{
|
||
|
public class PekarDataModel : IValidation
|
||
|
{
|
||
|
public string Id { get; private set; }
|
||
|
public string FIO { get; private set; }
|
||
|
public string Position { get; private set; }
|
||
|
public decimal BonusCoefficient { get; private set; }
|
||
|
|
||
|
public PekarDataModel(string id, string fio, string position, decimal bonusCoefficient)
|
||
|
{
|
||
|
Id = id;
|
||
|
FIO = fio;
|
||
|
Position = position;
|
||
|
BonusCoefficient = bonusCoefficient;
|
||
|
}
|
||
|
|
||
|
public void Validate()
|
||
|
{
|
||
|
if (Id.IsEmpty()) throw new ValidationException("Field Id is empty");
|
||
|
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
|
||
|
if (FIO.IsEmpty()) throw new ValidationException("Field FIO is empty");
|
||
|
if (Position.IsEmpty()) throw new ValidationException("Field Position is empty");
|
||
|
if (BonusCoefficient <= 0) throw new ValidationException("BonusCoefficient must be positive");
|
||
|
}
|
||
|
}
|
||
|
}
|