- Chỉnh update users

- Đưa phần gọi lệnh đếm vào Task
This commit is contained in:
Nguyen Dinh Thuan
2024-09-20 06:36:56 +07:00
parent 2d474ef17f
commit 781e7e4f25
3 changed files with 79 additions and 45 deletions
+2 -22
View File
@@ -50,29 +50,9 @@ namespace SafeBagDE70.Admin
}
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();
}
int nUpdatedCustomers=await AppData.UpdateCustomers();
lblStatus.Foreground = new SolidColorBrush(Colors.Green);
lblStatus.Content = "Updated customers: " + amCustomers.Count;
lblStatus.Content = "Updated customers: " + nUpdatedCustomers;
}
AppData.InitUsers();
}