/// <summary>
        /// Add AccountDictionaryRecordConditions to database
        /// </summary>
        /// <param name="instances">AccountDictionaryRecordCondition instance array</param>
        /// <param name="accountDictionaryRecord">AccountDictionaryRecord instance for instances</param>
        /// <param name="saveAfterInsert">Save database after insertion</param>
        /// <param name="waitUntilSaving">Wait until saving</param>
        public void AccountDictionaryRecordConditionAdd(IEnumerable<AccountDictionaryRecordCondition> instances, AccountDictionaryRecord accountDictionaryRecord, bool saveAfterInsert = true, bool waitUntilSaving = true)
        {
            try
            {
                if (instances == null)
                    throw new ArgumentNullException("instances");
                if (accountDictionaryRecord == null)
                    throw new ArgumentNullException("accountDictionary");
                instances = instances.Where(i => i != null).ToArray();
                try
                {
                    foreach (var i in instances)
                        if (i.DictionaryRecord != accountDictionaryRecord)
                            i.DictionaryRecord = accountDictionaryRecord;

                    this.Context.AccountDictionaryRecordConditions.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.AccountDictionaryRecordConditionAdd(instances=[{0}],saveAfterInsert={1},waitUntilSaving={2})", instances == null ? "NULL" : instances.Count().ToString(), saveAfterInsert, waitUntilSaving));
                throw;
            }
        }
 /// <summary>
 /// Add AccountDictionaryRecordCondition to database
 /// </summary>
 /// <param name="instance">AccountDictionaryRecordCondition instance</param>
 /// <param name="accountDictionaryRecord">AccountDictionaryRecord instance for instance</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountDictionaryRecordConditionAdd(AccountDictionaryRecordCondition instance, AccountDictionaryRecord accountDictionaryRecord, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     AccountDictionaryRecordConditionAdd(new AccountDictionaryRecordCondition[] { instance }, accountDictionaryRecord, saveAfterInsert, waitUntilSaving);
 }
        /// <summary>
        /// Create/Get new AccountDictionaryRecordCondition instance without any link to database
        /// </summary>
        /// <returns>AccountDictionaryRecordCondition instance</returns>
        public AccountDictionaryRecordCondition AccountDictionaryRecordConditionNew(AccountDictionaryRecord accountDictionaryRecord = null, uint? from = null, uint? to = null, bool? even = null)
        {
            try
            {
                var res = new AccountDictionaryRecordCondition()
                {
                    Even = even,
                    DictionaryRecord = accountDictionaryRecord,
                };

                if (from.HasValue)
                    res.From = from.Value;
                if (to.HasValue)
                    res.To = to.Value;
                if (accountDictionaryRecord != null)
                    accountDictionaryRecord.Conditions.Add(res);
                return res;
            }
            catch(Exception ex)
            {
                Helpers.Log.Add(ex, string.Format("Repository.AccountDictionaryRecordConditionNew()"));
                throw;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Remove AccountDictionaryRecord from database
 /// </summary>
 /// <param name="instance">AccountDictionaryRecord instance</param>
 /// <param name="saveAfterRemove">Save database after removing</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountDictionaryRecordRemove(AccountDictionaryRecord instance, bool saveAfterRemove = true, bool waitUntilSaving = true)
 {
     AccountDictionaryRecordRemove(new AccountDictionaryRecord[] { instance }, saveAfterRemove, waitUntilSaving);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add AccountDictionaryRecord to database
 /// </summary>
 /// <param name="instance">AccountDictionaryRecord instance</param>
 /// <param name="accountDictionary">AccountDictionary instance for instance</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountDictionaryRecordAdd(AccountDictionaryRecord instance, AccountDictionary accountDictionary, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     AccountDictionaryRecordAdd(new AccountDictionaryRecord[] { instance }, accountDictionary, saveAfterInsert, waitUntilSaving);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create/Get new AccountDictionaryRecord instance without any link to database
 /// </summary>
 /// <returns>AccountDictionaryRecord instance</returns>
 public AccountDictionaryRecord AccountDictionaryRecordNew(AccountDictionary accountDictionary = null, Street street = null, Street streetChangeTo = null, object anonymousObject = null)
 {
     try
     {
         var res = new AccountDictionaryRecord() 
         {
             Street = street,
             ChangeStreetTo = streetChangeTo,
             Dictionary = accountDictionary,
         };
         if (anonymousObject != null)
             res.FillFromAnonymousType(anonymousObject);
         if (accountDictionary != null)
             accountDictionary.Records.Add(res);
         return res;
     }
     catch(Exception ex)
     {
         Helpers.Log.Add(ex, string.Format("Repository.AccountDictionaryRecordNew()"));
         throw;
     }
 }