Ejemplo n.º 1
0
        internal void run()
        {
            ProductCatalog catalog = new ProductCatalog()
            {
                Languages      = { LanguageCodes.DEU },
                CatalogId      = "QA_CAT_002",
                CatalogVersion = "001.002",
                CatalogName    = "Office Material",
                GenerationDate = new System.DateTime(2004, 8, 20, 10, 59, 54),
                Currency       = CurrencyCodes.EUR
            };

            catalog.Products.Add(new Product()
            {
                No               = "Q20-P09",
                EANCode          = "0000000011",
                Currency         = CurrencyCodes.EUR,
                NetPrice         = 16.49m,
                DescriptionShort = "Post-Safe Polythene Envelopes Deutsch",
                DescriptionLong  = "Deutsch All-weather lightweight envelopes protect your contents and save you money. ALL - WEATHER.Once sealed, Post-Safe envelopes are completely waterproof.Your contents won't get damaged.",
                Stock            = 100,
                VAT              = 19
            });


            catalog.Save("test.xml");
        }
 public OrderCreationUseCaseTest()
 {
     food = new Category
     {
         Name          = "food",
         TaxPercentage = 10M
     };
     orderRepository = new TestOrderRepository();
     productCatalog  = new InMemoryProductCatalog(
         new List <Product>
     {
         new Product
         {
             Name     = "salad",
             Price    = 3.56M,
             Category = food,
         },
         new Product
         {
             Name     = "tomato",
             Price    = 4.65M,
             Category = food
         }
     }
         );
     useCase = new OrderCreationUseCase(orderRepository, productCatalog);
 }
Ejemplo n.º 3
0
        public void When_I_generate_a_receipt_with_quantity_discount()
        {
            var sut            = new ReceiptGenerator();
            var productCatalog = new ProductCatalog();

            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            productCatalog.AddQuantityDiscount("apple", 3, 2.00m);
            var transaction = new CheckoutTransaction(productCatalog, new Promotions(new List <IPromotionalDiscountRule>()
            {
                new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)
            }));

            transaction.AddItem("apple");
            transaction.AddItem("banana");
            transaction.AddItem("apple");
            transaction.AddItem("apple");
            transaction.AddItem("apple");
            transaction.AddItem("apple");
            transaction.AddItem("apple");
            transaction.AddItem("apple");

            var actual = sut.Generate(transaction);

            Assert.That(actual, Is.EqualTo("Receipt:\n7 apple @ $0.75 is $5.25\n***Discount on apple: Buy 3 apple for $2.00, New Price $4.75, Savings $0.50\n1 banana @ $1.00 is $1.00\nTotal is $5.75"));
        }
        private void CreateShoes(ProductCatalog catalog)
        {
            var shoes = CreateCatalogCategory(catalog, "Shoes", "F161B9C5-BC86-43CD-8350-880DB938A288");

            var shoeDefinition = GetProductDefinition("Shoe");

            var hiking = CreateProductOnCategory(shoes, shoeDefinition, "074617", "Paraboot Avoriaz/Jannu Marron Brut Marron Brown Hiking Boot Shoes", 343.85M, "DE2C86A7-C38F-4445-9598-07EB104E45BE", "", "<ul><li>Paraboot Avoriaz Mountaineering Boots</li><li>Marron Brut Marron (Brown)</li><li>Full leather inners and uppers</li><li>Norwegien Welted Commando Sole</li><li>Hand made in France</li><li>Style number : 074617</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-avoriaz-jannu-marron-brut-brown-20879.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(hiking, new List <string>()
            {
                "6", "8", "10"
            });
            AddProductProperty(hiking, "ShowOnHomepage", "true");
            hiking.Guid = new Guid("1B27B4B8-C9C2-4CFE-B37A-2CCD86F9CBBB");
            hiking.Save();

            var marron = CreateProductOnCategory(shoes, shoeDefinition, "710708", "Paraboot Chambord Tex Marron Lis Marron Brown Shoes", 281.75M, "A9B7C1EF-6156-4772-AB24-DD8BD4E49328", "", "<ul><li>Style : Chambord Tex</li><li>Colour : Marron Lis Marron</li><li>Paraboot style code : 710708</li><li>Estimated delivery time : 1 - 4 weeks</li><li>Customers ordering from outside the EU will receive a 20% VAT discount on their order. This is applied at checkout once you have given your delivery details.</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-order-chambord-marron-brown-shoes-20709.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(marron, new List <string>()
            {
                "6", "8", "10"
            });

            var brown = CreateProductOnCategory(shoes, shoeDefinition, "710707", "Paraboot Chambord Tex Marron Lis Cafe Brown Shoes", 281.75M, "CF3E318F-1AA9-4B3B-A902-8616529CC2B2", "", "<ul><li>Style : Chambord Tex</li><li>Colour : Marron Lis Cafe</li><li>Paraboot style code : 710707</li><li>Estimated delivery time : 1 - 4 weeks</li><li>Customers ordering from outside the EU will receive a 20% VAT discount on their order. This is applied at checkout once you have given your delivery details.</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-order-chambord-marron-cafe-brown-18606.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(brown, new List <string>()
            {
                "6", "8", "10", "12"
            });
        }
