Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
generate invoice now removes order and ordertracks from that order
  • Loading branch information
Jeremy Mill committed Dec 7, 2015
1 parent 500f48e commit bb59370
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.SqlService;
using TeamDBAwesome.Models;

namespace TeamDBAwesome.Controllers
{
public class GetCustomerInvoiceController : ApiController
{
public HttpResponseMessage Get(int custId)
{
HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);

MySqlService sql = new MySqlService();

List<Invoice> invoiceList = new List<Invoice>();

int nextInvoice = sql.createInvoice(custId, payId, orderId);

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

return message;
}
}
}
27 changes: 27 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/Models/Invoice.cs
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TeamDBAwesome.Models
{
public class Invoice
{
public int invoiceId { get; set; }
public int customerId { get; set; }
public DateTime invoiceDate { get; set; }
public string address { get; set; }
public string city { get; set; }
public string state { get; set; }
public string country { get; set; }
public string post { get; set; }
public float total { get; set; }
public Payment payment { get; set; }

public Invoice()
{
payment = new Payment();
}

}
}
9 changes: 9 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -288,6 +288,15 @@ namespace TeamDBAwesome.SqlService
cmd = new MySqlCommand(insert, SqlConn);
cmd.ExecuteNonQuery();

//NEED TO DELETE THE ORDER, AND ORDER TRACKS
string delete_order = "delete from orders where orderid = " + orderId;
cmd = new MySqlCommand(delete_order, SqlConn);
cmd.ExecuteNonQuery();

string delete_ordertracks = "delete from ordertracks where orderid = " + orderId;
cmd = new MySqlCommand(delete_ordertracks, SqlConn);
cmd.ExecuteNonQuery();

return nextInvoice;
}
else
Expand Down
1 change: 1 addition & 0 deletions TeamDBAwesome/TeamDBAwesome/TeamDBAwesome.csproj
Expand Up @@ -174,6 +174,7 @@
<Compile Include="Controllers\DropPlaylistController.cs" />
<Compile Include="Controllers\GenerateInvoiceController.cs" />
<Compile Include="Controllers\GetCustomerController.cs" />
<Compile Include="Controllers\GetCustomerInvoiceController.cs" />
<Compile Include="Controllers\GetCustomerOrdersController.cs" />
<Compile Include="Controllers\GetCustomPlaylistController.cs" />
<Compile Include="Controllers\GetCustomPlaylistsController.cs" />
Expand Down

0 comments on commit bb59370

Please sign in to comment.