Skip to content
Permalink
35a3db2c01
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
66 lines (60 sloc) 2 KB
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;
}
}
}