Ejemplo n.º 5
0
        private static void Constantize()
        {
            try {
                var builder = new StringBuilder();
                builder.AppendLine("/// <summary>");
                builder.AppendLine("/// IAPのProductIDを定数として保持するクラス");
                builder.AppendLine("/// </summary>");
                builder.AppendLine("public static class IAPProductID {");

                var catalog = ProductCatalog.LoadDefaultCatalog();
                foreach (var product in catalog.allProducts)
                {
                    var name = RemoveInvalidChars(product.id.Replace(".", "_")).ToUpper();
                    builder.Append("\t").AppendFormat(@"public const string {0} = ""{1}"";", name, product.id).AppendLine();
                }

                builder.AppendLine("}");

                var directoryName = Path.GetDirectoryName(_path);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }

                File.WriteAllText(_path, builder.ToString(), Encoding.UTF8);
                AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
            } catch (Exception e) {
                Debug.LogException(e);
            }
        }
Ejemplo n.º 6
0
    private void InitIAP()
    {
        var module = StandardPurchasingModule.Instance();
        ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

        var catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (var product in catalog.allValidProducts)
        {
            if (product.allStoreIDs.Count > 0)
            {
                var ids = new IDs();
                foreach (var storeID in product.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(product.id, product.type, ids);
            }
            else
            {
                builder.AddProduct(product.id, product.type);
            }
        }


        UnityPurchasing.Initialize(this, builder);
    }
Ejemplo n.º 7
0
        public async void UpdateProductCatalog_AtInitializedDbTable_UpdatedProductCatalogEqualExpectedProductCatalog()
        {
            // arrange
            var product = GetProductCatalog();

            fixture.db.Add(product);
            await fixture.db.SaveChangesAsync();

            var expected = new ProductCatalog
            {
                Id              = product.Id,
                Cas             = 4040404,
                LicenseRequired = true,
                Name            = "Testedtin"
            };

            // act
            await logic.UpdateDataModelAsync(expected);

            // assert
            var actual = await fixture.db.ProductCatalog.FirstOrDefaultAsync(i => i.Id == expected.Id);

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Cas, actual.Cas);
            Assert.Equal(expected.LicenseRequired, actual.LicenseRequired);
            Assert.Equal(expected.Name, actual.Name);
        }
