示例#1
0
        public IActionResult Create(Profile profile) // ApplicationUser appUser
        {
            // A user is read in by their role name.
            var user = _repo.ReadApplicationUser(User.Identity.Name);

            // The model is checked for valid data.
            if (ModelState.IsValid)
            {
                // The profile id is set to the identity user's id.
                profile.Id = user.User.Id;
                // A profile is created.
                _repo.CreateProfile(profile);
                // The page is redirected to the main shopping page.
                return(RedirectToAction("Index", "Home"));
            }
            // all appplication user data in the view is set to the profile id data being read in.
            ViewData["ApplicationUser"] = _repo.ReadProfile(profile.Id);
            // The index view is displayed.
            return(View(profile));
        }