public static void UpdateSettingsDictionary(int storeId, short paymentProviderId, Dictionary <string, string> settings) { using (esTransactionScope transaction = new esTransactionScope()) { // DELETE all existing settings for this store/provider StorePaymentProviderSettingQuery qDelete = new StorePaymentProviderSettingQuery(); qDelete.Where(qDelete.StoreId == storeId, qDelete.PaymentProviderId == paymentProviderId); StorePaymentProviderSettingCollection oldSettings = new StorePaymentProviderSettingCollection(); oldSettings.Load(qDelete); oldSettings.MarkAllAsDeleted(); oldSettings.Save(); // INSERT new settings for this store/provider if (settings.Keys.Count > 0) { StorePaymentProviderSettingCollection newSettings = new StorePaymentProviderSettingCollection(); foreach (KeyValuePair <string, string> setting in settings) { StorePaymentProviderSetting newSetting = newSettings.AddNew(); newSetting.StoreId = storeId; newSetting.PaymentProviderId = paymentProviderId; newSetting.Name = setting.Key; newSetting.Value = setting.Value; } newSettings.Save(); } transaction.Complete(); } }
static public void Delete(System.Int32 storeId, System.Int16 paymentProviderId, System.String name, esSqlAccessType sqlAccessType) { var obj = new StorePaymentProviderSetting(); obj.StoreId = storeId; obj.PaymentProviderId = paymentProviderId; obj.Name = name; obj.AcceptChanges(); obj.MarkAsDeleted(); obj.Save(sqlAccessType); }