/// <summary>
 /// Update product info view and set _isEditedProductInfo in the presentation model.
 /// </summary>
 private void UpdateProductInfoViewAndSetIsEditedProductInfo()
 {
     _productNameField.Text        = _productsManagementTabPagePresentationModel.GetCurrentSelectedProductName();
     _productPriceField.Text       = _productsManagementTabPagePresentationModel.GetCurrentSelectedProductPrice();
     _productTypeField.Text        = _productsManagementTabPagePresentationModel.GetCurrentSelectedProductType();
     _productImagePathField.Text   = _productsManagementTabPagePresentationModel.GetCurrentSelectedProductImagePath();
     _productDescriptionField.Text = _productsManagementTabPagePresentationModel.GetCurrentSelectedProductDescription();
     _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(false);
 }
        public void TestSetIsEditedProductInfoAndNotifyObserver()
        {
            int count = 0;

            _productsManagementTabPagePresentationModel.IsEditedProductInfoChanged += () => count++;
            _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
            Assert.IsTrue(( bool )_target.GetFieldOrProperty(MEMBER_VARIABLE_NAME_IS_EDITED_PRODUCT_INFO));
            Assert.AreEqual(count, 1);
        }
 public ProductManagementForm(ProductsManagementTabPagePresentationModel productsManagementTabPagePresentationModelData, ProductTypesManagementTabPagePresentationModel productTypesManagementTabPagePresentationModelData, Model modelData)
 {
     InitializeComponent();
     _productsManagementTabPagePresentationModel     = productsManagementTabPagePresentationModelData;
     _productTypesManagementTabPagePresentationModel = productTypesManagementTabPagePresentationModelData;
     _model         = modelData;
     this.Disposed += RemoveEvents;
     // Observers
     _model.ProductInfoChanged += ResetViewOnProductInfoChangedOrOnProductAdded;
     _model.ProductAdded       += ResetViewOnProductInfoChangedOrOnProductAdded;
     _model.ProductTypeAdded   += ResetViewOnProductTypeAdded;
     _productsManagementTabPagePresentationModel.CurrentSelectedProductChanged                 += UpdateProductInfoViewAndSetIsEditedProductInfo;
     _productsManagementTabPagePresentationModel.SubmitProductInfoButtonEnabledChanged         += UpdateSubmitProductInfoButtonView;
     _productTypesManagementTabPagePresentationModel.CurrentSelectedProductTypeChanged         += UpdateProductTypeInfoView;
     _productTypesManagementTabPagePresentationModel.SubmitProductTypeInfoButtonEnabledChanged += UpdateProductTypeInfoButtonView;
     // UI
     _productsListBox.SelectedIndexChanged     += ChangeProductsListBoxSelectedIndex;
     _productTypesListBox.SelectedIndexChanged += ChangeProductTypesListBoxSelectedIndex;
     _productPriceField.KeyPress        += InputHelper.InputNumbersOrBackSpace;
     _productImageBrowseButton.Click    += (sender, eventArguments) => BrowseImageAndSetProductImagePath();
     _submitProductInfoButton.Click     += (sender, eventArguments) => _productsManagementTabPagePresentationModel.ClickSubmitProductInfoButton(new ProductInfo(_productNameField.Text, _productTypeField.Text, new Money(int.Parse(_productPriceField.Text)), _productDescriptionField.Text, _productImagePathField.Text));
     _submitProductTypeInfoButton.Click += (sender, eventArguments) => _productTypesManagementTabPagePresentationModel.ClickSubmitProductTypeInfoButton(_productTypeNameField.Text);
     _addProductButton.Click            += (sender, eventArguments) => SetProductsManagementTabPageStateAndUpdateViewOnAddProductButtonClicked();
     _addProductTypeButton.Click        += (sender, eventArguments) => SetProductTypesManagementTabPageStateAndUpdateViewOnAddProductTypeButtonClicked();
     // Product info
     _productNameField.TextChanged        += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productPriceField.TextChanged       += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productTypeField.TextChanged        += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productImagePathField.TextChanged   += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productDescriptionField.TextChanged += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     // Input inspecting textboxes
     InitializeInputInspectingTextBoxesTextBoxInspectors();
     InitializeInputInspectingTextBoxes();
     InitializeInputInspectingTextBoxesTextBoxInspectorsCollectionChangedEventHandlers();
     // Input inspecting drop-down lists
     InitializeInputInspectingDropDownListsDropDownListInspectors();
     InitializeInputInspectingDropDownLists();
     InitializeInputInspectingDropDownListsDropDownListInspectorsCollectionChangedEventHandlers();
     // Input inspectors collection
     InitializeInputInspectorsCollection();
     // Input inspecting textbox of product types management tab page
     _productTypeNameField.AddTextBoxInspectors(InputInspectorTypeHelper.FLAG_TEXT_BOX_IS_NOT_EMPTY);
     _productTypeNameField.TextBoxInspectorsCollectionChanged += () => UpdateErrorProviderViewAndIsValidProductTypeInfo(_productTypeNameField, _productTypeNameField.GetInputInspectorsError());
     // Initial UI States
     InitializeProductTypeField();
     InitializeProductsListBox();
     InitializeProductTypesListBox();
     _productsManagementTabPagePresentationModel.SetCurrentSelectedProductAndNotifyObserver(null);
     _productsManagementTabPagePresentationModel.SetIsValidProductInfoAndNotifyObserver(false);
     _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(false);
     _productsManagementTabPagePresentationModel.SetProductsManagementTabPageStateAndNotifyObserver(ProductsManagementTabPageState.EditProduct);
     _productTypesManagementTabPagePresentationModel.SetCurrentSelectedProductTypeAndNotifyObserver(null);
     _productTypesManagementTabPagePresentationModel.SetIsValidProductTypeInfoAndNotifyObserver(false);
     _productTypesManagementTabPagePresentationModel.SetProductTypesManagementTabPageStateAndNotifyObserver(ProductTypesManagementTabPageState.ViewProductType);
 }