public ActionResult Get(string id) { try { using (XTEC_DigitalContext db = new XTEC_DigitalContext()) { Carpetum carpetum = db.Carpeta.Find(id); return(Ok(carpetum)); } } catch { return(BadRequest("Item no encontrado")); } }
public ActionResult Delete(string id) { try { using (XTEC_DigitalContext db = new XTEC_DigitalContext()) { Carpetum carpetum = db.Carpeta.Find(id); db.Carpeta.Remove(carpetum); db.SaveChanges(); } return(Ok("Eliminacion realizada")); } catch { return(BadRequest("Eliminacion no realizada")); } }
public ActionResult Put(string id, [FromBody] Carpetum carpetumModel) { try { using (XTEC_DigitalContext db = new XTEC_DigitalContext()) { Carpetum carpetum = db.Carpeta.Find(id); carpetumModel.Nombre = carpetumModel.Nombre; carpetumModel.RutaUrl = carpetumModel.RutaUrl; carpetumModel.GrupoId = carpetumModel.GrupoId; db.Entry(carpetum).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); } return(Ok("Actualizacion realizada")); } catch { return(BadRequest("Actualizacion no realizada")); } }
public ActionResult Post([FromBody] Carpetum carpetumModel) { try { using (XTEC_DigitalContext db = new XTEC_DigitalContext()) { Carpetum carpetum = new Carpetum(); carpetum.CarpetaId = carpetumModel.CarpetaId; carpetumModel.Nombre = carpetumModel.Nombre; carpetumModel.RutaUrl = carpetumModel.RutaUrl; carpetumModel.GrupoId = carpetumModel.GrupoId; db.Carpeta.Add(carpetum); db.SaveChanges(); } return(Ok("Carpeta agregado")); } catch { return(BadRequest("No se pudo agregar la carpeta")); } }