private void InitCommands()
        {
            RemoveGoodCommand = new RelayCommand(x =>
            {
                goodService.Remove(SelectedGood);
                Goods.Remove(SelectedGood);
            });

            RemoveCategoryCommand = new RelayCommand(x =>
            {
                categoryService.Remove(SelectedCategory);
                Categories.Remove(SelectedCategory);
            });

            RemoveManufacturerCommand = new RelayCommand(x =>
            {
                manufacturerService.Remove(SelectedManufactirer);
                Manufacturers.Remove(SelectedManufactirer);
            });

            AddUpdateGoodCommand = new RelayCommand(x =>
            {
                AddUpdateGood dlg = new AddUpdateGood();
                dlg.ShowDialog();
                var good = new GoodDTO
                {
                    GoodName       = GoodViewModelProxy.Proxy.GoodName,
                    GoodCount      = GoodViewModelProxy.Proxy.GoodCount,
                    Price          = GoodViewModelProxy.Proxy.GoodPrice,
                    CategoryId     = categoryService.GetAll().FirstOrDefault(y => y.CategoryName == GoodViewModelProxy.Proxy.GoodCategory).CategoryId,
                    ManufacturerId = manufacturerService.GetAll().FirstOrDefault(y => y.ManufacturerName == GoodViewModelProxy.Proxy.GoodManufacturer).ManufacturerId
                };
                var result = goodService.CreateOrUpdate(good);
                Goods.Add(result);
            });

            AddUpdateCategoryCommand = new RelayCommand(x =>
            {
                AddUpdateCategoryView dlg = new AddUpdateCategoryView();
                dlg.ShowDialog();
                var category = new CategoryDTO
                {
                    CategoryName = CategoryViewModelProxy.Proxy.CategoryName
                };
                var result = categoryService.CreateOrUpdate(category);
                Categories.Add(result);
            });

            AddUpdateManufacturerCommand = new RelayCommand(x =>
            {
                AddUpdateManufactorerView dlg = new AddUpdateManufactorerView();
                dlg.ShowDialog();
                var manufactorer = new ManufacturerDTO
                {
                    ManufacturerName = ManufacturerModelProxy.Proxy.ManufacturerName
                };
                var result = manufacturerService.CreateOrUpdate(manufactorer);
                Manufacturers.Add(result);
            });
        }
Exemplo n.º 2
0
        public void AddTest()
        {
            VerifyDoesNotExist();
            bool value = Manufacturers.Add(_databasePath, _manufacturersTestName, out _errOut);

            General.HasTrueValue(value, _errOut);
        }
