public AddProductDepartmentViewModel(ProductDepartmentModel productDepartmentModel) { var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>(); _adminDataUnit = dataUnitLocator.ResolveDataUnit<IAdminDataUnit>(); OKCommand = new RelayCommand(OKCommandExecuted, OKCommandCanExecute); ProcessProductDepartment(productDepartmentModel); }
public AddProductDepartmentView(ProductDepartmentModel productGroupModel) { InitializeComponent(); DataContext = ViewModel = new AddProductDepartmentViewModel(productGroupModel); ViewModel.PropertyChanged += ViewModelOnPropertyChanged; Owner = Application.Current.MainWindow; Loaded += OnViewLoaded; }
private void ProcessProductDepartment(ProductDepartmentModel productDepartmentModel) { _isEditMode = (productDepartmentModel != null); ProductDepartment = productDepartmentModel ?? GetNewProductDepartment(); if (_isEditMode) TillDivision = productDepartmentModel.Till.TillDivision; ProductDepartment.PropertyChanged += OnProductDepartmentPropertyChanged; }
private ProductDepartmentModel GetNewProductDepartment() { var productDepartmentModel = new ProductDepartmentModel(new ProductDepartment() { ID = Guid.NewGuid() }); return productDepartmentModel; }
private void EditProductDepartmentCommandExecuted(ProductDepartmentModel model) { RaisePropertyChanged("DisableParentWindow"); var view = new AddProductDepartmentView(model); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); }
private async void DeleteProductDepartmentCommandExecuted(ProductDepartmentModel model) { if (model == null) return; bool? dialogResult = null; string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM; RaisePropertyChanged("DisableParentWindow"); RadWindow.Confirm(confirmText, (sender, args) => { dialogResult = args.DialogResult; }); RaisePropertyChanged("EnableParentWindow"); if (dialogResult != true) return; // Check if product Department has dependencies if (model.ProductDepartment.Products.Any()) { var sb = new StringBuilder(); sb.AppendLine("Sorry, we can't delete this product Department :("); sb.AppendLine("This product Department already in use by these products:"); model.ProductDepartment.Products.Select(x => x.Name).ForEach(x => sb.AppendLine(string.Format("- {0}", x))); RaisePropertyChanged("DisableParentWindow"); RadWindow.Alert(sb.ToString()); RaisePropertyChanged("EnableParentWindow"); return; } // Delete product Department _adminDataUnit.ProductDepartmentsRepository.Delete(model.ProductDepartment); await _adminDataUnit.SaveChanges(); ProductDepartments.Remove(model); }