public VoucherController(VoucherContext context, ILightning lightning)
        {
            _context   = context;
            _lightning = lightning;

            if (_context.VoucherItems.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.VoucherItems.Add(new VoucherItem()
                {
                    StartSat = 2
                });
                _context.SaveChanges();
            }

            if (_context.VoucherBuyItems.Count() == 0)
            {
                _context.VoucherBuyItems.Add(new VoucherBuyItem()
                {
                    Amount  = 3,
                    claimed = false,
                    Id      =
                        "lnbc150n1pwr7z63pp568q60gxz5ta69v6jqxxpnlt2yg006hvkcq6pn8s5lc03pmkk3yzqdqqcqzyskp254xkgme7knwf0ygufdr7t24zz0dnctglttv8ezk0r9t4jhyh4q8eenjc0vgc59jladn50wxupua2sm624sp57cg4z9j8p3phd76qqlx6tn3",
                    SatPerVoucher = 5
                });
                _context.SaveChanges();
            }
        }
        public async Task <ActionResult <Invoice> > GetVoucherInvoice(uint amt, ulong satPerVoucher)
        {
            VoucherBuyRequestsMade.Inc();
            Console.WriteLine("CONTROLLERLOG: GetVoucherInvoice " + amt + " " + satPerVoucher);
            if (amt > _lightning.getMaxAmt() || satPerVoucher > _lightning.getMaxSat())
            {
                return new Invoice {
                           PaymentRequest = "ERROR: Voucheramount is capped at " + _lightning.getMaxAmt() + " and satoshi per voucher is capped at " + _lightning.getMaxSat()
                }
            }
            ;
            var payReq = await _lightning.GetPayReq(amt *satPerVoucher);

            var buyItem = _context.VoucherBuyItems.Add(new VoucherBuyItem()
            {
                Id = payReq.PaymentRequest, Amount = amt, SatPerVoucher = satPerVoucher, claimed = false
            }).Entity;

            _context.SaveChanges();
            return(payReq);
        }
        public VoucherController(VoucherContext context)
        {
            _context = context;
            if (_context.Vouchers.Count() == 0)
            {
                var voucher = new Voucher("First");

                _context.Vouchers.Add(voucher);

                var voucherId = voucher.Id;

                string voucherCode = ConvertIdToVoucherCode(voucherId);

                voucher.VoucherCode = voucherCode;

                _context.SaveChanges();
            }
        }