// GET: api/List/5 public ListTo Get(int id) { ListPersistence listP = new ListPersistence(); ListTo listTo = listP.getList(id); return(listTo); }
public long saveList(ListTo listToSave) { String sqlInquiry = "INSERT INTO todo (title,text,priority) VALUES ('" + listToSave.title + "','" + listToSave.text + "','" + listToSave.priority + "')"; MySqlCommand comm = new MySqlCommand(sqlInquiry, conn); comm.ExecuteNonQuery(); long id = comm.LastInsertedId; return(id); }
// POST: api/List public HttpResponseMessage Post([FromBody] ListTo value) { ListPersistence listP = new ListPersistence(); long id; id = listP.saveList(value); value.id = id; HttpResponseMessage resp = Request.CreateResponse(HttpStatusCode.Created); resp.Headers.Location = new Uri(Request.RequestUri, string.Format("list/{0}", id)); return(resp); }
public ArrayList getLists() { ArrayList listArray = new ArrayList(); MySqlDataReader reader = null; String sqlInquiry = "SELECT * FROM todo"; MySqlCommand comm = new MySqlCommand(sqlInquiry, conn); reader = comm.ExecuteReader(); while (reader.Read()) { ListTo listN = new ListTo(); listN.id = reader.GetInt32(0); listN.title = reader.GetString(1); listN.text = reader.GetString(2); listN.priority = reader.GetString(3); listArray.Add(listN); } return(listArray); }
public ListTo getList(long id) { ListTo listN = new ListTo(); MySqlDataReader reader = null; String sqlInquiry = "SELECT * FROM todo WHERE id=" + id.ToString(); MySqlCommand comm = new MySqlCommand(sqlInquiry, conn); reader = comm.ExecuteReader(); if (reader.Read()) { listN.id = reader.GetInt32(0); listN.title = reader.GetString(1); listN.text = reader.GetString(2); listN.priority = reader.GetString(3); return(listN); } else { return(null); } }