Exemple #1
0
        /// <summary>
        /// This method is a facade which simplifies the placement of an order.
        /// It orchestrates the steps needed to place an order.
        /// The OrderPlacement process consists of a validation, price calculation and the storage of the order.
        /// </summary>
        /// <param name="articleId">The article id</param>
        /// <param name="quantity">The quantity</param>
        /// <returns>True if order was succesfully stored and will be shipped</returns>
        public bool PlaceOrder(string articleId, int quantity)
        {
            Order order = new Order
            {
                ArticleId = articleId,
                Quantity  = quantity
            };

            // Validate order
            bool result = OrderValidator.IsValidOrder(order);

            // Calculate Price
            result = result && CalculatePrice(order);

            // Place Order
            result = result & OrderStorage.PlaceOrder(order);

            return(result);
        }