示例#1
0
        public bool IsIngedientAvailable(Ingredient i, ProductDetails p, int numberOfPersons = 1)
        {
            if (numberOfPersons < 1)
            {
                numberOfPersons = 1;
            }

            bool productHasSameMeasurementClass = p.ProductQuantities.Any(pq => Measurements.GetMeasurementClassForEUnitQuantityType(pq.MeasurementType) == Measurements.GetMeasurementClassForEUnitQuantityType(i.UnitQuantityType));

            if (!productHasSameMeasurementClass || p.MeasurementAmounts == null)
            {
                return(false);
            }
            var totalAmountOfProduct = p.MeasurementAmounts.GetTotalAmount(i.UnitQuantityType);

            return(totalAmountOfProduct >= i.UnitQuantity * numberOfPersons);
        }