public async Task <IActionResult> SettingsDetails() { ApplicationUser user = await _userManager.GetUserAsync(User); var measurements = _context.Measurements.Where(m => m.User.Id == user.Id).ToList(); var model = new PersonalSettingsViewModel { User = user, Measurements = measurements }; return(View(model)); }
//posting the information to the db. public async Task <IActionResult> PersonalSettings(PersonalSettingsViewModel model) { ModelState.Remove("User"); //ApplicationUser user = await _userManager.GetUserAsync(User); var measurement = new Measurement() { User = await _userManager.GetUserAsync(User), BodyWeight = model.BodyWeight, BMI = model.BMI, Date = DateTime.UtcNow }; if (ModelState.IsValid) { _context.Add(measurement); await _context.SaveChangesAsync(); return(RedirectToAction("SettingsDetails", "Manage")); } return(View()); }
public PersonalSettings() { InitializeComponent(); viewModel = new PersonalSettingsViewModel(); BindingContext = viewModel; }