Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public IActionResult ListMeasures()
        {
            var measures = measurementRepository.GetMeasures(CurrentUserId);

            var response = AutoMapper.Mapper.Map <MeasureSummaryResponse[]>(measures);

            return(Ok(response));
        }
Ejemplo n.º 3
0
 public static decimal?GetUserWeight(this IMeasurementRepository measurementRepository, Guid userId)
 {
     return(measurementRepository.GetMeasures(userId).FirstOrDefault(m => m.Id == Constants.Measurements.WeightId)?.LatestValue);
 }