Esempio n. 1
0
        public async Task DeleteAsync(IList <Guid> ids)
        {
            var batchDeleteCommand = new BatchDeleteRoleCommand(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(BatchDeleteRoleCommand request, CancellationToken cancellationToken)
        {
            var role = await _roleRepository.GetWhereAsync(x => request.Ids.Contains(x.Id));

            await _roleRepository.DeleteRangeAsync(role);

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

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

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

            return(true);
        }