예제 #1
0
        public IActionResult PutPlaga(int Id, [FromBody] Plaga plaga)
        {
            try
            {
                plagas = new PlagaRepositor(_config, Request);

                if (Id != plaga.id)
                {
                    throw new Exception("La petición no se realizó correctamente");
                }

                if (!plagas.Exist(Id))
                {
                    throw new Exception("La plaga no existe");
                }

                plagas.Actualizar(plaga);

                return(Ok(new
                {
                    statusCode = 200,
                    message = "success",
                    plaga = plagas.Actualizar(plaga)
                }));
            }
            catch (Exception ex)
            {
                return(new ResponseContext().getFauilureResponse(ex));
            }
        }
예제 #2
0
        public IActionResult DeletePlaga(int Id)
        {
            try
            {
                plagas = new PlagaRepositor(_config, Request);

                if (!plagas.Exist(Id))
                {
                    throw new Exception("La plaga no existe");
                }

                plagas.Borrar(Id);

                return(Ok(new
                {
                    statusCode = 200,
                    message = "success"
                }));
            }
            catch (Exception ex)
            {
                return(new ResponseContext().getFauilureResponse(ex));
            }
        }