Beispiel #1
0
        public void Reload()
        {
            string path = CardSellerViewModel.Path;

            if (Directory.Exists(path))
            {
                foreach (string filename in Directory.EnumerateFiles(path, "*.xml", SearchOption.TopDirectoryOnly))
                {
                    try
                    {
                        CardSellerViewModel seller = new CardSellerViewModel(filename);
                        Sellers.Add(seller);
                    }
                    catch (Exception ex)
                    {
                        Logger.Exception($"Error while loading {filename ?? "??"} seller", ex);
                        PopupService.DisplayError($"Error while loading {filename ?? "??"} seller", ex);
                    }
                }
            }
        }
Beispiel #2
0
        private void AddNewSellerNameSelected(string name, string email)
        {
            CardSellerViewModel alreadyExisingSeller = Sellers.FirstOrDefault(x => String.Equals(x.SellerName, name, StringComparison.InvariantCultureIgnoreCase));

            if (alreadyExisingSeller != null)
            {
                Logger.Warning($"A seller with than name '{name}' has already been opened!");
                PopupService.DisplayError(
                    "Warning",
                    $"A seller with than name '{name}' has already been opened! Switching to {name}",
                    () => SelectedSeller = alreadyExisingSeller);
            }
            else
            {
                // Save sellers
                _cardSellers = _cardSellers ?? new CardSellers();
                CardSeller cardSeller = _cardSellers.Sellers.FirstOrDefault(x => CultureInfo.CurrentCulture.CompareInfo.IndexOf(x.Name, name, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase) >= 0);
                if (cardSeller == null)
                {
                    _cardSellers.Sellers.Add(new CardSeller
                    {
                        Name  = name,
                        Email = email
                    });
                }
                else
                {
                    cardSeller.Email = email;
                }
                SaveSellers();

                // Add seller view model
                CardSellerViewModel newSeller = new CardSellerViewModel(name, email);
                Sellers.Add(newSeller);
                SelectedSeller = newSeller;
            }
        }
Beispiel #3
0
 private void SelectSeller(CardSellerViewModel seller)
 {
     SelectedSeller = seller;
 }