示例#1
0
		private void btnAddFeature_Click(object sender, RoutedEventArgs e)
		{
			if (_featuresService == null)
				_featuresService = ObjectLocator.GetInstance<IFeaturesService>();

			if (string.IsNullOrEmpty(txtFeatureName.Text))
			{
				MessageBox.Show("You must supply a feature name.");
				return;
			}

			Feature f = new Feature();
			f.Name = txtFeatureName.Text;
			f.Description = txtFeatureDescription.Text;
			f.ProductId = _product.ProductId;

			if (_featuresService.IsFeatureNameInUse(_product.ProductId, f.Name))
			{
				MessageBox.Show("Feature name is in use for this product, please try again");
				return;
			}
			else
			{
				_featuresService.SaveFeature(f);

				txtFeatureName.Text = "";
				txtFeatureDescription.Text = "";

				_product.Features = new NotifyList<Feature>(_featuresService.GetFeaturesForProduct(_product.ProductId));
				gridFeatures.ItemsSource = SelectedProduct.Features;
			}
		}
示例#2
0
		public Feature SaveFeature(Feature feature)
		{
			if (feature.FeatureId == 0)
				return _featuresRepository.InsertFeature(feature).First();
			else
				return _featuresRepository.UpdateFeature(feature).First();
		}