/// <summary>
        /// Calcs the consumption.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public Int32 CalcConsumption()
        {
            BodyMeasure lastKnownEntry = BodyMeasure.FindNearestToDate(this.User, this.Date);

            Double result = 0;

            if (lastKnownEntry != null)
            {
                Double weight   = lastKnownEntry.Weight;
                Double duration = this.DurationInMinutes;
                Double factor   = this.Action.Consumption;

                result = weight * duration * factor;
            }

            return(Convert.ToInt32(result));
        }
        public static BodyMeasure FindNearestToDate(User user, DateTime date)
        {
            BodyMeasure result = null;

            BodyMeasure before = BodyMeasure.FindNearestBeforeDate(user, date);

            if (before != null)
            {
                result = before;
            }
            else
            {
                BodyMeasure after = BodyMeasure.FindNearestAfterDate(user, date);

                if (after != null)
                {
                    result = after;
                }
            }

            return(result);
        }