78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using SafeBagDE70.API;
|
|
using SafeBagDE70.Model;
|
|
using Serilog;
|
|
using Serilog.Core;
|
|
using Serilog.Events;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace SafeBagDE70.Admin
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for LogViewerUC.xaml
|
|
/// </summary>
|
|
public partial class UserManageUC : UserControl
|
|
{
|
|
private ObservableCollection<string> _logItems = new ObservableCollection<string>();
|
|
|
|
public UserManageUC()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void LogInfoButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private async void btnGetUsers_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
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;
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
lblStatus.Foreground = new SolidColorBrush(Colors.Red);
|
|
lblStatus.Content= ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|