public async Task CreateAsync(Delivery delivery) { var existingDelivery = await _repository.GetByOrderNumberAsync(delivery.Order.OrderNumber); if (existingDelivery != null && existingDelivery.State != State.cancelled) { throw new OrderAlreadyDeliveredException(existingDelivery.Id); } await _repository.SaveAsync(delivery); }