using System; using CandyHouseBase.Exceptions; using CandyHouseBase.Extensions; using CandyHouseBase.Infrastructure; namespace CandyHouseBase.DataModels { public class SalaryDataModel : IValidation { public string Id { get; private set; } public string PekarId { get; private set; } public DateTime Period { get; private set; } public decimal BaseRate { get; private set; } public decimal BonusRate { get; private set; } public decimal TotalSalary { get; private set; } public SalaryDataModel(string id, string pekarId, DateTime period, decimal baseRate, decimal bonusRate, decimal totalSalary) { Id = id; PekarId = pekarId; Period = period; BaseRate = baseRate; BonusRate = bonusRate; TotalSalary = totalSalary; } 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 (PekarId.IsEmpty()) throw new ValidationException("Field PekarId is empty"); if (!PekarId.IsGuid()) throw new ValidationException("PekarId must be a GUID"); if (BaseRate < 0) throw new ValidationException("BaseRate cannot be negative"); if (BonusRate < 0) throw new ValidationException("BonusRate cannot be negative"); if (TotalSalary < 0) throw new ValidationException("TotalSalary cannot be negative"); } } }