// POST candidats/values public void Post([FromBody] Candidat data) { DatabaseOperations db = new DatabaseOperations(); MySqlCommand command = new MySqlCommand("INSERT INTO Candidats(Nume, Descriere, Functie, CreationTime) VALUES(@Nume, @Descriere, @Functie, @CreationTime)"); command.Parameters.AddWithValue("@Nume", data.Nume); command.Parameters.AddWithValue("@Descriere", data.Descriere); command.Parameters.AddWithValue("@Functie", data.Functie); command.Parameters.AddWithValue("@CreationTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); db.ExecuteQuery(command); }
public static async Task <Candidat> AddCandidat(Candidat candidat) { string data; data = ""; try { data = await HttpRequestClient.PostRequest("Candidats.php?cmd=addCandidat", candidat); candidat = JsonConvert.DeserializeObject <Candidat>(data); } catch (Exception ee) { Console.WriteLine(ee.Message); } return(candidat); }