public TargetAndCaloriesNeedHelper GetActualProgress(int userId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { TargetAndCaloriesNeedHelper tAndCNeedHelper; List<DailyMensurationHelper> myMensurationInscription = new List<DailyMensurationHelper>(); using (var dB = new DailyServerContext()) { var newestProgress = (from x in dB.DailyInscriptionSet where x.DailyMensuration.Count > 0 && x.UserUserId == userId select x).OrderByDescending(x => x.Date); tAndCNeedHelper = new TargetAndCaloriesNeedHelper(); foreach (var item in newestProgress) { foreach (var dm in item.DailyMensuration) { if (dm.TypeOfMensuration.MName == "Współczynnik BF") { tAndCNeedHelper.TargetBodyFat = dm.MResultValue; } else if (dm.TypeOfMensuration.MName == "Waga") { tAndCNeedHelper.TargetWeight = dm.MResultValue; } } if (tAndCNeedHelper.TargetBodyFat != 0 && tAndCNeedHelper.TargetWeight != 0) { tAndCNeedHelper.TargetDate = item.Date; break; } else { tAndCNeedHelper.TargetBodyFat = tAndCNeedHelper.TargetWeight = 0; } } } return tAndCNeedHelper; } }
public TargetAndCaloriesNeedHelper GetTargetInfoAndCaloriesNeedInfo(int userId) { if (!Verify(userId)) { throw new SoapException("Nie rozpoznano użytkownika.", SoapException.ClientFaultCode); } else { using (var dB = new DailyServerContext()) { var updateUserTarget = from UserTargetSet in dB.UserTargetSet where UserTargetSet.User.UserId == userId select UserTargetSet; UserTarget userTarget = updateUserTarget.Single(); TargetAndCaloriesNeedHelper targetHelper = new TargetAndCaloriesNeedHelper(); targetHelper.TargetDate = userTarget.Date; targetHelper.TargetWeight = userTarget.Weight; targetHelper.TargetBodyFat = userTarget.BodyFat; targetHelper.TargetCaloriesNeed = userTarget.CaloriesNeed; targetHelper.TargetProteins = userTarget.Proteins; targetHelper.TargetCarbohydrates = userTarget.Carbohydrates; targetHelper.TargetFat = userTarget.Fat; return targetHelper; } } }