Exemple #1
0
        public static async Task AddNewProduct()
        {
            Console.WriteLine("Adding New Product");
            Console.WriteLine("=============================");

            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Description: ");
            string description = Console.ReadLine();

            Console.Write("Category: ");
            string category = Console.ReadLine();

            var product = new Product
            {
                Name        = name,
                Description = description,
                Category    = category
            };

            await _store.Add(product);

            await _publisher.Publish(product);
        }
Exemple #2
0
 private static async Task ProductsOnMessageConsumed(Message <Null, Product> message)
 {
     await _store.Add(new StorageProduct
     {
         MarketingId   = ObjectId.Parse(message.Value.MarketingId),
         Name          = message.Value.Name,
         Available     = 0,
         Manufacturing = 0
     });
 }
 private static async Task ProductsOnOnMessageConsumed(Message <Null, Product> message)
 {
     await _store.Add(new StorageProduct
     {
         Name          = message.Value.Name,
         Description   = message.Value.Description,
         Category      = message.Value.Category,
         DevelopmentId = message.Value.Id,
     });
 }
        private static async Task ProductsOnMessageConsumed(Message <Null, Product> message)
        {
            var product =
                await _store.Get <StorageProduct>(p => p.MarketingId == ObjectId.Parse(message.Value.MarketingId));

            if (product == null)
            {
                await _store.Add(new StorageProduct
                {
                    MarketingId = ObjectId.Parse(message.Value.MarketingId),
                    Name        = message.Value.Name,
                    Description = message.Value.Description,
                    Skus        = message.Value.Skus
                });
            }
            else
            {
                await _store.Update(f => f.MarketingId == ObjectId.Parse(message.Value.MarketingId),
                                    Builders <StorageProduct> .Update
                                    .Set(f => f.Name, message.Value.Name)
                                    .Set(f => f.Description, message.Value.Description)
                                    .Set(f => f.Skus, message.Value.Skus));
            }
        }