public async Task <IActionResult> PostUserMetrics(User user, MetricsModel model, UserManager <User> _userManager)
        {
            user.Age    = model.MetricAge;
            user.Height = model.MetricHeight;
            WeightHistory        history = new WeightHistory(user.Id, model.MetricWeight, DateTime.Now.Date);
            WeightHistoryManager manager = new WeightHistoryManager(_context, _userManager);
            await manager.AddChange(history);

            user.Goal       = model.MetricGoal;
            user.MaxPushUps = model.MetricPushUps;
            user.MaxPullUps = model.MetricPullUps;
            user.IsMetrics  = true;


            for (int i = 0; i < model.MetricHealth.Count; i++)
            {
                HealthProblem problem = new HealthProblem(user.Id, model.MetricHealth[i].Problem);

                await _context.HealthProblems.AddAsync(problem);

                await _context.SaveChangesAsync();
            }


            await _userManager.UpdateAsync(user);

            return(new OkResult());
        }
        public async Task <IActionResult> UpdateUserMetrics(User user, UserMetricsUpdateModel UserMetrics, UserManager <User> _userManager)
        {
            user.Name = UserMetrics.Name;
            WeightHistory        history = new WeightHistory(user.Id, UserMetrics.MetricWeight, DateTime.Now.Date);
            WeightHistoryManager manager = new WeightHistoryManager(_context, _userManager);
            await manager.AddChange(history);

            user.Age    = UserMetrics.MetricAge;
            user.Gender = UserMetrics.MetricGender;
            user.Goal   = UserMetrics.MetricGoal;
            user.Height = UserMetrics.MetricHeight;
            for (int i = 0; i < UserMetrics.healthProblems.Count; i++)
            {
                UserMetrics.healthProblems[i].UserId = user.Id;
            }
            await _userManager.UpdateAsync(user);

            await _context.SaveChangesAsync();

            var user_health = _context.HealthProblems.Where(x => x.UserId == user.Id).ToList();

            _context.HealthProblems.RemoveRange(user_health);
            await _context.SaveChangesAsync();

            await _context.HealthProblems.AddRangeAsync(UserMetrics.healthProblems);

            await _context.SaveChangesAsync();

            return(new OkResult());
        }
        public async Task <IActionResult> WeightChange(WeightHistory history)
        {
            history.Date = DateTime.Now.Date;
            WeightHistoryManager manager = new WeightHistoryManager(_context, _userManager);
            bool result = await manager.AddChange(history);

            if (!result)
            {
                return(new StatusCodeResult(400));
            }
            return(new OkResult());
        }