Ejemplo n.º 8
0
        private async Task ProcessCustomerChoice(string entity)
        {
            if (!string.IsNullOrEmpty(entity))
            {
                // cancel pending prompts
                this.allowSendingOffMsg = false;
                // route customer
                string direction = ProductCatalog.GetDirectionFromLuisEntity(entity);

                if (direction == "left")
                {
                    if (this.ViewModel.Update(DemoScreenState.LeftSelected))
                    {
                        await SpeakWithDelay(this.ViewModel.CustomerPrompt);
                    }
                }
                else if (direction == "right")
                {
                    if (this.ViewModel.Update(DemoScreenState.RightSelected))
                    {
                        await SpeakWithDelay(this.ViewModel.CustomerPrompt);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public IActionResult Post([FromBody] ProductCatalog productcatalog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (productcatalog.Id == 0)
            {
                var resultValidationCatalog = this._productcatalogservices.existCatalog(productcatalog);

                if (resultValidationCatalog != "OK")
                {
                    this.ModelState.AddModelError("400", resultValidationCatalog);
                    return(BadRequest(this.ModelState));
                }

                _productcatalogservices.createProductCatalog(productcatalog);
            }
            else
            {
                _productcatalogservices.updateProductCatalog(productcatalog);
            }

            return(Ok(productcatalog));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Update product from catalog.
        /// </summary>
        /// <param name="model">Updated product from catalog information</param>
        public async Task UpdateDataModelAsync(ProductCatalog model)
        {
            var currentModel = await db.ProductCatalog.FirstOrDefaultAsync(i => i.Id == model.Id);

            db.Entry(currentModel).CurrentValues.SetValues(model);
            await db.SaveChangesAsync();
        }
Ejemplo n.º 11
0
        public void ShouldGetProductsFeed()
        {
            ProductCatalog catalog = new ProductCatalog(
                new InMemoryProductRepository(
                    new List <Product> {
                new Product {
                    Id = "1", Category = "foo", Name = "Foo1", UnitPrice = 1
                },
                new Product {
                    Id = "2", Category = "bar", Name = "bar2", UnitPrice = 2
                }
            }));

            Mock <IWebOperationContext> mockContext = new Mock <IWebOperationContext>
            {
                DefaultValue = DefaultValue.Mock
            };

            IEnumerable <SyndicationItem> items;

            using (new MockedWebOperationContext(mockContext.Object))
            {
                var formatter = catalog.GetProducts("foo");
                items = formatter.Feed.Items;
            }

            mockContext.VerifySet(c => c.OutgoingResponse.ContentType, "application/atom+xml");

            Assert.AreEqual(1, items.Count());
            Assert.IsTrue(items.Any(i => i.Id == "http://products/1" && i.Title.Text == "Foo1"));
        }
Ejemplo n.º 12
0
        private void ProcessCatalog()
        {
            _project = (from project in CurrentDb.Projects where project.ID == _args.ProjectId select project).First();
            var aryaUser             = CurrentDb.Users.First(u => u.ID == _project.CreatedBy);
            var lastUpdatedTimestamp = TimestampRecordType.FromValues(_project.CreatedOn,
                                                                      User.FromAryaUser(aryaUser));

            CurrentLogWriter.Debug("Processing " + _project);
            _productCatalog = new ProductCatalog
            {
                Id                  = _project.ID,
                Company             = _project.ClientDescription,
                Type                = "STANDARD",
                ProductCatalogNames =
                    ProductCatalogProductCatalogName.FromName(_project.SetName),
                TaxonomyMetaDataLanguageVersionss =
                    ProductCatalogTaxonomyMetaDataLanguageVersions.FromAryaProject(
                        _project),
                SchemaMetaDataLanguageVersionss =
                    ProductCatalogSchemaMetaDataLanguageVersions.FromAryaProject(
                        _project),
                LastUpdatedTimestamp = lastUpdatedTimestamp
            };

            var taxonomyNode = TaxonomyNode.FromValues(_project.CreatedOn, _project.ID, _project.ToString(),
                                                       Guid.Empty, _project.ID);

            taxonomyNode.IsRoot = true;
            taxonomyNode.SerializeObject(GetSaveFilePath("Node", _project.ID.ToString()));

            _productCatalog.SerializeObject(GetSaveFilePath("Catalog", _productCatalog.Id.ToString()));

            ProcessTaxonomyNodes();
        }
        private Category CreateCatalogCategory(ProductCatalog catalog, string name)
        {
            var category = CreateCategory(catalog, name);

            catalog.AddCategory(category);
            return(category);
        }
        private void CreateShoes(ProductCatalog catalog)
        {
            var shoes = CreateCatalogCategory(catalog, "Shoes");

            var shoeDefinition = GetProductDefinition("Shoe");

            var hiking = CreateProductOnCategory(shoes, shoeDefinition, "074617",
                                                 "Paraboot Avoriaz/Jannu Marron Brut Marron Brown Hiking Boot Shoes", 343.85M, "",
                                                 "<ul><li>Paraboot Avoriaz Mountaineering Boots</li><li>Marron Brut Marron (Brown)</li><li>Full leather inners and uppers</li><li>Norwegien Welted Commando Sole</li><li>Hand made in France</li><li>Style number : 074617</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-avoriaz-jannu-marron-brut-brown-20879.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(hiking, new List <string>()
            {
                "6", "8", "10"
            });
            AddProductProperty(hiking, "ShowOnHomepage", "true");
            hiking.Save();

            var marron = CreateProductOnCategory(shoes, shoeDefinition, "710708",
                                                 "Paraboot Chambord Tex Marron Lis Marron Brown Shoes", 281.75M, "",
                                                 "<ul><li>Style : Chambord Tex</li><li>Colour : Marron Lis Marron</li><li>Paraboot style code : 710708</li><li>Estimated delivery time : 1 - 4 weeks</li><li>Customers ordering from outside the EU will receive a 20% VAT discount on their order. This is applied at checkout once you have given your delivery details.</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-order-chambord-marron-brown-shoes-20709.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(marron, new List <string>()
            {
                "6", "8", "10"
            });

            var brown = CreateProductOnCategory(shoes, shoeDefinition, "710707",
                                                "Paraboot Chambord Tex Marron Lis Cafe Brown Shoes", 281.75M, "",
                                                "<ul><li>Style : Chambord Tex</li><li>Colour : Marron Lis Cafe</li><li>Paraboot style code : 710707</li><li>Estimated delivery time : 1 - 4 weeks</li><li>Customers ordering from outside the EU will receive a 20% VAT discount on their order. This is applied at checkout once you have given your delivery details.</li></ul><p>As featured on <a href=\"http://www.pritchards.co.uk/shoes-trainers-11/paraboot-order-chambord-marron-cafe-brown-18606.htm\">Pritchards.co.uk</a></p>");

            AddShoeVariantsToProduct(brown, new List <string>()
            {
                "6", "8", "10", "12"
            });
        }
Ejemplo n.º 15
0
        public void InitializePurchasing()
        {
            // If we have already connected to Purchasing ...
            if (IsInitialized())
            {
                // ... we are done here.
                return;
            }

            // Create a builder, first passing in a suite of Unity provided stores.
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            var catalog = ProductCatalog.LoadDefaultCatalog();

            builder = AddProducts(builder, catalog);

            // Add a product to sell / restore by way of its identifier, associating the general identifier
            // with its store-specific identifiers.
            //builder.AddProduct(kProductIDConsumable, ProductType.Consumable);
            // Continue adding the non-consumable product.
            //builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable);
            // And finish adding the subscription product. Notice this uses store-specific IDs, illustrating
            // if the Product ID was configured differently between Apple and Google stores. Also note that
            // one uses the general kProductIDSubscription handle inside the game - the store-specific IDs
            // must only be referenced here.
            //builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
            //    { kProductNameAppleSubscription, AppleAppStore.Name },
            //    { kProductNameGooglePlaySubscription, GooglePlay.Name },
            //});

            // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
            // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
            UnityPurchasing.Initialize(this, builder);
        }
            private StoreManager()
            {
                catalog = ProductCatalog.LoadDefaultCatalog();

                StandardPurchasingModule module = StandardPurchasingModule.Instance();

                module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

                ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

                foreach (var product in catalog.allProducts)
                {
                    if (product.allStoreIDs.Count > 0)
                    {
                        var ids = new IDs();
                        foreach (var storeID in product.allStoreIDs)
                        {
                            ids.Add(storeID.id, storeID.store);
                        }
                        builder.AddProduct(product.id, product.type, ids);
                    }
                    else
                    {
                        builder.AddProduct(product.id, product.type);
                    }
                }
                UnityPurchasing.Initialize(this, builder);
            }
Ejemplo n.º 17
0
            private static async Task <IDictionary <long, MediaLocation> > GetMediaLocationDictionary(EcommerceContext ecommerceContext, IEnumerable <long> productIds, IEnumerable <ProductCatalog> catalogs)
            {
                long channelId = await Utilities.GetChannelId(ecommerceContext);

                var             distinctProductIds = productIds.Distinct();
                ManagerFactory  managerFactory     = Utilities.GetManagerFactory(ecommerceContext);
                IProductManager productManager     = managerFactory.GetManager <IProductManager>();

                IDictionary <long, MediaLocation> mediaLocationDictionary = new Dictionary <long, MediaLocation>();
                QueryResultSettings queryResultSettings = new QueryResultSettings()
                {
                    Paging = new PagingInfo()
                    {
                        Skip = 0, Top = 1
                    }
                };

                ProductCatalog firstCatalog = catalogs.FirstOrDefault();
                long           catalogId    = (firstCatalog == null) ? 0 : firstCatalog.RecordId;

                foreach (var productId in distinctProductIds)
                {
                    PagedResult <MediaLocation> mediaLocations = await productManager.GetMediaLocations(productId, channelId, catalogId, queryResultSettings : queryResultSettings);

                    if (mediaLocations.Any())
                    {
                        mediaLocationDictionary.Add(productId, mediaLocations.First());
                    }
                }

                return(mediaLocationDictionary);
            }
        public void When_checkout_transaction_is_created()
        {
            var productCatalog = new ProductCatalog();
            var sut = new CheckoutTransaction(productCatalog, new Promotions(new List<IPromotionalDiscountRule>()));

            Assert.That(sut.Bill.Total, Is.EqualTo(0));
        }
Ejemplo n.º 19
0
        public void When_checkout_transaction_is_created()
        {
            var productCatalog = new ProductCatalog();
            var sut            = new CheckoutTransaction(productCatalog, new Promotions(new List <IPromotionalDiscountRule>()));

            Assert.That(sut.Bill.Total, Is.EqualTo(0));
        }
        internal void AddDataFromCatalog(ProductCatalog catalog, FieldList list, VersionUri version)
        {
            if (catalog == null)
            {
                return;
            }

            list.SafeAdd(FieldIDs.Security, GetSecurityPermisionsFor(catalog));
            list.SafeAdd(FieldIds.Catalog.NameFieldId, catalog.Name);
            list.SafeAdd(FieldIds.Catalog.CatalogIdFieldId, catalog.ProductCatalogId.ToString());
            list.SafeAdd(FieldIds.Catalog.ShowPricesWithVatId, catalog.ShowPricesIncludingVAT.ToSitecoreFormat());
            list.SafeAdd(FieldIds.Catalog.DefaultPriceGroupId, catalog.PriceGroup.SitecoreId().ToString());
            list.SafeAdd(FieldIDs.Revision, catalog.Guid.Derived(catalog.ModifiedOn).ToString());

            var description = catalog.GetDescription(version.Language.Name);

            if (description != null)
            {
                list.SafeAdd(FieldIds.Catalog.DisplayNameFieldId, description.DisplayName);
            }

            var allowedPriceGroupIds = catalog.AllowedPriceGroups.ToList().Select(x => x.PriceGroupId).ToList();

            foreach (var priceGroupId in _priceGroupIdToFieldIdMap.Keys)
            {
                list.SafeAdd(_priceGroupIdToFieldIdMap[priceGroupId],
                             allowedPriceGroupIds.Contains(priceGroupId) ? true.ToSitecoreFormat() : false.ToSitecoreFormat());
            }
        }
        public async Task <int> CreateProductCatalogAsync(CreateProductCatalogCommand command, CancellationToken cancellationToken)
        {
            var productCatalog = new ProductCatalog
            {
                Code  = command.Code,
                Name  = command.Name,
                Photo = command.Photo,
                Price = command.Price
            };

            _dbContext.ProductCatalogs.Add(productCatalog);

            try
            {
                await _dbContext.SaveChangesAsync(cancellationToken);
            }
            //The table can have more than one uniqe index
            //in this case we must know where the exception cames from.
            //catch (Exception ex) when (ex.Message.Contains(ProductCatalogConstants.ProductCatalogCodeIndexName)
            //    || (ex.InnerException != null && ex.InnerException.Message.Contains(ProductCatalogConstants.ProductCatalogCodeIndexName)))
            //{
            //    throw new CodeExistsException(nameof(ProductCatalog), command.Code);
            //}

            catch (DbUpdateException ex)
            {
                throw new CodeExistsException(nameof(ProductCatalog), command.Code);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(productCatalog.Id);
        }
Ejemplo n.º 22
0
            private IAPButtonStoreManager()
            {
                catalog = ProductCatalog.LoadDefaultCatalog();

                StandardPurchasingModule module = StandardPurchasingModule.Instance();

                module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

                ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

                //This seems to be outdated/unneeded, the value should be set in unity services
                //builder.Configure<IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2O/9/H7jYjOsLFT/uSy3ZEk5KaNg1xx60RN7yWJaoQZ7qMeLy4hsVB3IpgMXgiYFiKELkBaUEkObiPDlCxcHnWVlhnzJBvTfeCPrYNVOOSJFZrXdotp5L0iS2NVHjnllM+HA1M0W2eSNjdYzdLmZl1bxTpXa4th+dVli9lZu7B7C2ly79i/hGTmvaClzPBNyX+Rtj7Bmo336zh2lYbRdpD5glozUq+10u91PMDPH+jqhx10eyZpiapr8dFqXl5diMiobknw9CgcjxqMTVBQHK6hS0qYKPmUDONquJn280fBs1PTeA6NMG03gb9FLESKFclcuEZtvM8ZwMMRxSLA9GwIDAQAB");

                foreach (var product in catalog.allProducts)
                {
                    if (product.allStoreIDs.Count > 0)
                    {
                        var ids = new IDs();
                        foreach (var storeID in product.allStoreIDs)
                        {
                            ids.Add(storeID.id, storeID.store);
                        }
                        builder.AddProduct(product.id, product.type, ids);
                    }
                    else
                    {
                        builder.AddProduct(product.id, product.type);
                    }
                }
                                #if RECEIPT_VALIDATION
                validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.bundleIdentifier);
                                #endif
                UnityPurchasing.Initialize(this, builder);
            }
 public void CatalogSaved(ProductCatalog catalog)
 {
     foreach (var provider in _providers)
     {
         provider.CatalogSaved(catalog);
     }
 }
Ejemplo n.º 24
0
        public ActionResult Create([Bind(Include = "Code, Description, ProductsViewModel")] CatalogViewModel catalog)
        {
            if (ModelState.IsValid)
            {
                _unitOfWork.CatalogManager.CreateCatalog(new Catalog
                {
                    Code        = catalog.Code,
                    Description = catalog.Description
                });


                foreach (var p in catalog.ProductsViewModel)
                {
                    if (p.IsSelected)
                    {
                        var productCatalog = new ProductCatalog();
                        productCatalog.CatalogId = catalog.CatalogId;
                        productCatalog.ProductId = p.ProductId;
                        _unitOfWork.ProductCatalogManager.AddProductCatalog(productCatalog);
                    }
                }
                _unitOfWork.Save();

                return(RedirectToAction("Index", "Catalog"));
            }

            return(View(catalog));
        }
Ejemplo n.º 25
0
        // Constructor
        public ShoppingCartVM()
        {
            // Pri prvom kreiranju korisnik je gost
            UserVM = new UserVM();

            ShoppingCart  = new ShoppingCart();
            ShopCatalogue = new ObservableCollection <ShoppingCartItem>();

            var lista = ProductCatalog.getAllProducts();

            foreach (Product p in lista)
            {
                ShopCatalogue.Add(new ShoppingCartItem()
                {
                    Product = p, Quantity = 1
                });
            }

            NavigationService = new NavigationService();

            ProductFilter = "";

            // prvi param je akcija, drugi je validaciona rutina
            ShowProductDetails = new RelayCommand(showDetails, canShowDetails);
            RemoveFromCart     = new RelayCommand(removeItemFromCart, canBeRemoved);
        }
Ejemplo n.º 26
0
        public ActionResult Index()
        {
            //Начальная инициализация
            vwWallet = new VMWallet(new Dictionary <FaceValueTypes, int> {
                { FaceValueTypes.One, 100 },
                { FaceValueTypes.Two, 100 },
                { FaceValueTypes.Five, 100 },
                { FaceValueTypes.Ten, 100 }
            });

            userWallet = new Wallet(new Dictionary <FaceValueTypes, int>
            {
                { FaceValueTypes.One, 10 },
                { FaceValueTypes.Two, 30 },
                { FaceValueTypes.Five, 20 },
                { FaceValueTypes.Ten, 15 }
            });

            productCatalog = new ProductCatalog(new Dictionary <ProductTypes, int>
            {
                { ProductTypes.Tea, 10 },
                { ProductTypes.Coffee, 20 },
                { ProductTypes.MilkCoffee, 20 },
                { ProductTypes.Juice, 15 }
            });

            return(View());
        }
Ejemplo n.º 27
0
        private static void CopyFiles(ProductCatalog product, IEnumerable <FileInfo> newDependencyFiles, string filesLocation)
        {
            var typeName = Enum.GetName(typeof(ApplicationType), product.ApplicationType);

            if (typeName == null)
            {
                throw new InvalidOperationException();
            }
            var path      = Path.Combine(filesLocation, typeName);
            var directory = new DirectoryInfo(path);

            Directory.CreateDirectory(path);

            foreach (var file in directory.GetFiles())
            {
                if (file.Name.Equals(".gitkeep"))
                {
                    continue;
                }
                if (!product.Dependencies.Any(x => x.Name.Equals(file.Name)))
                {
                    Logger.Warn($"Deleting '{file.Name}' because it was not present in the product catalog");
                    file.Delete();
                }
            }

            foreach (var newFile in newDependencyFiles)
            {
                Logger.Debug($"Copying file '{newFile.Name}' to location {directory.FullName}");
                newFile.CopyTo(Path.Combine(directory.FullName, newFile.Name), true);
            }
        }
        public bool SaveItem(ITreeNodeContent node, ItemChanges changes)
        {
            if (!changes.HasFieldsChanged)
            {
                return(false);
            }

            var catalog = ProductCatalog.Get(Convert.ToInt32(node.ItemId));

            if (catalog == null)
            {
                var message = string.Format("Product Catalog with id: {0} not found for ITreeNodeContent. ", node.ItemId);
                _loggingService.Debug <ProductCatalogTemplateBuilder>(message);
                throw new InvalidDataException(message);
            }

            foreach (FieldChange change in changes.FieldChanges)
            {
                UpdateCatalogValuesFor(change, catalog);
            }

            ObjectFactory.Instance.Resolve <IPipeline <ProductCatalog> >("SaveProductCatalog").Execute(catalog);

            return(true);
        }
Ejemplo n.º 29
0
        public static async Task CreateProducts(ApplicationDbContext context)
        {
            for (int i = 0; i < 20; i++)
            {
                Product product = new Product()
                {
                    Slug        = "product-" + i,
                    Title       = "Product " + i,
                    Text        = "",
                    Description = "",
                    Price       = 200,
                    Currency    = 0,
                    Quantity    = 150,
                    ImageId     = null,
                    GalleryId   = null,
                    DateTime    = DateTime.Now
                };

                context.Add(product);

                await context.SaveChangesAsync();

                ProductCatalog productCatalog = new ProductCatalog()
                {
                    ProductId = product.Id,
                    CatalogId = 3
                };

                context.ProductsCatalogs.Add(productCatalog);

                await context.SaveChangesAsync();
            }
        }
        private string GetSecurityPermisionsFor(ProductCatalog catalog)
        {
            var valueBuilder = ObjectFactory.Instance.Resolve <ISecurityFieldValueBuilder>();
            var security     = valueBuilder.BuildSecurityValue(catalog);

            return(security);
        }
Ejemplo n.º 31
0
        public void SetUp()
        {
            orderRepository = new TestOrderRepository();
            food            = new Category();
            food.setName("food");
            food.setTaxPercentage(new BigDecimal(10));

            var salad = new Product();

            salad.setName("salad");
            salad.setPrice(new BigDecimal(3.56));
            salad.setCategory(food);

            var tomato = new Product();

            tomato.setName("tomato");
            tomato.setPrice(new BigDecimal(4.65));
            tomato.setCategory(food);

            productCatalog = new InMemoryProductCatalog(
                new List <Domain.Product>
            {
                salad, tomato
            });

            useCase = new OrderCreationUseCase(orderRepository, productCatalog);
        }
Ejemplo n.º 32
0
 public void Update(DbContext DbContext,ProductCatalog entity)
 {
     EntityState state = DbContext.Entry(entity).State;
        if (state == EntityState.Detached)
        {
       DbContext.Entry(entity).State = EntityState.Modified;
     }
 }
Ejemplo n.º 33
0
        public void When_quantity_discount_is_added()
        {
            var sut = new ProductCatalog();

            sut.AddQuantityDiscount("apple", 3, 2.00m);

            Assert.That(sut.QuantityDiscounts.Count(), Is.EqualTo(1));
            Assert.True(sut.QuantityDiscounts.First(p => p.Barcode == "apple").DiscountPrice == 2.00m);
            Assert.True(sut.QuantityDiscounts.First(p => p.Barcode == "apple").DiscountQuantity == 3.00m);
        }
Ejemplo n.º 34
0
        public void When_product_catalog_is_added_to()
        {
            var sut = new ProductCatalog();

            sut.AddProduct("apple", 0.75m);
            sut.AddProduct("banana", 1.00m);

            Assert.That(sut.Products.Count(), Is.EqualTo(2));
            Assert.True(sut.Products.First(p => p.Barcode == "apple").Price == 0.75m);
            Assert.True(sut.Products.First(p => p.Barcode == "banana").Price == 1.00m);
        }
Ejemplo n.º 35
0
        public void When_constructed_with_applicable_quantity_discount_but_no_matching_items()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            productCatalog.AddQuantityDiscount("apple", 2, 2.00m);
            var sut = new Bill(new List<string>() { "banana" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() { new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)}));

            Assert.That(sut.Total, Is.EqualTo(1.00m));
            Assert.That(sut.LineItems.Count(), Is.EqualTo(1));
        }
Ejemplo n.º 36
0
        public void When_additional_item_discount_is_added()
        {
            var sut = new ProductCatalog();

            sut.AddAdditionalItemDiscount("apple", 3, 2, 100);

            Assert.That(sut.QuantityDiscounts.Count(), Is.EqualTo(0));
            Assert.That(sut.AdditionalItemDiscounts.Count(), Is.EqualTo(1));
            Assert.True(sut.AdditionalItemDiscounts.First(p => p.Barcode == "apple").QuantityFullPrice == 3);
            Assert.True(sut.AdditionalItemDiscounts.First(p => p.Barcode == "apple").QuantityDiscounted == 2.00);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ProductCatalog pc = new ProductCatalog();

        pc.AddProduct("Radiation Blaster 3000", 150M, "microwave.jpg");
        pc.AddProduct("Fruit Ninja", 70M, "mixer.jpg");
        pc.AddProduct("Toasty Buns", 20M, "toaster.jpg");

        Response.Write(pc.GetCatalogHtml());

        TaxableProduct tp = (TaxableProduct)pc.GetHighPricedProduct();
        Response.Write("The high priced product is: " + tp.Name + " at a price of $" + tp.TotalPrice);
    }
        public void When_promotion_applies()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new AdditionalItemDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);
            
            var actual = sut.PromotionApplies(lineItem);

            Assert.That(actual, Is.True);
        }
        public void When_constructed()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            var sut = new LineItem("apple", 2, productCatalog, new Promotions(new List<IPromotionalDiscountRule>()));

            Assert.That(sut.Barcode, Is.EqualTo("apple"));
            Assert.That(sut.Quantity, Is.EqualTo(2));
            Assert.That(sut.PricePerUnit, Is.EqualTo(0.75m));
            Assert.That(sut.SubTotal, Is.EqualTo(1.50m));
            Assert.That(sut.DiscountNote, Is.EqualTo(""));
        }
