public decimal GetUserCalories(User user) { decimal calories = 0; decimal heightCentimeters = UnitConverter.MetersToCentimeters(user.HeighInt) + user.HeighDec;//estatura en centimetros int age = Selery.Library.Common.Helper.GetAge(user.BirthDate.Value); spSelectActivityByID_Result activity = null; using (var context = new RegistrationEntities()) { activity = context.spSelectActivityByID(user.ActivityID).FirstOrDefault(); } //calcular el gasto de calorias. if (user.Gender == (int)Selery.BO.Core.Enum.Gender.Male) { //( (10*peso)+(6.25*estatura)-(5*edad)+5 )*factor calories = ((10 * user.Weight) + ((decimal)6.25 * heightCentimeters) - (5 * age) + 5) * activity.Factor; } else { //( ( 10*peso)+(6.25*estatura)-(5*edad)-161 )*factor calories = ((10 * user.Weight) + ((decimal)6.25 * heightCentimeters) - (5 * age) + 161) * activity.Factor; } return(calories); }