Example #1
0
        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));
        }
Example #2
0
        //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());
        }
Example #3
0
 public PersonalSettings()
 {
     InitializeComponent();
     viewModel      = new PersonalSettingsViewModel();
     BindingContext = viewModel;
 }