Hello, my name is Bill.

This commit is contained in:
MarcEricMartel
2022-12-12 12:28:21 -08:00
parent 23284fc514
commit 7a89d78e4a
7 changed files with 139 additions and 62 deletions

View File

@@ -70,6 +70,7 @@ public class InvoiceController : Controller {
.Include(x => x.ShippingAddress)
.Include(x => x.LinkedAccount)
.Include(x => x.Payment)
.ThenInclude(x => x.BillingAddress)
.Include(x => x.Products)
.ThenInclude(y => y.Product)
.ToList());
@@ -77,6 +78,7 @@ public class InvoiceController : Controller {
.Include(x => x.ShippingAddress)
.Include(x => x.LinkedAccount)
.Include(x => x.Payment)
.ThenInclude(x => x.BillingAddress)
.Include(x => x.Products)
.ThenInclude(y => y.Product)
.Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList());
@@ -99,7 +101,9 @@ public class InvoiceController : Controller {
}
try {
inv = _context.Invoices.Where(x => x.Id == id).Include("ShippingAddress").Include(x => x.Payment).First();
inv = _context.Invoices.Where(x => x.Id == id).Include("ShippingAddress")
.Include(x => x.Payment)
.ThenInclude(x => x.BillingAddress).First();
} catch (Exception e) {
_logger.LogError(10, e.Message);
return BadRequest();
@@ -164,9 +168,17 @@ public class InvoiceController : Controller {
// Charges!
StripeConfiguration.ApiKey = _stripeOptions.Value.SecretKey;
ChargesModel chr;
AddressModel bill = new() {
CivicNumber = sinv.BillCivicNumber,
Street = sinv.BillStreet,
City = sinv.BillCity,
Appartment= sinv.BillAppartment,
Country= sinv.BillCountry,
PostalCode= sinv.BillPostalCode,
Province= sinv.BillProvince,
};
chr = new() {
ChargesModel chr = new() {
Token = sinv.Token,
AmountInCents = sinv.AmountInCents,
Name = sinv.Name,
@@ -175,6 +187,7 @@ public class InvoiceController : Controller {
Description = sinv.Description,
CurrencyCode = sinv.CurrencyCode,
LastFourDigits = sinv.LastFourDigits,
BillingAddress = bill
};
inv.Payment = chr;