private bool CreateNewProduct(NewProductSagaData sagaData, IMessageHandlerContext context)
        {
            try
            {
                if (sagaData.HasName && sagaData.HasName && sagaData.HasPrice)
                {
                    LOG.Info($"Saga is complete.");
                    LOG.Info($"Creating a new prroduct '{sagaData}'");

                    ProductsCatalog catalog = new ProductsCatalog(productStorage);

                    Product product = new Product(sagaData.Name, sagaData.Description, sagaData.Price.Value);
                    catalog.AddNewProduct(product);

                    LOG.Info($"Product created");
                    return(true);
                }

                LOG.Info($"Saga is not complete yet '{sagaData}'");
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public XmlCatalogCreator(int catalogId)
 {
     _catalog          = new ProductsCatalog();
     _catalog.Id       = catalogId;
     _catalog.Version  = Config.CatalogVersion;
     _catalog.Products = new List <Product>();
 }
        public Task Handle(NewProductSimpleEvent message, IMessageHandlerContext context)
        {
            LOG.Info($"Incomimng {message}");

            ProductsCatalog catalog = new ProductsCatalog(productStorage);

            //catalog.AddNewProduct(new Product(message.Name, message.Description, message.Price));

            return(Task.CompletedTask);
        }
Esempio n. 4
0
        public static void CreateInAppTestConfig(ProductsCatalog catalog)
        {
            ServiceLocator.Logger.Log(LogLevel.Info, "In app test config generation...");

            try
            {
                XNamespace xml = XNamespace.Xml;

                XElement rootElement = new XElement("CurrentApp");

                XElement listingInformationElement = new XElement("ListingInformation",
                                                                  new XElement("App",
                                                                               new XElement("AppId", "00000000-0000-0000-0000-000000000000"),
                                                                               new XElement("LinkUri", "http://apps.microsoft.com/webpdp/app/00000000-0000-0000-0000-000000000000"),
                                                                               new XElement("CurrentMarket", "en-US"),
                                                                               new XElement("AgeRating", "3"),
                                                                               new XElement("MarketData", new XAttribute(xml + "lang", "en-us"),
                                                                                            new XElement("Name", "AppName"),
                                                                                            new XElement("Description", "AppDescription"),
                                                                                            new XElement("Price", "42.00"),
                                                                                            new XElement("CurrencySymbol", "$"),
                                                                                            new XElement("CurrencyCode", "USD"))));

                foreach (Product product in catalog.Products)
                {
                    listingInformationElement.Add(new XElement("Product",
                                                               new XAttribute("ProductId", product.Id),
                                                               new XAttribute("LicenseDuration", "0"),
                                                               new XAttribute("ProductType", "Durable"),
                                                               new XElement("MarketData", new XAttribute(xml + "lang", "en-us"),
                                                                            new XElement("Name", product.Id),
                                                                            new XElement("Price", "42.00"),
                                                                            new XElement("CurrencySymbol", "$"),
                                                                            new XElement("CurrencyCode", "USD"))));
                }

                XElement licenseInformationElement = new XElement("LicenseInformation",
                                                                  new XElement("App",
                                                                               new XElement("IsActive", "true"),
                                                                               new XElement("IsTrial", "false")));

                rootElement.Add(listingInformationElement);
                rootElement.Add(licenseInformationElement);

                File.WriteAllText(Config.InAppTestConfigFile, rootElement.ToString());

                ServiceLocator.Logger.Log(LogLevel.Info, "Done.");
            }
            catch (Exception ex)
            {
                ServiceLocator.Logger.Log(LogLevel.Warning, string.Format("Failed to generate InApp test config.\n{0}", ex));
            }
        }
Esempio n. 5
0
        public ProductsCatalog CreateCatalog(int catalogId)
        {
            _catalogId = catalogId;

            ServiceLocator.Logger.Log(LogLevel.Info, "Start catalog generation...");

            RequestPdahpcCatalogs();
            SavePdahpcCatalogs();
            ProductsCatalog catalog = GenerateCatalog();

            ServiceLocator.Logger.Log(LogLevel.Info, string.Format("Catalog generation completed, {0} products.", catalog.Products.Count));

            return(catalog);
        }