Esempio n. 1
0
        public async Task DeleteAsync(IList <Guid> ids)
        {
            var batchDeleteCommand = new BatchDeleteUserCommand(ids);
            await _bus.SendCommand(batchDeleteCommand);

            if (_notifications.HasNotifications())
            {
                var errorMessage = _notifications.GetNotificationMessage();
                throw new GirvsException(StatusCodes.Status400BadRequest, errorMessage);
            }
        }
Esempio n. 2
0
        public async Task <bool> Handle(BatchDeleteUserCommand request, CancellationToken cancellationToken)
        {
            //批量删除不允许删除超级管理员和租户管理员。
            var users = await _userRepository.GetUsersIncludeRolesAndDataRule(x =>
                                                                              request.Ids.Contains(x.Id) &&
                                                                              (x.UserType != UserType.AdminUser && x.UserType != UserType.TenantAdminUser));

            await _userRepository.DeleteRangeAsync(users);

            if (await Commit())
            {
                foreach (var id in request.Ids)
                {
                    var key = GirvsEntityCacheDefaults <Role> .ByIdCacheKey.Create(id.ToString());

                    _bus.RaiseEvent(new RemoveCacheEvent(key), cancellationToken);
                }

                _bus.RaiseEvent(new RemoveCacheListEvent(GirvsEntityCacheDefaults <Role> .ListCacheKey.Create()),
                                cancellationToken);
            }

            return(true);
        }