Esempio n. 1
0
        public IActionResult Edit(int id, [Bind("FirstName", "LastName", "Alias", "Location", "Age", "DOB",
                                                "Mobile", "Twitter", "Instagram", "Facebook", "Snapchat", "AltSocialMedia")] Profile profile)
        {
            EditViewModel viewModel = new EditViewModel(_connectionString);

            profile.ID = id;

            if (id != profile.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    viewModel.EditProfile(profile);
                }
                catch (Exception)
                {
                    if (!ProfileExists(profile.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(profile));
        }