public static string JoinClass(string CommandPara) { SQLManager.Connection.Close(); JoinClassCommand Command = new JoinClassCommand(); ResultWithNoData Result = new ResultWithNoData(); Command = JsonConvert.DeserializeObject <JoinClassCommand>(CommandPara); CodeEMailCIDSafe tmp = InviteCodesSafe.getData(Command.EMail); if (tmp == null) { Result.statusCode = 202; return(JsonConvert.SerializeObject(Result)); } if (Command.Code == tmp.Code) { InviteCodesSafe.RemoveData(Command.EMail); using (MySqlCommand mysqlCommand = SQLManager.Connection.CreateCommand()) { SQLManager.Connection.Open(); mysqlCommand.CommandText = "UPDATE `users` SET `CID` = '" + tmp.CID + "' WHERE `EMail` = '" + Command.EMail + "'"; mysqlCommand.ExecuteNonQuery(); SQLManager.Connection.Close(); } using (MySqlCommand mysqlCommand = SQLManager.Connection.CreateCommand()) { SQLManager.Connection.Open(); mysqlCommand.CommandText = "UPDATE users SET HasSelected = 1 WHERE EMail = ?email"; mysqlCommand.Parameters.AddWithValue("?email", Command.EMail); mysqlCommand.ExecuteNonQuery(); SQLManager.Connection.Close(); } Result.statusCode = 201; } else { Result.statusCode = 202; } return(JsonConvert.SerializeObject(Result)); }
public static int JoinClass(int Code) { JoinClassCommand command = new JoinClassCommand(); command.EMail = EMAIL; command.Hash = HASH; command.Code = Code; ResultWithNoData result = JsonConvert.DeserializeObject <ResultWithNoData>(TCPManager.SendRequest(JsonConvert.SerializeObject(command))); return(result.statusCode); }