Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add payment is in progress, added is default to holder service
  • Loading branch information
Jeremy Mill committed Dec 2, 2015
1 parent c44ba43 commit 35a3db2
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 21 deletions.
67 changes: 47 additions & 20 deletions TeamDBAwesome/TeamDBAwesome/Controllers/AddPaymentController.cs
Expand Up @@ -4,36 +4,63 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TeamDBAwesome.Models;
using TeamDBAwesome.SqlService;

namespace TeamDBAwesome.Controllers
{
public class AddPaymentController : ApiController
{
// GET: api/AddPayment
public IEnumerable<string> Get()
public HttpResponseMessage Post([FromBody] Payment payment)
{
return new string[] { "value1", "value2" };
}
MySqlService dbService = new MySqlService();

// GET: api/AddPayment/5
public string Get(int id)
{
return "value";
}
payment.Type = payment.Type.ToUpper();

if(payment.Type == "CC")
{
if(payment.cardnum == null || payment.cardnum == "" || payment.expr_date == null || payment.expr_date == "")
{
return new HttpResponseMessage(HttpStatusCode.BadRequest);
}
else
{
dbService.AddPayment(payment);
}

// POST: api/AddPayment
public void Post([FromBody]string value)
{
}
}
else if (payment.Type == "AP")
{
if (payment.token == null || payment.token == "")
{
return new HttpResponseMessage(HttpStatusCode.BadRequest);
}
else
{
dbService.AddPayment(payment);
}
}
else if (payment.Type == "GP")
{
if (payment.token == null || payment.token == "" || payment.email == "" || payment.email == null)
{
return new HttpResponseMessage(HttpStatusCode.BadRequest);
}
else
{
dbService.AddPayment(payment);
}
}
else
{
return new HttpResponseMessage(HttpStatusCode.BadRequest);
}

// PUT: api/AddPayment/5
public void Put(int id, [FromBody]string value)
{
}
//dbService.AddNewUser(customer);
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StringContent("0");
return response;

// DELETE: api/AddPayment/5
public void Delete(int id)
{
}
}
}
28 changes: 28 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -138,6 +138,34 @@ namespace TeamDBAwesome.SqlService

}

public int AddPayment(Payment payment)
{
bool open = this.OpenConnection();

if (open == true)
{

if (payment.Type == "CC")
{

}
else if (payment.Type == "AP")
{

}
else if (payment.Type == "GP")
{

}
else
{
return 1;
}
}

return 0;
}

/// <summary>
/// Update a Customer Object
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions TeamDBAwesome/TeamDBAwesome/TeamDBAwesome.csproj
Expand Up @@ -179,6 +179,7 @@
<Compile Include="Models\Customer.cs" />
<Compile Include="Models\Genre.cs" />
<Compile Include="Models\Media.cs" />
<Compile Include="Models\Payment.cs" />
<Compile Include="Models\Search.cs" />
<Compile Include="Models\SearchResult.cs" />
<Compile Include="Models\Track.cs" />
Expand Down
4 changes: 3 additions & 1 deletion TeamDBAwesome/TeamDBAwesome/js/HolderService.js
Expand Up @@ -48,7 +48,9 @@
cardnum: null,
//expr_date needs to be a date type
//YYYY-MM-DD
expr_date: null
expr_date: null,
//is_default is 0 for false, 1 for true
is_default: null
}


Expand Down

0 comments on commit 35a3db2

Please sign in to comment.