mirror of
https://github.com/Queercon/QC14-Badge-Webview.git
synced 2025-08-19 21:03:31 -07:00
sql update working
This commit is contained in:
parent
dea8abf8f2
commit
6afa3aaeb4
2 changed files with 34 additions and 8 deletions
|
@ -150,8 +150,9 @@ namespace qcbadge.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Helpers.Sql sql = new Helpers.Sql();
|
||||||
|
|
||||||
if(!String.IsNullOrEmpty(advertData64))
|
if (!String.IsNullOrEmpty(advertData64))
|
||||||
{
|
{
|
||||||
byte[] bytes = Convert.FromBase64String(advertData64);
|
byte[] bytes = Convert.FromBase64String(advertData64);
|
||||||
advertData = "0x" + BitConverter.ToString(bytes);
|
advertData = "0x" + BitConverter.ToString(bytes);
|
||||||
|
@ -209,7 +210,21 @@ namespace qcbadge.Controllers
|
||||||
System.Diagnostics.Debug.WriteLine(bitSet[i]);
|
System.Diagnostics.Debug.WriteLine(bitSet[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StatusCode(200);
|
|
||||||
|
|
||||||
|
int rows = sql.updateBadge(badgeId, curIcon, bitSet);
|
||||||
|
System.Diagnostics.Debug.WriteLine(rows);
|
||||||
|
|
||||||
|
if(rows == 1)
|
||||||
|
{
|
||||||
|
return StatusCode(201);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return StatusCode(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -130,9 +130,9 @@ namespace qcbadge.Helpers
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBadge(String code, string email, string custcode, string paycode, string qrcode)
|
public int updateBadge(int badgeId, int curIcon, int[] bitSet)
|
||||||
{
|
{
|
||||||
|
int rtn = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
|
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
|
||||||
|
@ -145,22 +145,33 @@ namespace qcbadge.Helpers
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append("UPDATE " + table + " SET codeused = 1, email = '" + email + "', custcode = '" + custcode + "', paycode = '" + paycode + "', qrcode = '" + qrcode + "', datepayed = CURRENT_TIMESTAMP WHERE [requestcode] = '" + code + "';");
|
sb.Append("UPDATE " + table + " SET [curr] = '" + curIcon + "', ");
|
||||||
|
|
||||||
|
int z = 47;
|
||||||
|
for (int i = 0; i < 48; i++)
|
||||||
|
{
|
||||||
|
sb.Append("[" + z + "] = '" + bitSet[i] + "', ");
|
||||||
|
z = z - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sb.Append("[lastseen] = CURRENT_TIMESTAMP WHERE [badgeid] = '" + badgeId + "';");
|
||||||
String sql = sb.ToString();
|
String sql = sb.ToString();
|
||||||
|
System.Diagnostics.Debug.WriteLine(sb.ToString());
|
||||||
using (SqlCommand command = new SqlCommand(sql, connection))
|
using (SqlCommand command = new SqlCommand(sql, connection))
|
||||||
{
|
{
|
||||||
|
|
||||||
int rowsAffected = command.ExecuteNonQuery();
|
rtn = command.ExecuteNonQuery();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SqlException e)
|
catch (SqlException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
System.Diagnostics.Debug.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue