示例#1
0
        // GET: api/List/5
        public ListTo Get(int id)
        {
            ListPersistence listP  = new ListPersistence();
            ListTo          listTo = listP.getList(id);

            return(listTo);
        }
示例#2
0
        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);
        }
示例#3
0
        // 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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }