public override void BeforeSave(Sungero.Domain.BeforeSaveEventArgs e) { if (PersonalSettings.GetAll(s => Equals(s.Employee, _obj.Employee) && !Equals(s, _obj)).Any()) { throw AppliedCodeException.Create(PersonalSettings.Resources.CantCreateMoreSetting); } }
public static IPersonalSetting GetOrCreatePersonalSettings(IEmployee employee) { var personalSettings = PersonalSettings.GetAll(s => employee.Equals(s.Employee)).SingleOrDefault(); if (personalSettings == null) { personalSettings = CreatePersonalSettings(employee); } return(personalSettings); }
public static IPersonalSetting CreatePersonalSettings(IEmployee employee) { var personalSettings = PersonalSettings.GetAll(s => Equals(s.Employee, employee)).SingleOrDefault(); if (personalSettings != null) { return(personalSettings); } personalSettings = PersonalSettings.Create(); personalSettings.Employee = employee; personalSettings.Save(); return(personalSettings); }