Exemple #1
0
        public void UpdateShiftProfiles(DateTime now)
        {
            var dbProfiles = repository.GetShiftProfiles();

            foreach (var profile in configuration.ShiftProfiles.Where(p => p.Start <= now && p.End > now))
            {
                var profiles       = dbProfiles.Where(p => p.Name == profile.Name);
                var disableProfile = profiles.Where(p => p.Start != profile.Start);
                if (disableProfile.Any())
                {
                    foreach (var p in disableProfile)
                    {
                        repository.DisableShiftProfile(p);
                    }
                    profiles = null;
                }

                if (profiles == null || !profiles.Any())
                {
                    InsertShiftProfile(profile);
                }
            }
        }