Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TeamDbAwesome/TeamDBAwesome/TeamDBAwesome/Controllers/AddPaymentController.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (60 sloc)
2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
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 | |
{ | |
public HttpResponseMessage Post([FromBody] Payment payment) | |
{ | |
MySqlService dbService = new MySqlService(); | |
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); | |
} | |
} | |
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); | |
} | |
//dbService.AddNewUser(customer); | |
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); | |
response.Content = new StringContent("0"); | |
return response; | |
} | |
} | |
} |