Exemple #1
0
 public void RecordConsumption(double carbAmount)
 {
     CarbConsumption.Add(new CarbConsumption()
     {
         Amount     = carbAmount,
         ConsumedOn = DateTimeOffset.Now
     });
     TotalCarbConsumption += carbAmount;
 }
Exemple #2
0
        public bool CanConsume(Product product)
        {
            if (Preference != null)
            {
                double consumption = CarbConsumption.Where(x => x.ConsumedOn.Date == DateTimeOffset.Now.Date)
                                     .Sum(x => x.Amount);

                double max = Preference.MaxCarbsPerDayInGrams - consumption;

                return(product.Carbs <= max);
            }
            return(true);
        }