Пример #1
0
		public Product SaveProduct(Product product)
		{
			if (product.ProductId == 0)
				return productsRepository.InsertProduct(product).First();
			else
				return productsRepository.UpdateProduct(product).First();
		}
Пример #2
0
        private void btnAddProduct_Click(object sender, RoutedEventArgs e)
        {
            if (IsNewProductFormValid())
            {
                IProductsService productsService = ObjectLocator.GetInstance<IProductsService>();

                if (productsService.IsProductNameInUse(txtProductName.Text.Trim()))
                {
                    MessageBox.Show(string.Format("The product name you entered [{0}] is already in use.", txtProductName.Text.Trim()));
                    return;
                }

                Product p = new Product();
                p.Name = txtProductName.Text.Trim();
                p.Description = txtProductDescription.Text;

                productsService.SaveProduct(p);

                ResetNewProductForm();

                IEventAggregator eventAggregator = ObjectLocator.GetInstance<IEventAggregator>();
                eventAggregator.SendMessage<ProductsUpdatedEvent>();

                gridProducts.DataSource = productsService.GetAllProducts();
            }
            else
            {
                MessageBox.Show("Please fill in the form completely to add a new product.");
            }
        }
Пример #3
0
		public FeaturesWindow(Window parent, Product product)
			: this(parent)
		{
			_product = product;
			lblProductName.Text = _product.Name;

			gridFeatures.ItemsSource = SelectedProduct.Features;
		}
		public UpdateProductWindow(Window parent, Product product)
			: this(parent)
		{
			_product = product;

			txtProductName.Text = _product.Name;
			txtProductDescription.Text = _product.Description;
		}
		public LicenseSetFeaturesWindow(Window parent, Product product, LicenseSet licenseSet)
			: this(parent)
		{
			_licenseSet = licenseSet;
			_product = product;
			gridProductFeatures.ItemsSource = new ObservableCollection<Feature>(ObjectLocator.GetInstance<IFeaturesService>().GetFeaturesForProduct(_product.ProductId));

			lblTitle.Text = _product.Name + " - " + _licenseSet.Name;
		}
Пример #6
0
        public void SingleUserSetup()
        {
            License.Name = "UnitTest License";

            Product p = new Product();
            p.Name = "UnitTest Product";
            p.Description = "Just a product for unit testing";

            License.LicenseId = 1;
            License.Product = p;
            License.KeyGeneratorType = KeyGeneratorTypes.StaticSmall;

            LicenseTrialSettings ts = new LicenseTrialSettings();
            ts.ExpirationOptions = TrialExpirationOptions.Days;
            ts.ExpirationData = "30";

            License.TrialSettings = ts;

            LicenseSet ls = new LicenseSet();
            ls.LicenseId = 1;
            ls.LicenseSetId = 1;
            ls.Name = "Unit Test License Set";
            ls.MaxUsers = 5;
            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser;

            License.LicenseSets = new NotifyList<LicenseSet>();
            License.LicenseSets.Add(ls);

            CreateFile(new ClientLicense(License));
        }
Пример #7
0
        public void InvalidTrialSetup()
        {
            License.Name = "UnitTest License";

            Product p = new Product();
            p.Name = "UnitTest Product";
            p.Description = "Just a product for unit testing";

            License.LicenseId = 1;
            License.Product = p;
            License.KeyGeneratorType = KeyGeneratorTypes.StaticSmall;

            LicenseTrialSettings ts = new LicenseTrialSettings();
            ts.ExpirationOptions = TrialExpirationOptions.Days;
            ts.ExpirationData = "30";

            License.TrialSettings = ts;

            LicenseSet ls = new LicenseSet();
            ls.LicenseId = 1;
            ls.LicenseSetId = 1;
            ls.Name = "Unit Test License Set";
            ls.MaxUsers = 5;
            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.Enterprise;

            License.LicenseSets = new NotifyList<LicenseSet>();
            License.LicenseSets.Add(ls);

            ClientLicense lic2 = new ClientLicense(License);
            lic2.RunCount = 10;
            lic2.LastRun = DateTime.Now.AddMonths(12);
            lic2.FirstRun = DateTime.Now.AddMonths(24);

            CreateFile(lic2);
        }
Пример #8
0
		public bool Equals(Product other)
		{
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			return Equals(other._uniquePad, _uniquePad) && Equals(other._description, _description) && Equals(other._name, _name) && other._productId == _productId;
		}