Ejemplo n.º 40
0
        public void When_no_promotion_applies()
        {
            var rule = new Mock<IPromotionalDiscountRule>();
            rule.Setup(p => p.PromotionApplies(It.IsAny<LineItem>())).Returns(false);
            var sut = new Promotions(new List<IPromotionalDiscountRule>() { rule.Object });
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            var lineItem = new LineItem("apple", 7, productCatalog, sut);

            var actual = sut.CalculatePromotionalCost(lineItem);
            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(lineItem.SubTotal));
            Assert.That(actual.DiscountNote, Is.EqualTo(""));
        }
Ejemplo n.º 41
0
        public void When_constructed_with_applicable_additional_item_discount()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            var sut = new Bill(new List<string>() { "apple", "banana", "apple", "apple", "apple", "apple" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() {new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)}));

            Assert.That(sut.Total, Is.EqualTo(3.25m));
            Assert.That(sut.LineItems.Count(), Is.EqualTo(2));
            Assert.That(sut.LineItems.ElementAt(0).PricePerUnit, Is.EqualTo(0.75m));
            Assert.That(sut.LineItems.ElementAt(0).DiscountNote, Is.EqualTo("***Discount on apple: Buy 1 apple get 1 at $0.00, New Price $2.25, Savings $1.50"));
        }
        public void When_promotion_does_not_apply()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddQuantityDiscount("apple", 3, 2);
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1m);
            var sut = new QuantityDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("banana", 7, productCatalog, promotions);

            var actual = sut.PromotionApplies(lineItem);

            Assert.That(actual, Is.False);
        }
        public void When_add_some_items()
        {
            var expected = new List<string>() { "apple", "banana", "apple" };
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            var sut = new CheckoutTransaction(productCatalog, new Promotions(new List<IPromotionalDiscountRule>()));
            sut.AddItem("apple");
            sut.AddItem("banana");
            sut.AddItem("apple");

            Assert.That(sut.Bill.Total, Is.EqualTo(2.50m));
            CollectionAssert.AreEquivalent(expected, sut.Items);
        }
