// GET api/<controller> /// <summary> /// Retrieve a list of dvd items that match your criteria (All fields are optional. If no fields are given all items will be retrieved) /// </summary> /// <param name="title">The title of the DVD</param> /// <param name="release_year">The year the movie was released on DVD</param> /// <param name="rating">The movies MPAA rating</param> public ArrayList Get(string title = null, int?release_year = null, string rating = null) { DVDPersistence dvdp = new DVDPersistence(); dvdp.addCallField("title", title, System.Data.SqlDbType.VarChar, 50); dvdp.addCallField("release_year", release_year, System.Data.SqlDbType.Int, 4); dvdp.addCallField("rating", rating, System.Data.SqlDbType.VarChar, 50); return(dvdp.GetAll()); }
// GET api/<controller>/5 /// <summary> /// Retrieve a dvd item with the specified item_id /// </summary> /// <param name="item_id">ID generated by database upon its creation</param> public DVD Get(int item_id) { DVDPersistence dvdp = new DVDPersistence(); dvdp.addCallField("item_id", item_id, System.Data.SqlDbType.Int, 4); return((DVD)dvdp.Get()); }
// DELETE api/<controller>/5 /// <summary> /// Delete the dvd item with a specified item_id /// </summary> /// <param name="item_id">ID generated by database upon its creation</param> public HttpResponseMessage Delete(int item_id) { DVDPersistence tp = new DVDPersistence(); tp.addCallField("item_id", item_id, System.Data.SqlDbType.Int, 4); bool recordExisted = tp.Delete(); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
// PUT api/<controller>/5 /// <summary> /// Update an existing dvd item with a specified item_id /// </summary> /// <param name="item_id">ID generated by database upon its creation</param> public HttpResponseMessage Put(int item_id, [FromBody] DVD value) { DVDPersistence dvdp = new DVDPersistence(); dvdp.addCallField("item_id", item_id, System.Data.SqlDbType.Int, 4); bool recordExisted = dvdp.Update(value); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }