public async Task HandleAsync(DeleteConfiguration command, ICorrelationContext context) { if (!await _ConfigurationRepository.ExistsAsync(command.Id)) { throw new DShopException("product_not_found", $"Product with id: '{command.Id}' was not found."); } await _ConfigurationRepository.DeleteAsync(command.Id); await _busPublisher.PublishAsync(new ConfigurationDeleted(command.Id), context); }
public async Task HandleAsync(CreateConfiguration command, ICorrelationContext context) { if (await _configurationRepository.ExistsAsync(command.Name)) { throw new DShopException("product_already_exists", $"Product: '{command.Name}' already exists."); } var configuration = new Configuration(command.Id, command.Name, command.Value); await _configurationRepository.AddAsync(configuration); await _busPublisher.PublishAsync(new ConfigurationCreated(command.Id, command.Name), context); }