コード例 #1
0
        public ActionResult Edit(UserEdit model, IEnumerable <PermissionFlagEntry> permissions)
        {
            PermissionContext.VerifyPermission(PermissionToken.ManageUserPermissions);

            model.EditableGroups = UserEdit.GetEditableGroups(_loginManager);
            model.OldName        = Service.GetUser(model.Id).Name;

            if (permissions != null)
            {
                model.Permissions = permissions.ToArray();
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                Data.UpdateUser(model.ToContract());
            }
            catch (InvalidEmailFormatException)
            {
                ModelState.AddModelError("Email", ViewRes.User.MySettingsStrings.InvalidEmail);
                return(View(model));
            }
            catch (UserNameAlreadyExistsException)
            {
                ModelState.AddModelError("Username", "Username is already in use.");
                return(View(model));
            }

            return(RedirectToAction("Details", new { id = model.Id }));
        }
コード例 #2
0
        public ActionResult Edit(int id)
        {
            PermissionContext.VerifyPermission(PermissionToken.ManageUserPermissions);

            var user = Service.GetUserWithPermissions(id);

            return(View(new UserEdit(user)
            {
                EditableGroups = UserEdit.GetEditableGroups(_loginManager)
            }));
        }