Exemplo n.º 3
0
        async Task ExecuteLoadManufacturersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Manufacturers.Clear();
                var items = await restService.GetResponse <List <Manufacturer> >(Constants.urlApi + "manufacturers", true);

                foreach (var item in items)
                {
                    Manufacturers.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Verifies the exists in case the test runs out of order this will makre sure that the data is in the database.
 /// </summary>
 private void VerifyExists()
 {
     if (!Manufacturers.Exists(_databasePath, _manufacturersTestName, out _errOut))
     {
         Manufacturers.Add(_databasePath, _manufacturersTestName, out _errOut);
     }
 }
Exemplo n.º 5
0
 public void AddChild(ICodelist child)
 {
     if (Manufacturers == null)
     {
         Manufacturers = new List <Manufacturer>();
     }
     Manufacturers.Add((Manufacturer)child);
 }
Exemplo n.º 6
0
 private void BluetoothService_NewDateRecieved(object _sender, BLEModel _bleModel)
 {
     Data.Add(_bleModel);
     if (!Manufacturers.ToList().Any(x => x.ManufacturerID == _bleModel.Manufacturer.ManufacturerID))
     {
         Manufacturers.Add(_bleModel.Manufacturer);
     }
 }
Exemplo n.º 7
0
 private void FillManufacturers()
 {
     Manufacturers.Clear();
     foreach (Manufacturer manufacturer in storeService.ManufacturerService.GetAllManufacturers())
     {
         Manufacturers.Add(manufacturer);
     }
 }
 private void FillProducts(IEnumerable <Product> products)
 {
     unshowedProducs = null;
     foreach (Product product in products)
     {
         Products.Add(product);
         if (!Manufacturers.Contains(product.Manufacturer))
         {
             Manufacturers.Add(product.Manufacturer);
         }
     }
 }
Exemplo n.º 9
0
        private async void getData()
        {
            foreach (var item in await catService.GetData())
            {
                Categories.Add(item);
            }

            foreach (var item in await manuService.GetData())
            {
                Manufacturers.Add(item);
            }
        }
Exemplo n.º 10
0
 public void Read(Stream stream, uint startPosition)
 {
     for (int i = 0; i < 39; i++)
     {
         stream.Position = (i * 4) + startPosition;
         var manufacturer = new Manufacturer()
         {
             Name = ManufacturerNames[i]
         };
         manufacturer.Read(stream, startPosition + stream.ReadUShort(), stream.ReadUShort());
         Manufacturers.Add(manufacturer);
     }
 }
Exemplo n.º 11
0
 public void ReadCSV(string directory)
 {
     foreach (string name in ManufacturerNames)
     {
         var manufacturer = new Manufacturer()
         {
             Name = name
         };
         string filename = directory + "\\" + manufacturer.Name + ".csv";
         if (!string.IsNullOrWhiteSpace(name) && File.Exists(filename))
         {
             manufacturer.ReadCSV(filename);
         }
         Manufacturers.Add(manufacturer);
     }
 }
Exemplo n.º 12
0
 private void SeedManufacturers()
 {
     Manufacturers.Add(new ManufacturerEntity
     {
         Id              = ManufacturerGuids[0],
         Name            = "Dell",
         Description     = "...",
         Logo            = "Path",
         CountryOfOrigin = "USA",
     });
     Manufacturers.Add(new ManufacturerEntity
     {
         Id              = ManufacturerGuids[1],
         Name            = "Lenovo",
         Description     = "...",
         Logo            = "Path",
         CountryOfOrigin = "China",
     });
 }
Exemplo n.º 13
0
        public void ReadCSV(string directory)
        {
            foreach (string name in ManufacturerNames)
            {
                var manufacturer = new Manufacturer()
                {
                    Name = name
                };

                foreach (string filename in Directory.EnumerateFiles(directory, $"{manufacturer.Name}*.csv"))
                {
                    if (!string.IsNullOrWhiteSpace(name) && File.Exists(filename))
                    {
                        manufacturer.ReadCSV(filename);
                    }
                }
                manufacturer.Sort();
                Manufacturers.Add(manufacturer);
            }
        }
Exemplo n.º 14
0
        public SelectManufacturerPageViewModel(INavigationService navigationService,
                                               IManufacturerService manufacturerService,
                                               IDialogService dialogService
                                               ) : base(navigationService, dialogService)
        {
            Title = "选择供应商";

            _navigationService   = navigationService;
            _dialogService       = dialogService;
            _manufacturerService = manufacturerService;

            //Load
            this.Load = ManufacturersLoader.Load(async() =>
            {
                //重载时排它
                ItemTreshold = 1;
                try
                {
                    //清除列表
                    Manufacturers.Clear();

                    var items = await GetManufacturersPage(0, PageSize);
                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            if (Manufacturers.Count(s => s.Id == item.Id) == 0)
                            {
                                Manufacturers.Add(item);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }

                this.Manufacturers = new ObservableRangeCollection <ManufacturerModel>(Manufacturers);


                return(Manufacturers.ToList());
            });

            //以增量方式加载数据
            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                using (var dig = UserDialogs.Instance.Loading("加载中..."))
                {
                    try
                    {
                        int pageIdex         = Manufacturers.Count / (PageSize == 0 ? 1 : PageSize);
                        var items            = await GetManufacturersPage(pageIdex, PageSize);
                        var previousLastItem = Terminals.Last();
                        if (items != null)
                        {
                            foreach (var item in items)
                            {
                                if (Manufacturers.Count(s => s.Id == item.Id) == 0)
                                {
                                    Manufacturers.Add(item);
                                }
                            }

                            if (items.Count() == 0 || items.Count() == Terminals.Count)
                            {
                                ItemTreshold = -1;
                                return(Manufacturers.ToList());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                        ItemTreshold = -1;
                    }


                    this.Manufacturers = new ObservableRangeCollection <ManufacturerModel>(Manufacturers);
                    return(Manufacturers.ToList());
                }
            }, this.WhenAny(x => x.Terminals, x => x.GetValue().Count > 0));


            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async item =>
            {
                await _navigationService.GoBackAsync(("Manufacturer", item));
                this.Selecter = null;
            }).DisposeWith(DeactivateWith);

            this.BindBusyCommand(Load);
        }