Ejemplo n.º 44
0
 public virtual OperationResult Create(ProductCatalogInfo info)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new MRPDbContext())
     {
       ProductCatalog entity = new ProductCatalog();
       DESwap.ProductCatalogDTE(info, entity);
       ProductCatalogRpt.Insert(DbContext, entity);
       DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
        public void When_calculating_rule()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new AdditionalItemDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);

            var actual = sut.Calculate(lineItem);

            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(3m));
            Assert.That(actual.DiscountNote, Is.EqualTo("***Discount on apple: Buy 1 apple get 1 at $0.00, New Price $3.00, Savings $2.25"));
        }
Ejemplo n.º 46
0
        public void When_constructed_with_some_items()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            var sut = new Bill(new List<string>() { "apple", "banana", "apple" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>()));

            Assert.That(sut.Total, Is.EqualTo(2.50m));
            Assert.That(sut.LineItems.Count(), Is.EqualTo(2));
            Assert.That(sut.LineItems.ElementAt(0).Barcode, Is.EqualTo("apple"));
            Assert.That(sut.LineItems.ElementAt(0).SubTotal, Is.EqualTo(1.50m));
            Assert.That(sut.LineItems.ElementAt(1).Barcode, Is.EqualTo("banana"));
            Assert.That(sut.LineItems.ElementAt(1).SubTotal, Is.EqualTo(1.00m));
        }
        public void When_calculating_rule()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddQuantityDiscount("apple", 3, 2);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new QuantityDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);

            var actual = sut.Calculate(lineItem);

            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(4.75m));
            Assert.That(actual.DiscountNote, Is.EqualTo("***Discount on apple: Buy 3 apple for $2.00, New Price $4.75, Savings $0.50"));
        }
        public void When_constructed_with_quantity_discount()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            productCatalog.AddQuantityDiscount("apple", 3, 2.00m);
            var sut = new LineItem("apple", 7, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() { new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog) }));

            Assert.That(sut.Barcode, Is.EqualTo("apple"));
            Assert.That(sut.Quantity, Is.EqualTo(7));
            Assert.That(sut.PricePerUnit, Is.EqualTo(0.75m));
            Assert.That(sut.SubTotal, Is.EqualTo(5.25m));
            Assert.That(sut.DiscountedSubTotal, Is.EqualTo(4.75m));
            Assert.That(sut.DiscountNote, Is.EqualTo("***Discount on apple: Buy 3 apple for $2.00, New Price $4.75, Savings $0.50"));
        }
        public void When_constructed_with_additional_item_discount()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1.00m);
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            var sut = new LineItem("apple", 5, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() { new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)}));

            Assert.That(sut.Barcode, Is.EqualTo("apple"));
            Assert.That(sut.Quantity, Is.EqualTo(5));
            Assert.That(sut.PricePerUnit, Is.EqualTo(0.75m));
            Assert.That(sut.SubTotal, Is.EqualTo(3.75m));
            Assert.That(sut.DiscountedSubTotal, Is.EqualTo(2.25m));
            Assert.That(sut.DiscountNote, Is.EqualTo("***Discount on apple: Buy 1 apple get 1 at $0.00, New Price $2.25, Savings $1.50"));
        }
