public IActionResult Edit(EditCredentialViewModel model)
        {
            if (ModelState.IsValid)
            {
                var context    = new ApplicationContext();
                var credential = context.Credentials
                                 .FirstOrDefault(c => c.Id == model.Id);

                if (credential != null)
                {
                    credential.Source   = model.Source;
                    credential.Login    = model.Login;
                    credential.Password = model.Password;
                    context.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(model));
        }
Exemplo n.º 2
0
        private async Task <IActionResult> DisplayEditView(ClaimsPrincipal authenticatedUser)
        {
            await TranslateUserEditView(DefaultLanguage).ConfigureAwait(false);

            var viewModel = new EditCredentialViewModel();

            if (_authModules != null)
            {
                viewModel.Links = _authModules.Where(e => e.IsEditCredentialsEnabled).Select(e => {
                    return(new EditCredentialLinkViewModel
                    {
                        DisplayName = e.DisplayName,
                        Href = e.EditCredentialUrl
                    });
                }).ToList();
            }

            var resourceOwner = await _userActions.GetUser(authenticatedUser.GetSubject()).ConfigureAwait(false);

            return(View("Edit", viewModel));
        }
        public IActionResult Edit(int id)
        {
            var context = new ApplicationContext();

            var credential = context.Credentials
                             .FirstOrDefault(c => c.Id == id);

            if (credential == null)
            {
                return(NotFound());
            }

            var model = new EditCredentialViewModel
            {
                Id       = id,
                Source   = credential.Source,
                Login    = credential.Login,
                Password = credential.Password
            };

            return(View(model));
        }