public IActionResult ReadCSV(string file) { IAdjuntoService service = new AdjuntoService(DbContext); Response <List <Adjunto> > response = new Response <List <Adjunto> >(); try { List <Adjunto> p = service.migrateCsvData(file).Result; response.ok(true, p, "La siguiente lista fue migrada"); return(Ok(response)); } catch (Exception ex) { response.ok(false, new List <Adjunto>(), "Error al Migrar la data " + ex.Message); return(BadRequest(response)); } }
public IActionResult SaveAdjunto(Adjunto adjunto) { Response <Adjunto> response = new Response <Adjunto>(); try { IAdjuntoService service = new AdjuntoService(DbContext); Task <Adjunto> p = service.save(adjunto); response.ok(true, p.Result, "Se inserto el adjunto"); return(Ok(response)); } catch (Exception ex) { response.ok(false, null, "Error en el servicio " + ex.Message); return(BadRequest(response)); } }
public IActionResult DeleteAttachedById(int Id) { IAdjuntoService service = new AdjuntoService(DbContext); Response <Adjunto> response = new Response <Adjunto>(); try { Adjunto p = service.deleteById(Id).Result; response.ok(true, p, "Se cambio el estado a DELETE"); return(Ok(response)); } catch (Exception ex) { response.ok(false, new Adjunto(), "Error al cambiar estado " + ex.Message); return(BadRequest(response)); } }
public IActionResult Get() { Response <List <Adjunto> > response = new Response <List <Adjunto> >(); IAdjuntoService p = new AdjuntoService(DbContext); try { List <Adjunto> listAttached = p.finAll().Result; response.ok(true, listAttached, "Lista de adjuntos regristrados"); return(Ok(response)); } catch (Exception ex) { response.ok(false, new List <Adjunto>(), "No hay adjuntos en la lista"); return(BadRequest(response)); } }