Example #1
0
        public async Task EditRole(EditUserInput input)
        {
            var id   = input.Id;
            var role = input.MapTo <Role>();

            role.TenantId = AbpSession.TenantId;
            if (id == null)
            {
                CheckErrors(await _roleManager.CreateAsync(role));
            }
            else
            {
                var isRepetition = await _roleManager.CheckDuplicateRoleNameAsync(id, input.Name, input.DisplayName);

                CheckErrors(isRepetition);
                if (isRepetition.Succeeded == true)
                {
                    var roleUpdate = await _roleManager.GetRoleByIdAsync(Convert.ToInt32(id));

                    roleUpdate.Name        = input.Name;
                    roleUpdate.DisplayName = input.DisplayName;
                    roleUpdate.IsStatic    = input.IsStatic;
                    await _roleManager.UpdateAsync(roleUpdate);
                }
            }
            //var role = input.MapTo<Role>();
            //await _roleRepository.InsertOrUpdateAsync(role);
        }
Example #2
0
        [AbpAuthorize("CanEditUsers")] //An example of permission checking
        public async Task EditUser(EditUserInput input)
        {
            if (AbpSession.MultiTenancySide == MultiTenancySides.Host)
            {
                CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, input.TenantId);
                var user = _userRepository.Get(input.Id);
                Mapper.CreateMap<EditUserInput, User>();
                input.MapTo<EditUserInput, User>(user);

                await _userRepository.UpdateAsync(user);
            }
        }
Example #3
0
        [AbpAuthorize("CanEditUsers")] //An example of permission checking
        public async Task EditUser(EditUserInput input)
        {
            if (AbpSession.MultiTenancySide == MultiTenancySides.Host)
            {
                CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, input.TenantId);
                var user = _userRepository.Get(input.Id);
                Mapper.CreateMap <EditUserInput, User>();
                input.MapTo <EditUserInput, User>(user);

                await _userRepository.UpdateAsync(user);
            }
        }
Example #4
0
        /// <summary>
        /// 更新用户
        /// </summary>
        public async Task UpdateUser(EditUserInput input)
        {
            var user = await UserManager.GetUserByIdAsync(input.Id);

            if (user == null)
            {
                throw new UserFriendlyException($"用户ID:[{input.Id}]不存在!");
            }

            input.MapTo(user);
            CheckErrors(await UserManager.UpdateAsync(user));

            //通知
            await this._etupirkaPortalNotifier.WelcomeToTheApplicationAsync(user);
        }