protected override void checkBusinessRulesOnAdd(DomainObject entity) { Drzava drzava = (Drzava)entity; Notification notification = new Notification(); DrzavaDAO drzavaDAO = DAOFactoryFactory.DAOFactory.GetDrzavaDAO(); if (drzavaDAO.existsDrzavaNaziv(drzava.Naziv)) { notification.RegisterMessage("Naziv", "Drzava sa datim nazivom vec postoji."); throw new BusinessException(notification); } if (drzavaDAO.existsDrzavaKod(drzava.Kod)) { notification.RegisterMessage("Kod", "Drzava sa datim kodom vec postoji."); throw new BusinessException(notification); } }
protected override void checkBusinessRulesOnUpdate(DomainObject entity) { Drzava drzava = (Drzava)entity; Notification notification = new Notification(); DrzavaDAO drzavaDAO = DAOFactoryFactory.DAOFactory.GetDrzavaDAO(); bool nazivChanged = (drzava.Naziv.ToUpper() != oldNaziv.ToUpper()) ? true : false; if (nazivChanged && drzavaDAO.existsDrzavaNaziv(drzava.Naziv)) { notification.RegisterMessage("Naziv", "Drzava sa datim nazivom vec postoji."); throw new BusinessException(notification); } bool kodChanged = (drzava.Kod.ToUpper() != oldKod.ToUpper()) ? true : false; if (kodChanged && drzavaDAO.existsDrzavaKod(drzava.Kod)) { notification.RegisterMessage("Kod", "Drzava sa datim kodom vec postoji."); throw new BusinessException(notification); } }