Пример #1
0
        /// <summary>
        /// Cancels the order.
        /// </summary>
        /// <param name="order">The order.</param>
        public override void CancelOrder(Order order)
        {
            ServiceClientArgs args = this.serviceClientArgsFactory.GetServiceClientArgs();

            using (OrderProcessorServiceClient client = new OrderProcessorServiceClient())
            {
                client.CancelOrder(order.OrderId, args);
            }
        }
        /// <summary>
        /// Updates the product stock.
        /// </summary>
        /// <param name="stockInfo">The stock info.</param>
        /// <param name="newAmount">The new amount.</param>
        public void Update(ProductStockInfo stockInfo, long newAmount)
        {
            ServiceClientArgs args = this.serviceClientArgsFactory.GetServiceClientArgs();

            using (ProductStockServiceClient client = new ProductStockServiceClient())
            {
                client.Update(stockInfo.ProductCode, newAmount, args);
            }
        }
        /// <summary>
        /// Gets the product stock.
        /// </summary>
        /// <param name="stockInfo">The product stock info. Contains info required to get product stock value.
        /// By default it's product code.</param>
        /// <returns>The product stock.</returns>
        public ProductStock GetStock(ProductStockInfo stockInfo)
        {
            ServiceClientArgs args = this.serviceClientArgsFactory.GetServiceClientArgs();

            using (ProductStockServiceClient client = new ProductStockServiceClient())
            {
                ProductStock stock = client.Get(stockInfo, args);

                return(stock);
            }
        }
        /// <summary>
        /// Updates the specified stock info.
        /// </summary>
        /// <param name="stockInfo">The stock info.</param>
        /// <param name="expression">The expression.</param>
        public void Update(ProductStockInfo stockInfo, Expression <Func <long, long> > expression)
        {
            Func <long, long> func = expression.Compile();
            ServiceClientArgs args = this.serviceClientArgsFactory.GetServiceClientArgs();

            using (ProductStockServiceClient client = new ProductStockServiceClient())
            {
                ProductStock stock    = client.Get(stockInfo, args);
                long         newStock = func(stock.Stock);

                client.Update(stockInfo.ProductCode, newStock, args);
            }
        }
Пример #5
0
        /// <summary>
        /// Gets the product totals.
        /// </summary>
        /// <typeparam name="TTotals">The type of the totals.</typeparam>
        /// <typeparam name="TProduct">The type of the product.</typeparam>
        /// <typeparam name="TCurrency">The type of the currency.</typeparam>
        /// <param name="product">The product.</param>
        /// <param name="currency">The currency.</param>
        /// <param name="quantity">The quantity.</param>
        /// <returns>The totals.</returns>
        public override TTotals GetProductTotals <TTotals, TProduct, TCurrency>(TProduct product, TCurrency currency, uint quantity)
        {
            Assert.ArgumentNotNull(product, "product");
            Assert.ArgumentNotNull(currency, "currency");

            Assert.IsNotNull(product.Code, "Product code is not specified.");

            ServiceClientArgs args = this.serviceClientArgsFactory.GetServiceClientArgs();

            using (ProductPriceServiceClient client = new ProductPriceServiceClient())
            {
                this.priceMatrix = client.GetPriceMatrix(product.Code, args);

                TTotals totals = base.GetProductTotals <TTotals, TProduct, TCurrency>(product, currency, quantity);

                return(totals);
            }
        }