Пример #1
0
        /// <summary>
        /// Find the cheapest Supplier
        /// </summary>
        /// <param name="order"></param>
        /// <returns>Cheapest Supplier</returns>
        public Supplier FindCheapestSupplier(Order order)
        {
            Supplier cheapestSupplier = null;
            var      suppliers        = _SuppliersService.GetAvailableSuppliers();

            if (suppliers.Count > 0)
            {
                //calculate total cost for each supplier
                foreach (var supplier in suppliers)
                {
                    supplier.TotalCost = CalculateTotalCost(supplier, order);
                }

                cheapestSupplier = suppliers.OrderBy(supplier => supplier.TotalCost).FirstOrDefault();
            }
            return(cheapestSupplier);
        }