Ejemplo n.º 50
0
 public virtual OperationResult Create(IEnumerable<ProductCatalogInfo> infoList)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     List<ProductCatalog> eList = new List<ProductCatalog>();
     infoList.ForEach(x =>
     {
         ProductCatalog entity = new ProductCatalog();
         DESwap. ProductCatalogDTE(x, entity);
         eList.Add(entity);
     });
     using (var DbContext = new MRPDbContext())
     {
     ProductCatalogRpt.Insert(DbContext, eList);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // populate a new catalog
        var catalog = new ProductCatalog();
        catalog.AddProduct("Nukulizer 1945", 39.99M, "microwave.jpg");
        catalog.AddProduct("Sir Mix-a-Lot", 599.99M, "mixer.jpg");
        catalog.AddProduct("The Cylon", 1.99M, "toaster.jpg");

        // write catalog to screen
        Response.Write(catalog.GetCatalogHtml());

        // write priciest product to screen AS a TaxableProduct
        TaxableProduct priceyProduct = catalog.GetHighPricedProduct() as TaxableProduct;

        if (priceyProduct != null)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(
                "<p>{0} is the most expensive product at {1:C} (including tax), {2:C} (excluding tax).</p>",
                priceyProduct.Name, priceyProduct.TotalPrice, priceyProduct.Price);
            Response.Write(builder.ToString());
        }
    }
