Exemple #1
0
 // DELETE api/<controller>/5
 public bool Delete(string clave)
 {
     try
     {
         ServiciosLogica logica = new ServiciosLogica();
         return(logica.EliminarSubCategoria(clave));
     }
     catch (Exception ex)
     {
         string mensaje   = ex.Message;
         var    respuesta = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content      = new StringContent(string.Format(mensaje)),
             ReasonPhrase = "Error al Elimnar  SubCategoria: " + ex.Message.Replace("\n", "").Replace("\r", "")
         };
         throw new HttpResponseException(respuesta);
     }
 }
Exemple #2
0
 // POST api/<controller>
 public bool Post(SubCategoria entidad)
 {
     try
     {
         ServiciosLogica logica = new ServiciosLogica();
         return(logica.InsertarSubCategoria(entidad));
     }
     catch (Exception ex)
     {
         string mensaje   = ex.Message;
         var    respuesta = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content      = new StringContent(string.Format(mensaje)),
             ReasonPhrase = "Error al Obtener Lista de SubCategorias: " + ex.Message.Replace("\n", "").Replace("\r", "")
         };
         throw new HttpResponseException(respuesta);
     }
 }
Exemple #3
0
 // GET api/<controller>
 public HttpResponseMessage Get()
 {
     try
     {
         ServiciosLogica   Srv   = new ServiciosLogica();
         ListaSubCategoria Lista = Srv.ObtenerSubCategoria();
         var response            = Request.CreateResponse <IEnumerable <SubCategoria> >(System.Net.HttpStatusCode.Created, Lista);
         return(response);
     }
     catch (Exception ex)
     {
         var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content      = new StringContent(string.Format(ex.Message)),
             ReasonPhrase = "Error al Obtener Lista de Sub Categoria: " + ex.Message.Replace("\n", "").Replace("\r", "")
         };
         throw new HttpResponseException(resp);
     }
 }
        // PUT: api/Cliente/5
        public bool Put([FromBody] Cliente entidad)
        {
            try
            {
                ServiciosLogica srv = new ServiciosLogica();
                return(srv.EditarCliente(entidad));
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;

                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent(string.Format(mensaje)),
                    ReasonPhrase = "Error al Editar Cliente : " + mensaje.Replace("\n", "").Replace("\r", "")
                };
                throw new HttpResponseException(resp);
            }
        }