using ElectricalRepairServiceContract.Enums; using ElectricalRepairServiceContract.Exceptions; using ElectricalRepairServiceContract.Extensions; using ElectricalRepairServiceContract.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElectricalRepairServiceContract.DataModels { public class SalaryDataModel : IValidation { public string Id { get; private set; } public SalaryType SalaryType { get; private set; } public int Amount { get; private set; } public string EmploeeId { get; private set; } public DateTime Date { get; private set; } public SalaryDataModel(string id, string postId, SalaryType type, int amount, DateTime date) { Id = id; SalaryType = type; Amount = amount; EmploeeId = postId; Date = date; } 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 (EmploeeId.IsEmpty()) throw new ValidationException("Field EmploeeId is empty"); if (!EmploeeId.IsGuid()) throw new ValidationException("The value in the field EmploeeId is not a unique identifier"); if (Amount < 0) throw new ValidationException("The amount must be positive"); } } }