public ActionResult <PaisResponse> Get(int id) { IResponse <PaisEntity> respuesta = new PaisResponse(); try { PaisEntity pais = _paisService.FindById(id); if (pais != null) { respuesta.Resultado = "S"; respuesta.Datos.Add(pais); } else { respuesta.Resultado = "N"; respuesta.Mensaje = "País no encontrado"; } } catch (Exception ex) { respuesta.Resultado = "E"; respuesta.Mensaje = ex.Message.ToString(); } return(Ok(respuesta)); }
public ActionResult <PaisResponse> Put(int id, [FromBody] PaisRequest.PaisUpdate updatePais) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } IResponse <PaisEntity> respuesta = new PaisResponse(); try { PaisEntity pais = _paisService.Update(id, updatePais); respuesta.Resultado = "S"; respuesta.Datos.Add(pais); } catch (Exception ex) { respuesta.Resultado = "E"; respuesta.Mensaje = ex.Message.ToString(); } return(Ok(respuesta)); }
public TweetResponse() { Usuario = new UsuarioResponse(); Tags2 = new List <TagResponse>(); Pais = new PaisResponse(); Idioma = new IdiomaResponse(); }
public ActionResult <PaisResponse> Delete(int id) { IResponse <PaisEntity> respuesta = new PaisResponse(); try { bool resDelete = _paisService.Delete(id); respuesta.Resultado = resDelete == true ? "S" : "N"; } catch (Exception ex) { respuesta.Resultado = "E"; respuesta.Mensaje = ex.Message.ToString(); } return(Ok(respuesta)); }
public ActionResult <PaisResponse> Get() { IResponse <PaisEntity> respuesta = new PaisResponse(); try { List <PaisEntity> paises = _paisService.Find() ?? new List <PaisEntity>(); respuesta.Resultado = "S"; respuesta.Datos = paises; } catch (Exception ex) { respuesta.Resultado = "E"; respuesta.Mensaje = ex.Message.ToString(); } return(Ok(respuesta)); }