private async Task ImportCustomerList(string fileName)
        {
            await Task.Run(() =>
            {
                StreamReader r    = new StreamReader(fileName);
                string jsonString = r.ReadToEnd();
                // QBInvoice m = JsonConvert.DeserializeObject<QBInvoice>(jsonString);

                QBCustomer mm = JsonConvert.DeserializeObject <QBCustomer>(jsonString);
                List <Customer> customerList = new List <Customer>();
                if (mm.QueryResponse.Customer.Count == 0)
                {
                    MessageBox.Show("List Empty");
                }
                else
                {
                    var step = 100 / (mm.QueryResponse.Customer.Count + 4);
                    int i    = 0;

                    foreach (var item in mm.QueryResponse.Customer)
                    {
                        customerList.Add(new Customer()
                        {
                            Id                 = Convert.ToInt32(item.Id),
                            ContactName        = item.GivenName,
                            ContactLastName    = item.FamilyName,
                            Phone1             = item.PrimaryPhone == null ? "" : item.PrimaryPhone.FreeFormNumber,
                            Email              = item.PrimaryEmailAddr == null ? "" : item.PrimaryEmailAddr.Address,
                            City               = item.BillAddr == null ? "" : item.BillAddr.City,
                            CompanyName        = item.CompanyName == null ? "" : item.CompanyName,
                            PostalCode         = item.BillAddr == null ? "" : item.BillAddr.PostalCode,
                            DisplayShipAddress = item.BillAddr == null ? "" : item.GivenName + " " + item.FamilyName + "\n" + item.BillAddr.Line1 + "\n" + item.BillAddr.City + ", " + item.BillAddr.CountrySubDivisionCode + " " +
                                                 item.BillAddr.PostalCode + "\n" + item.BillAddr.Country,
                            BalanceDueLCY = Convert.ToDecimal(item.Balance),
                            BalanceLCY    = Convert.ToDecimal(item.BalanceWithJobs),
                            Active        = item.Active,
                            Note          = item.Notes,
                            CreatedBy_fk  = 1
                        });
                    }

                    foreach (var customer in customerList.OrderBy(p => p.Id))
                    {
                        _repositoryService.AddAndUpdateCustomer(customer, false);
                        i += step;
                        this.Dispatcher.Invoke(() => pbStatus.Value = i);
                    }
                    bool res = _repositoryService.SaveDatabase();
                    this.Dispatcher.Invoke(() => pbStatus.Value      = 100);
                    this.Dispatcher.Invoke(() => pbStatus.Foreground = Brushes.DarkGreen);
                    if (!res)
                    {
                        MessageBox.Show("Error");
                    }
                }
            });
        }
        public MainWindow()
        {
            InitializeComponent();

            QBCustomer         qbc = new QBCustomer();
            quickbooksEntities qbe = new quickbooksEntities();

            ObservableCollection <customer> Customers = qbc.DbRead();

            qbe.customers.AddRange(Customers);
            qbe.SaveChanges();
        }
 public ControllerCustomer()
 {
     qbCustomer         = new QBCustomer();
     repositoryCustomer = new EFRepositoryCustomers();
 }