Ejemplo n.º 52
0
        public ActionResult Index()
        {
            //Начальная инициализация
            vwWallet = new VMWallet(new Dictionary<FaceValueTypes, int>{
                {FaceValueTypes.One,100},
                {FaceValueTypes.Two,100},
                {FaceValueTypes.Five,100},
                {FaceValueTypes.Ten,100}
            });

            userWallet = new Wallet(new Dictionary<FaceValueTypes, int>
            {
                {FaceValueTypes.One,10},
                {FaceValueTypes.Two,30},
                {FaceValueTypes.Five,20},
                {FaceValueTypes.Ten,15}
            });

            productCatalog=new ProductCatalog(new Dictionary<ProductTypes,int>
                {
                    {ProductTypes.Tea,10},
                    {ProductTypes.Coffee,20},
                    {ProductTypes.MilkCoffee,20},
                    {ProductTypes.Juice,15}
                });

            return View();
        }
 public AdditionalItemDiscountRule(ProductCatalog productCatalog)
 {
     _productCatalog = productCatalog;
 }
Ejemplo n.º 54
0
 public void Save(ProductCatalog catalog)
 {
     _catalogs.Value.Save(catalog);
 }
Ejemplo n.º 55
0
        public void AssignCategoryToCatalog(string name, Definition definition, ProductCatalog catalog)
        {
            Category category = _categories.Value
                .SingleOrDefault(c => c.Name == name && c.ProductCatalog.Name == catalog.Name) ??
                new Category();

            category.Name = name;
            category.Definition = definition;
            category.Deleted = false;

            catalog.AddCategory(category);
            _catalogs.Value.Save(catalog);
        }
