コード例 #1
0
        /// <summary>
        /// Save order to database and call vendor api to place order
        /// </summary>
        /// <param name="orders"></param>
        /// <returns>returns true if vendor accepts the order successfully</returns>
        public Order SaveOrder(List <Order> orders)
        {
            //save order to database
            var order      = orders.FirstOrDefault();
            int vendorType = order.OrderDetails.FirstOrDefault().VendorId;

            _orderRepository.Insert(order);
            _orderRepository.Save();

            //call external api to place order
            var vendorToCall = _vendorFactory.CreateVendor(vendorType);

            vendorToCall.PlaceOrder();


            //call loger
            _loggingHelper.LogOrderInformation(order);

            return(order);
        }