コード例 #1
0
        public virtual IActionResult Edit(UserAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var userAttribute = _userAttributeService.GetUserAttributeById(model.Id);

            if (userAttribute == null)
            {
                //no user attribute found with the specified id
                return(RedirectToAction("List"));
            }

            if (!ModelState.IsValid)
            {
                //if we got this far, something failed, redisplay form
                return(View(model));
            }

            userAttribute = model.ToEntity(userAttribute);
            _userAttributeService.UpdateUserAttribute(userAttribute);

            //activity log
            _userActivityService.InsertActivity("EditUserAttribute",
                                                string.Format(_localizationService.GetResource("ActivityLog.EditUserAttribute"), userAttribute.Id),
                                                userAttribute);

            //locales
            UpdateAttributeLocales(userAttribute, model);

            SuccessNotification(_localizationService.GetResource("Admin.Users.UserAttributes.Updated"));

            if (!continueEditing)
            {
                return(RedirectToAction("List"));
            }

            //selected tab
            SaveSelectedTabName();

            return(RedirectToAction("Edit", new { id = userAttribute.Id }));
        }