Ejemplo n.º 56
0
        public void When_product_catalog_is_created()
        {
            var sut = new ProductCatalog();

            Assert.That(sut.Products.Count(), Is.EqualTo(0));
        }
Ejemplo n.º 57
0
        public static void ProductCatalogETD(ProductCatalog entity, ProductCatalogInfo info)
        {
            info.Id = entity.Id;
               info._IdIsDirty = 0;

               info.ParentId = entity.ParentId;
               info._ParentIdIsDirty = 0;

               info.ProductCatalogCode = entity.ProductCatalogCode;
               info._ProductCatalogCodeIsDirty = 0;

               info.ProductCatalogName = entity.ProductCatalogName;
               info._ProductCatalogNameIsDirty = 0;

               info.SYS_OrderSeq = entity.SYS_OrderSeq;
               info._SYS_OrderSeqIsDirty = 0;

               info.SYS_IsValid = entity.SYS_IsValid;
               info._SYS_IsValidIsDirty = 0;

               info.SYS_IsDeleted = entity.SYS_IsDeleted;
               info._SYS_IsDeletedIsDirty = 0;

               info.SYS_Remark = entity.SYS_Remark;
               info._SYS_RemarkIsDirty = 0;

               info.SYS_StaffId = entity.SYS_StaffId;
               info._SYS_StaffIdIsDirty = 0;

               info.SYS_StationId = entity.SYS_StationId;
               info._SYS_StationIdIsDirty = 0;

               info.SYS_DepartmentId = entity.SYS_DepartmentId;
               info._SYS_DepartmentIdIsDirty = 0;

               info.SYS_CompanyId = entity.SYS_CompanyId;
               info._SYS_CompanyIdIsDirty = 0;

               info.SYS_AppId = entity.SYS_AppId;
               info._SYS_AppIdIsDirty = 0;

               info.SYS_CreateTime = entity.SYS_CreateTime;
               info._SYS_CreateTimeIsDirty = 0;

               info.SYS_ModifyTime = entity.SYS_ModifyTime;
               info._SYS_ModifyTimeIsDirty = 0;

               info.SYS_DeleteTime = entity.SYS_DeleteTime;
               info._SYS_DeleteTimeIsDirty = 0;
        }
Ejemplo n.º 58
0
 public void Insert(DbContext DbContext,ProductCatalog entity)
 {
     DbContext.Entry(entity).State = EntityState.Added;
 }
Ejemplo n.º 59
0
 public QuantityDiscountRule(ProductCatalog productCatalog)
 {
     _productCatalog = productCatalog;
 }
Ejemplo n.º 60
0
 public void Delete(DbContext DbContext,ProductCatalog  entity)
 {
     DbContext.Entry(entity).State = EntityState.Deleted;
 }