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);
     }
 }
Example #2
0
        public static IPersonalSetting GetOrCreatePersonalSettings(IEmployee employee)
        {
            var personalSettings = PersonalSettings.GetAll(s => employee.Equals(s.Employee)).SingleOrDefault();

            if (personalSettings == null)
            {
                personalSettings = CreatePersonalSettings(employee);
            }

            return(personalSettings);
        }
Example #3
0
        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);
        }