public async Task <IActionResult> GetProfile() { var profile = _profileRepository.GetProfile(CurrentUserId); if (profile == null) { profile = new Profile.Profile { UserId = CurrentUserId }; } var user = await _userManager.FindByIdAsync(CurrentUserId.ToString()); var logins = await _userManager.GetLoginsAsync(user); var hasPassword = await _userManager.HasPasswordAsync(user); var result = Mapper.Map <ProfileResponse>(profile); var measures = _measurementRepository.GetMeasures(CurrentUserId); result.Weight = measures.FirstOrDefault(m => m.Id == Constants.Measurements.WeightId)?.LatestValue; result.Height = measures.FirstOrDefault(m => m.Id == Constants.Measurements.HeightId)?.LatestValue; result.Rmr = measures.FirstOrDefault(m => m.Id == Constants.Measurements.RmrId)?.LatestValue; result.Logins = logins.Select(l => l.LoginProvider).ToArray(); result.HasPassword = hasPassword; result.Username = user.UserName; LogClientVersion(); return(Ok(result)); }
public IActionResult ListMeasures() { var measures = measurementRepository.GetMeasures(CurrentUserId); var response = AutoMapper.Mapper.Map <MeasureSummaryResponse[]>(measures); return(Ok(response)); }
public static decimal?GetUserWeight(this IMeasurementRepository measurementRepository, Guid userId) { return(measurementRepository.GetMeasures(userId).FirstOrDefault(m => m.Id == Constants.Measurements.WeightId)?.LatestValue); }