InitUser after download

This commit is contained in:
thuannd88
2024-09-16 19:27:35 +07:00
parent 26ba949d1f
commit 2e94ba03ac
2 changed files with 32 additions and 22 deletions
+31 -21
View File
@@ -42,29 +42,39 @@ namespace SafeBagDE70.Admin
{ {
try try
{ {
var amCustomers = await APIModels.GetAeonMallCustomers(AppData.TenantId); if(AppData.IsInTransaction)
using (var context = new CDMDbContext())
{ {
var customers = context.Customers; lblStatus.Foreground = new SolidColorBrush(Colors.Red);
context.Customers.RemoveRange(customers); lblStatus.Content = "Vui lòng kết thúc giao dịch để thực hiện chức năng này";
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); else
lblStatus.Content = "Updated customers: " + amCustomers.Count; {
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) catch(Exception ex)
{ {
+1 -1
View File
@@ -68,7 +68,7 @@ namespace SafeBagDE70
} }
private static bool InitUsers() public static bool InitUsers()
{ {
int retryCount = 0; int retryCount = 0;
int maxRetries = 20; // Max retries before giving up int maxRetries = 20; // Max retries before giving up