/// <summary>
 /// Add AccountSettingsImportDirectorys to database
 /// </summary>
 /// <param name="instances">AccountSettingsImportDirectory instance array</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountSettingsImportDirectoryAdd(IEnumerable<AccountSettingsImportDirectory> instances, AccountSettings settings, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     try
     {
         if (instances == null)
             throw new ArgumentNullException("instances");
         if (settings == null)
             throw new ArgumentNullException("settings");
         instances = instances.Where(i => i != null).ToArray();
         try
         {
             this.Context.AccountSettingsImportDirectories.AddRange(instances);
             if (saveAfterInsert)
                 this.SaveChanges(waitUntilSaving);
         }
         catch (Exception ex)
         {
             var e = new Exception(ex.Message, ex);
             for (int i = 0; i < instances.Count();i++)
                 e.Data.Add(string.Format("instance_{0}", i), instances.ElementAt(i).ToString());
             throw e;
         }
     }
     catch (Exception ex)
     {
         Helpers.Log.Add(ex, string.Format("Repository.AccountSettingsImportDirectoryAdd(instances=[{0}],saveAfterInsert={1},waitUntilSaving={2})", instances == null ? "NULL" : instances.Count().ToString(), saveAfterInsert, waitUntilSaving));
         throw;
     }
 }
 /// <summary>
 /// Add AccountSettingsImportDirectory to database
 /// </summary>
 /// <param name="instance">AccountSettingsImportDirectory instance</param>
 /// <param name="settings">AccountSettings instance for shedule time</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountSettingsImportDirectoryAdd(AccountSettingsImportDirectory instance, AccountSettings settings, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     AccountSettingsImportDirectoryAdd(new AccountSettingsImportDirectory[] { instance }, settings, saveAfterInsert, waitUntilSaving);
 }
 /// <summary>
 /// Add AccountSettingsSheduleTime to database
 /// </summary>
 /// <param name="instance">AccountSettingsSheduleTime instance</param>
 /// <param name="settings">AccountSettings instance for shedule time</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountSettingsSheduleTimeAdd(AccountSettingsSheduleTime instance, AccountSettings settings, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     AccountSettingsSheduleTimeAdd(new AccountSettingsSheduleTime[] { instance }, settings, saveAfterInsert, waitUntilSaving);
 }
        /// <summary>
        /// Create/Get new AccountSettingsImportDirectory instance without any link to database
        /// </summary>
        /// <returns>AccountSettingsImportDirectory instance</returns>
        public AccountSettingsImportDirectory AccountSettingsImportDirectoryNew(AccountSettings settings = null, object anonymousFiller = null)
        {
            try
            {
                var res = new AccountSettingsImportDirectory()
                {
                    Encoding = Encoding.Default,
                };

                if (anonymousFiller != null)
                    res.FillFromAnonymousType(anonymousFiller);

                if (settings != null)
                    settings.ImportDirectories.Add(res);
                return res;
            }
            catch(Exception ex)
            {
                Helpers.Log.Add(ex, string.Format("Repository.AccountSettingsImportDirectoryNew()"));
                throw;
            }
        }
 /// <summary>
 /// Create/Get new AccountSettingsSheduleTime instance without any link to database
 /// </summary>
 /// <returns>AccountSettingsSheduleTime instance</returns>
 public AccountSettingsSheduleTime AccountSettingsSheduleTimeNew(AccountSettings settings = null, TimeSpan? time = null)
 {
     try
     {
         var res = new AccountSettingsSheduleTime();
         if (time.HasValue)
             res.Time = time.Value;
         if (settings != null)
             settings.SheduleTimes.Add(res);
         return res;
     }
     catch(Exception ex)
     {
         Helpers.Log.Add(ex, string.Format("Repository.AccountSettingsSheduleTimeNew()"));
         throw;
     }
 }