Skip to content

Commit

Permalink
Code-review feedback, changed Hashtables to Dictionary<string, string…
Browse files Browse the repository at this point in the history
…> so get functions can use .TryAdd logic
  • Loading branch information
MatthiasSort committed Nov 11, 2024
1 parent 3d436ed commit 17df5fe
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/OrderProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Logging;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
Expand Down Expand Up @@ -562,20 +561,20 @@ private static void RemoveColumnMappingsThatShouldBeSkippedInMoveToMainTables(Ma
}
}

private Hashtable _existingUsers = null;
private Dictionary<string, string> _existingUsers = null;
/// <summary>
/// Collection of <AccessUserExternalID>, <AccessUserID> key value pairs
/// </summary>
private Hashtable ExistingUsers
private Dictionary<string, string> ExistingUsers
{
get
{
if (_existingUsers == null)
{
_existingUsers = new Hashtable();
SqlDataAdapter usersDataAdapter = new SqlDataAdapter("select AccessUserExternalID, AccessUserID from AccessUser where AccessUserExternalID is not null and AccessUserExternalID <> ''", Connection);
_existingUsers = [];
SqlDataAdapter usersDataAdapter = new("select AccessUserExternalID, AccessUserID from AccessUser where AccessUserExternalID is not null and AccessUserExternalID <> ''", Connection);
new SqlCommandBuilder(usersDataAdapter);
DataSet dataSet = new DataSet();
DataSet dataSet = new();
usersDataAdapter.Fill(dataSet);
DataTable dataTable = dataSet.Tables[0];
if (dataTable != null)
Expand All @@ -584,22 +583,19 @@ private Hashtable ExistingUsers
foreach (DataRow row in dataTable.Rows)
{
key = row["AccessUserExternalID"].ToString();
if (!_existingUsers.ContainsKey(key))
{
_existingUsers.Add(key, row["AccessUserID"].ToString());
}
_existingUsers.TryAdd(key, row["AccessUserID"].ToString());
}
}
}
return _existingUsers;
}
}

private Hashtable _existingOrders = null;
private Dictionary<string, string> _existingOrders = null;
/// <summary>
/// Collection of <OrderIntegrationOrderId>, <OrderId> key value pairs
/// </summary>
private Hashtable ExistingOrdersWithOrderIntegrationOrderId
private Dictionary<string, string> ExistingOrdersWithOrderIntegrationOrderId
{
get
{
Expand All @@ -617,10 +613,7 @@ private Hashtable ExistingOrdersWithOrderIntegrationOrderId
foreach (DataRow row in dataTable.Rows)
{
key = row["OrderIntegrationOrderId"].ToString();
if (!_existingOrders.ContainsKey(key))
{
_existingOrders.Add(key, row["OrderId"].ToString());
}
_existingOrders.TryAdd(key, row["OrderId"].ToString());
}
}
}
Expand Down

0 comments on commit 17df5fe

Please sign in to comment.