Skip to content
Permalink
Browse files

GetCustomeInvoice is good,

and the biggest piece of shit I've written
  • Loading branch information
Jeremy Mill
Jeremy Mill committed Dec 8, 2015
1 parent d28a1d4 commit 29ebfe1ac0dd6989572eef1bf04cdc003a31ebe6
@@ -6,6 +6,7 @@
using System.Web.Http;
using TeamDBAwesome.SqlService;
using TeamDBAwesome.Models;
using Newtonsoft.Json;

namespace TeamDBAwesome.Controllers
{
@@ -17,11 +18,11 @@ public HttpResponseMessage Get(int custId)

MySqlService sql = new MySqlService();

List<Invoice> invoiceList = new List<Invoice>();
List<Invoice> invoiceList = sql.getInvoices(custId);

int nextInvoice = sql.createInvoice(custId, payId, orderId);
string serialized = JsonConvert.SerializeObject(invoiceList);

message.Content = new StringContent(nextInvoice.ToString());
message.Content = new StringContent(serialized);

return message;
}
@@ -312,7 +312,88 @@ public List<Invoice> getInvoices(int custId)
if(open == true)
{
string query = "SELECT invoice.invoiceid, invoice.customerid, invoice.invoicedate, invoice.billingaddress, invoice.billingcity, " +
"invoice.billingstate, invoice.billingcountry, invoice.billingpostalcode, invoice.total, invoice.payid"
"invoice.billingstate, invoice.billingcountry, invoice.billingpostalcode, invoice.total, invoice.payid, payment.payId, " +
"payment.IsDefault, applepay.ApplePayToken, googlepay.GoogleToken, googlepay.GoogleEmail, creditcard.CreditCardNumber, " +
"creditcard.ExpirationDate " +
"from invoice " +
"left join payment on invoice.payid = payment.payid " +
"left join applepay on invoice.payid = applepay.PayId " +
"left join googlepay on invoice.payid = googlepay.PayId " +
"left join creditcard on invoice.payid = creditcard.PayId " +
//"where invoice.InvoiceId = " + custId;
"where invoice.customerId = " + custId;

MySqlCommand cmd = new MySqlCommand(query, SqlConn);
MySqlDataReader reader = cmd.ExecuteReader();
string Correct_Token;
while (reader.Read())
{
string appleToken = GetDBString("ApplePayToken", reader);
string googleToken = GetDBString("GoogleToken", reader);
if(String.IsNullOrEmpty(appleToken))
{
Correct_Token = googleToken;
}
else
{
Correct_Token = appleToken;
}

int payid = 0, IsDef = 0;
string EmptyPayId = GetDBString("payId", reader);
if(String.IsNullOrEmpty(EmptyPayId))
{
payid = 0;
}
else
{
payid = int.Parse(EmptyPayId);
}
string EmptyDefault = GetDBString("IsDefault", reader);
if(String.IsNullOrEmpty(EmptyDefault))
{
IsDef = 0;
}
else
{
IsDef = int.Parse(EmptyDefault);
}

Payment LoadPayment = new Payment
{
PayId = payid,
is_default = IsDef,
token = Correct_Token,
email = GetDBString("GoogleEmail", reader),
cardnum = GetDBString("CreditCardNumber", reader),
expr_date = GetDBString("ExpirationDate", reader)
};



invList.Add(new Invoice
{
invoiceId = int.Parse(GetDBString("invoiceid", reader)),
customerId = int.Parse(GetDBString("customerid", reader)),
invoiceDate = GetSqlDate("invoicedate", reader),
address = GetDBString("billingaddress", reader),
city = GetDBString("billingcity", reader),
state = GetDBString("billingstate", reader),
country = GetDBString("billingcountry", reader),
post = GetDBString("billingpostalcode", reader),
total = float.Parse(GetDBString("total", reader)),
payment = LoadPayment
/*payment = new Payment
{
PayId = int.Parse(GetDBString("payId", reader)),
is_default = int.Parse(GetDBString("IsDefault", reader)),
token = Correct_Token,
email = GetDBString("GoogleEmail", reader),
cardnum = GetDBString("CreditCardNumber", reader),
expr_date = GetDBString("ExpirationDate", reader)
}*/
});
}
}


@@ -1109,4 +1190,5 @@ public int UpdateTrack(Track track)
}
}
} // ADL: I added this ending paren.
}
}

0 comments on commit 29ebfe1

Please sign in to comment.
You can’t perform that action at this time.