Exemplo n.º 1
0
        public void AddProductCatalogTests()
        {
            Product product = new Toy();

            product.Name  = "Barbie2";
            product.Count = 10;
            product.Price = 9999;
            product.Unit  = "Шт";
            productTestCatalog.Add(product);

            ///Проверка Get
            var product2 = productTestCatalog.Get(0);

            Assert.AreEqual(product2.Name, "Barbie2");
        }
        public Cart AddOrder(Guid productId, int qty)
        {
            var order = _orders.FirstOrDefault(i => i.Product.Id == productId);

            if (order != null)
            {
                order.Quantity += qty;
                CreateEvent(CartEventTypeEnum.OrderChanged, order);
            }
            else
            {
                var product = _catalog.Get(productId);
                if (product != null)
                {
                    order = new Order
                    {
                        Id       = Guid.NewGuid(),
                        Product  = product,
                        Quantity = qty
                    };

                    _orders.Add(order);
                    CreateEvent(CartEventTypeEnum.OrderAdded, order);
                }
            }

            return(Get());
        }
Exemplo n.º 3
0
 private IEnumerable <ProductOrdered> MapProducts(IEnumerable <SubmitOrderCommand.Product> products)
 {
     return(products
            .Select(product => new
     {
         Product = _catalog.Get(product.Id),
         product.Quantity
     })
            .Select(x => new ProductOrdered
     {
         Description = x.Product.Description,
         Price = x.Product.Price,
         Quantity = x.Quantity
     }));
 }
        private bool Init(string productTypeName)
        {
            try
            {
                product = productCatalog.Get(productTypeName);
            }
            catch (ArgumentException)
            {
                return(false);
            }

            var productType = product.GetType();

            productProperties = productType.GetProperties();
            Misc.SortProperties(productProperties, productType);
            propertyIndex = 0;
            initialized   = true;
            return(true);
        }
Exemplo n.º 5
0
        public object GetProducts()
        {
            var res = _catalog.Get();

            return(res);
        }