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); }); }