public async Task <bool> Handle(DeleteRoleUserCommand request, CancellationToken cancellationToken) { var role = await _roleRepository.GetRoleByIdIncludeUsersAsync(request.RoleId); if (role == null) { await _bus.RaiseEvent(new DomainNotification(request.UserIds.ToString(), "未找到对应的数据")); return(false); } role.Users.RemoveAll(x => request.UserIds.Contains(x.Id)); if (await Commit()) { var key = GirvsEntityCacheDefaults <Role> .ByIdCacheKey.Create(role.Id.ToString()); _bus.RaiseEvent(new RemoveCacheEvent(key), cancellationToken); _bus.RaiseEvent(new RemoveCacheListEvent(GirvsEntityCacheDefaults <Role> .ListCacheKey.Create()), cancellationToken); _bus.RaiseEvent(new RemoveServiceCacheEvent(), cancellationToken); } return(true); }
public async Task DeleteRoleUser(Guid roleId, [FromForm] EditRoleUserViewModel model) { var command = new DeleteRoleUserCommand( roleId, model.UserIds ); await _bus.SendCommand(command); if (_notifications.HasNotifications()) { var errorMessage = _notifications.GetNotificationMessage(); throw new GirvsException(StatusCodes.Status400BadRequest, errorMessage); } }