InitUser after download
This commit is contained in:
+31
-21
@@ -42,29 +42,39 @@ namespace SafeBagDE70.Admin
|
||||
{
|
||||
try
|
||||
{
|
||||
var amCustomers = await APIModels.GetAeonMallCustomers(AppData.TenantId);
|
||||
using (var context = new CDMDbContext())
|
||||
if(AppData.IsInTransaction)
|
||||
{
|
||||
var customers = context.Customers;
|
||||
context.Customers.RemoveRange(customers);
|
||||
context.SaveChanges();
|
||||
foreach (var amCustomer in amCustomers)
|
||||
{
|
||||
var customer = new Customer
|
||||
{
|
||||
AccountNumber = amCustomer.TenantCode,
|
||||
AccountHolder = amCustomer.TenantName,
|
||||
TenantName = amCustomer.TenantShortName,
|
||||
TenantCode = amCustomer.TenantCode,
|
||||
PinCode = amCustomer.TenantCode,
|
||||
UpdatedTime = DateTime.Now,
|
||||
};
|
||||
customers.Add(customer);
|
||||
}
|
||||
context.SaveChanges();
|
||||
lblStatus.Foreground = new SolidColorBrush(Colors.Red);
|
||||
lblStatus.Content = "Vui lòng kết thúc giao dịch để thực hiện chức năng này";
|
||||
|
||||
}
|
||||
lblStatus.Foreground = new SolidColorBrush(Colors.Green);
|
||||
lblStatus.Content = "Updated customers: " + amCustomers.Count;
|
||||
else
|
||||
{
|
||||
var amCustomers = await APIModels.GetAeonMallCustomers(AppData.TenantId);
|
||||
using (var context = new CDMDbContext())
|
||||
{
|
||||
var customers = context.Customers;
|
||||
context.Customers.RemoveRange(customers);
|
||||
context.SaveChanges();
|
||||
foreach (var amCustomer in amCustomers)
|
||||
{
|
||||
var customer = new Customer
|
||||
{
|
||||
AccountNumber = amCustomer.TenantCode,
|
||||
AccountHolder = amCustomer.TenantName,
|
||||
TenantName = amCustomer.TenantShortName,
|
||||
TenantCode = amCustomer.TenantCode,
|
||||
PinCode = amCustomer.TenantCode,
|
||||
UpdatedTime = DateTime.Now,
|
||||
};
|
||||
customers.Add(customer);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
lblStatus.Foreground = new SolidColorBrush(Colors.Green);
|
||||
lblStatus.Content = "Updated customers: " + amCustomers.Count;
|
||||
}
|
||||
AppData.InitUsers();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ namespace SafeBagDE70
|
||||
|
||||
}
|
||||
|
||||
private static bool InitUsers()
|
||||
public static bool InitUsers()
|
||||
{
|
||||
int retryCount = 0;
|
||||
int maxRetries = 20; // Max retries before giving up
|
||||
|
||||
Reference in New Issue
Block a user