// GET api/picture public Picture Get(string id, string picture_id) { Picture picture = new Picture(); picture = pictureManagerService.Get(picture_id); if (picture == null || picture.url_general == null) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No pictures with ID = {0}", id)), ReasonPhrase = "Pictures ID Not Found", StatusCode = HttpStatusCode.NotFound }; throw new HttpResponseException(resp); } return picture; }
private void addPicture(string item_id, Picture newPicture) { //pictures.Clear(); String _query = "exec [sp_api_newPicture] '" + newPicture.item_id + "'," + newPicture.num_photo + ",'" + newPicture.url_general + "','"+newPicture.path_general+"'"; //BaseDatos conexion = new BaseDatos("SQL"); //Creando objetos de la base de datos conexion.Conectar(); conexion.CrearComando(_query); //Comando indica que quiero encontrar DbDataReader DRConexion = conexion.EjecutarConsulta(); while (DRConexion.Read()) { picture = new Picture { id = int.Parse(DRConexion.GetDecimal(0).ToString()), item_id = DRConexion.GetString(1), num_photo = DRConexion.GetInt32(2), url_general = DRConexion.GetString(3) }; } conexion.Desconectar(); }
// POST api/picture public Picture Post(string id, Picture pictureBase) { Picture newPicture = pictureManagerService.Add(id, pictureBase); if (newPicture == null || newPicture.url_general == "") { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No picture with ID = {0}", id)), ReasonPhrase = "Picture ID Not Found", StatusCode = HttpStatusCode.NotFound }; throw new HttpResponseException(resp); } return newPicture; }
public Picture Add(string id, Picture newPicture) { addPicture(id, newPicture); return picture; }
private void getPicture(string id) { String _query = "exec [sp_api_getPicture] " + id; //BaseDatos conexion = new BaseDatos("SQL"); //Creando objetos de la base de datos conexion.Conectar(); conexion.CrearComando(_query); //Comando indica que quiero encontrar DbDataReader DRConexion = conexion.EjecutarConsulta(); while (DRConexion.Read()) { picture = new Picture { id = int.Parse(DRConexion.GetDecimal(0).ToString()), item_id = DRConexion.GetString(1), num_photo = DRConexion.GetInt32(2), url_general = DRConexion.GetString(3), path_general = DRConexion.GetString(4) }; } conexion.Desconectar(); }