Esempio n. 1
0
        public IHttpActionResult PutPersona(int id, Persona persona)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != persona.idPersona)
            {
                return(BadRequest());
            }
            try
            {
                PersonaBLL.Update(persona);
                return(Content(HttpStatusCode.OK, "Persona actualizada correctamente"));
            }
            catch (Exception ex)
            {
                Persona per = PersonaBLL.Get(id);
                if (per == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
            }
        }
Esempio n. 2
0
 public IHttpActionResult GetPersona(int id)
 {
     try
     {
         Persona result = PersonaBLL.Get(id);
         if (result == null)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Esempio n. 3
0
        public IHttpActionResult DeletePersona(int id)
        {
            Persona persona = PersonaBLL.Get(id);

            if (persona == null)
            {
                return(NotFound());
            }
            try
            {
                PersonaBLL.Delete(id);
                return(Ok("Persona eliminada correctamente"));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex));
            }
        }