Exemple #1
0
        // GET: Admin/Edit/5
        public ActionResult Edit(string id)
        {
            Alue71UserPrincipal model = new Alue71UserPrincipal(_context);

            model.SamAccountName = id;

            PrincipalSearcher   searcher = new PrincipalSearcher(model);
            Alue71UserPrincipal edituser = (Alue71UserPrincipal)searcher.FindOne();

            return(View(edituser.ToViewModel()));
        }
        private UserViewModel GetUser()
        {
            UserViewModel user = GetSession();

            if (user == null)
            {
                Alue71UserPrincipal DomainUser = GetPrincipal();
                user = DomainUser.ToViewModel();
                SetSession(user);
                return(user);
            }
            return(user);
        }
        public IActionResult Edit(UserViewModel user)
        {
            try
            {
                Alue71UserPrincipal principal = GetPrincipal();
                principal.UpdateFromModel(user);
                principal.Save();
                ReplaceSession(principal.ToViewModel());

                return(RedirectToAction(nameof(Details)));
            }
            catch
            {
                return(View(GetUser()));
            }
        }