Beispiel #1
0
        public JsonResult Get()
        {
            ComunaModel comunaQuery = new ComunaModel(new Comuna());

            ResponseMenssage response = new ResponseMenssage("success", comunaQuery.GetComunas());

            return(new JsonResult(response));
        }
Beispiel #2
0
        public JsonResult GetProvincias(int id_provincia)
        {
            Comuna comuna = new Comuna();

            comuna.Id_provincia = id_provincia;
            ComunaModel comunaQuery = new ComunaModel(comuna);

            ResponseMenssage response = new ResponseMenssage("success", comunaQuery.GetComunasByProvincia());

            return(new JsonResult(response));
        }
Beispiel #3
0
        public JsonResult Delete(int id)
        {
            ComunaModel comunaQuery = new ComunaModel(new Comuna());

            comunaQuery.Comuna.Id = id;

            if (comunaQuery.Delete())
            {
                ResponseMenssage response = new ResponseMenssage("success", comunaQuery.Comuna);
                return(new JsonResult(response));
            }
            else
            {
                ResponseMenssage response = new ResponseMenssage("error", "error al eliminar comuna");
                return(new JsonResult(response));
            }
        }
Beispiel #4
0
        public JsonResult Put(int id, [FromBody] Comuna comuna)
        {
            ComunaModel comunaQuery = new ComunaModel(comuna);

            comunaQuery.Comuna.Id = id;

            if (comunaQuery.Update())
            {
                ResponseMenssage response = new ResponseMenssage("success", comunaQuery.Comuna);
                return(new JsonResult(response));
            }
            else
            {
                ResponseMenssage response = new ResponseMenssage("error", "error al modificar comuna");
                return(new JsonResult(response));
            }
        }
Beispiel #5
0
        public JsonResult PostProvincia(int id_provincia, [FromBody] Comuna comuna)
        {
            comuna.Id_provincia = id_provincia;

            ComunaModel comunaQuery = new ComunaModel(comuna);


            if (comunaQuery.Create())
            {
                ResponseMenssage response = new ResponseMenssage("success", comunaQuery.Comuna);
                return(new JsonResult(response));
            }
            else
            {
                ResponseMenssage response = new ResponseMenssage("error", "error al crear comuna");
                return(new JsonResult(response));
            }
        }
Beispiel #6
0
        public JsonResult Get(int id)
        {
            Comuna comuna = new Comuna
            {
                Id = id
            };
            ComunaModel comunaQuery = new ComunaModel(comuna);


            if (comunaQuery.ReadById())
            {
                ResponseMenssage response = new ResponseMenssage("success", comunaQuery.Comuna);
                return(new JsonResult(response));
            }
            else
            {
                ResponseMenssage response = new ResponseMenssage("error", "comuna no encontrada");
                return(new JsonResult(response));
            }
        }