/// <summary> /// Provjerava da li je trenutni objekt u ispravnom stanju /// </summary> public virtual void IsValid() { var errors = new BusinessRulesException<Person>(); if (!isOibValid()) { errors.AddErrorFor(x => x.Oib, "Oib is not valid."); } if (errors.Errors.Any()) { throw errors; } }
public virtual void SetBill(Bill bill) { var errors = new BusinessRulesException<Maintenance>(); if(bill.From.Oib != contractor.Oib) { errors.AddErrorFor(m => m.Bill, "Constractor who issued bill isn't the same as contractor responsible for the maintenance."); } if(errors.Errors.Any()) { throw errors; } this.bill = bill; }