示例#1
0
        public JsonResult GetById(int id)
        {
            TipoPedidoDAO dao = new TipoPedidoDAO();
            tipo_pedido   c   = dao.GetById(id);

            var jsnResult = new
            {
                ID          = c.ID,
                NOMBRE      = c.NOMBRE,
                DESCRIPCION = c.DESCRIPCION,
                ACTIVO      = c.ACTIVO,
                Success     = true
            };

            return(Json(jsnResult, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public JsonResult Delete(int id)
        {
            var rm = new ResponseModel();


            TipoPedidoDAO dao = new TipoPedidoDAO();

            rm.response = dao.DeleteById(id);

            if (rm.response)
            {
                rm.message = "El registro  se elimino correctamente";
            }

            return(Json(rm, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public JsonResult Guardar(TipoPedidoModel model)
        {
            var rm = new ResponseModel();

            if (!ModelState.IsValid)
            {
                rm.message  = "Hubo un problema verifique sus datos e intente de nuevo.";
                rm.message += ExtensionMethods.GetAllErrorsFromModelState(this);
                return(Json(rm, JsonRequestBehavior.AllowGet));
            }


            using (ArtexConnection db = new ArtexConnection())
            {
                TipoPedidoDAO dao    = new TipoPedidoDAO();
                var           entity = dao.GetById(model.Id, db);

                if (entity == null)
                {
                    entity             = new tipo_pedido();
                    entity.NOMBRE      = model.Nombre;
                    entity.DESCRIPCION = model.Descripcion;
                    entity.ACTIVO      = model.Activo;
                    db.tipo_pedido.Add(entity);
                }
                else
                {
                    entity.NOMBRE      = model.Nombre;
                    entity.DESCRIPCION = model.Descripcion;
                    entity.ACTIVO      = model.Activo;
                }

                if (db.SaveChanges() > 0 || db.Entry(entity).State == EntityState.Unchanged)
                {
                    rm.response = true;
                    rm.message  = "Sus datos se guardaron correctamente";
                    rm.function = "reload(true,'" + rm.message + "')";
                }
            }


            return(Json(rm, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public ActionResult GetAlls()
        {
            List <tipo_pedido> consulta = TipoPedidoDAO.GetAlls();

            var jsonData = new
            {
                rows = (
                    from c in consulta
                    select new
                {
                    ID = c.ID,
                    NOMBRE = c.NOMBRE,
                    DESCRIPCION = c.DESCRIPCION,
                    ACTIVO = c.ACTIVO,
                }).ToArray()
            };

            return(Json(jsonData.rows, JsonRequestBehavior.AllowGet));
        }