Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GetCustomeInvoice is good,
and the biggest piece of shit I've written
  • Loading branch information
Jeremy Mill committed Dec 8, 2015
1 parent d28a1d4 commit 29ebfe1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 5 deletions.
Expand Up @@ -6,6 +6,7 @@ using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;
using TeamDBAwesome.Models;
using Newtonsoft.Json;

namespace TeamDBAwesome.Controllers
{
Expand All @@ -17,11 +18,11 @@ namespace TeamDBAwesome.Controllers

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;
}
Expand Down
86 changes: 84 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -312,7 +312,88 @@ namespace TeamDBAwesome.SqlService
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)
}*/
});
}
}


Expand Down Expand Up @@ -1109,4 +1190,5 @@ namespace TeamDBAwesome.SqlService
}
}
} // ADL: I added this ending paren.
}
}

0 comments on commit 29ebfe1

Please sign in to comment.