public async Task <ActionResult> Receipt(int id, int?pointOfSaleId) { var order = await _db.Orders .Include(x => x.Lines) .FirstOrDefaultAsync(x => x.Id == id); if (order == null) { return(NotFound()); } var printerId = await _printDispatcher.GetReceiptPrinterAsync(pointOfSaleId ?? order.PointOfSaleId); if (printerId == null) { return(BadRequest()); } var data = _receiptPrintGenerator.Generate(order); await _printQueue.EnqueueAsync(new PrintJob() { PrinterId = printerId.Value, Name = $"Kvittering {order.Id}", Data = data }); await _mediator.Publish(new PrintJobCreatedNotification(printerId.Value)); return(NoContent()); }