public ActionResult Edit(Health_Enthusiast healthEnthusiast) { try { var healthEnthusiastInDb = _context.Health_Enthusiasts.Single(m => m.Id == healthEnthusiast.Id); healthEnthusiastInDb.FirstName = healthEnthusiast.FirstName; healthEnthusiastInDb.LastName = healthEnthusiast.LastName; healthEnthusiastInDb.Height = healthEnthusiast.Height; healthEnthusiastInDb.StartingWeight = healthEnthusiast.StartingWeight; healthEnthusiastInDb.GoalWeight = healthEnthusiast.GoalWeight; healthEnthusiastInDb.Sex = healthEnthusiast.Sex; healthEnthusiastInDb.Age = healthEnthusiast.Age; healthEnthusiastInDb.Email = healthEnthusiast.Email; healthEnthusiastInDb.InitialCalorieIntake = healthEnthusiast.InitialCalorieIntake; healthEnthusiastInDb.GoalCalories = healthEnthusiast.GoalCalories; healthEnthusiastInDb.WeeklyWeightLoss = healthEnthusiast.WeeklyWeightLoss; healthEnthusiastInDb.Activity = healthEnthusiast.Activity; _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Create(Health_Enthusiast healthEnthusiast) { try { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); healthEnthusiast.IdentityUserId = userId; healthEnthusiast.InitialCalorieIntake = 0; _context.Add(healthEnthusiast); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult GetActivity(Health_Enthusiast healthEnthusiastActivity, int id) { try { //var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); //var healthEnthusiast = _context.Goals.Where(c => c.HealthEnthusiastId == //int.Parse(userId)).FirstOrDefault(); healthEnthusiastActivity.Id = id; var healthEnthusiastInDb = _context.Health_Enthusiasts.Single(m => m.Id == healthEnthusiastActivity.Id); healthEnthusiastInDb.Activity = healthEnthusiastActivity.Activity; _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Recomendations(Health_Enthusiast healthEnthusiast, int id) { try { // Getting Recomendations healthEnthusiast.Id = id; var healthEnthusiastInDb = _context.Health_Enthusiasts.Single(m => m.Id == healthEnthusiast.Id); if (healthEnthusiastInDb.Activity == 1) { if (healthEnthusiastInDb.Age > 15 && healthEnthusiastInDb.Age <= 21) { healthEnthusiastInDb.GoalCalories = 2600; healthEnthusiastInDb.WeeklyWeightLoss = .5; } if (healthEnthusiastInDb.Age > 21 && healthEnthusiastInDb.Age <= 30) { healthEnthusiastInDb.GoalCalories = 2400; healthEnthusiastInDb.WeeklyWeightLoss = .5; } if (healthEnthusiastInDb.Age > 30 && healthEnthusiastInDb.Age <= 40) { healthEnthusiastInDb.GoalCalories = 2400; healthEnthusiastInDb.WeeklyWeightLoss = .5; } if (healthEnthusiastInDb.Age > 40 && healthEnthusiastInDb.Age <= 50) { healthEnthusiastInDb.GoalCalories = 2400; healthEnthusiastInDb.WeeklyWeightLoss = .5; } if (healthEnthusiastInDb.Age < 50 && healthEnthusiastInDb.Age <= 60) { healthEnthusiastInDb.GoalCalories = 2200; healthEnthusiastInDb.WeeklyWeightLoss = .5; } if (healthEnthusiastInDb.Age >= 60) { healthEnthusiastInDb.GoalCalories = 2000; healthEnthusiastInDb.WeeklyWeightLoss = .5; } } else if (healthEnthusiastInDb.Activity == 2) { if (healthEnthusiastInDb.Age > 15 && healthEnthusiastInDb.Age <= 21) { healthEnthusiast.GoalCalories = 2800; healthEnthusiast.WeeklyWeightLoss = 1; } if (healthEnthusiastInDb.Age > 21 && healthEnthusiastInDb.Age <= 30) { healthEnthusiastInDb.GoalCalories = 2800; healthEnthusiastInDb.WeeklyWeightLoss = 1; } if (healthEnthusiastInDb.Age > 30 && healthEnthusiastInDb.Age <= 40) { healthEnthusiastInDb.GoalCalories = 2600; healthEnthusiastInDb.WeeklyWeightLoss = 1; } if (healthEnthusiastInDb.Age > 40 && healthEnthusiastInDb.Age <= 50) { healthEnthusiastInDb.GoalCalories = 2400; healthEnthusiastInDb.WeeklyWeightLoss = 1; } if (healthEnthusiastInDb.Age > 50 && healthEnthusiastInDb.Age <= 60) { healthEnthusiastInDb.GoalCalories = 2400; healthEnthusiastInDb.WeeklyWeightLoss = 1; } if (healthEnthusiastInDb.Age >= 60) { healthEnthusiastInDb.GoalCalories = 2200; healthEnthusiastInDb.WeeklyWeightLoss = 1; } } else { if (healthEnthusiastInDb.Age > 15 && healthEnthusiastInDb.Age <= 21) { healthEnthusiastInDb.GoalCalories = 3200; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } if (healthEnthusiastInDb.Age > 21 && healthEnthusiast.Age <= 30) { healthEnthusiastInDb.GoalCalories = 3000; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } if (healthEnthusiastInDb.Age > 30 && healthEnthusiastInDb.Age <= 40) { healthEnthusiastInDb.GoalCalories = 2800; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } if (healthEnthusiastInDb.Age > 40 && healthEnthusiastInDb.Age <= 50) { healthEnthusiastInDb.GoalCalories = 2800; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } if (healthEnthusiastInDb.Age > 50 && healthEnthusiastInDb.Age <= 60) { healthEnthusiastInDb.GoalCalories = 2600; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } if (healthEnthusiastInDb.Age >= 60) { healthEnthusiastInDb.GoalCalories = 2600; healthEnthusiastInDb.WeeklyWeightLoss = 1.5; } } _context.SaveChanges(); return(RedirectToAction("RecomendationDetails", new { id = healthEnthusiastInDb.Id })); } catch { return(View()); } }