Exemplo n.º 1
0
        public JsonResult Guardar(ProcesosModel model)
        {
            var rm     = new ResponseModel();
            var entity = db.procesos_de_fabricacion.Where(x => x.ID == model.Id).FirstOrDefault();

            if (entity == null)
            {
                entity             = new procesos_de_fabricacion();
                entity.NOMBRE      = model.Nombre;
                entity.DESCRIPCION = model.Descripcion;
                entity.ACTIVO      = model.Activo;
                db.procesos_de_fabricacion.Add(entity);
            }
            else
            {
                entity.NOMBRE      = model.Nombre;
                entity.DESCRIPCION = model.Descripcion;
                entity.ACTIVO      = model.Activo;
            }
            if (db.SaveChanges() > 0)
            {
                rm.result   = true;
                rm.response = true;
                rm.message  = "Sus datos se guardaron correctamente";
                rm.function = "reload(true,'" + rm.message + "')";
            }
            return(Json(rm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public procesos_de_fabricacion GetById(int id, ArtexConnection dbContext = null)
        {
            procesos_de_fabricacion consulta = null;

            try
            {
                dbContext = dbContext != null ? dbContext : new ArtexConnection();

                consulta = dbContext.procesos_de_fabricacion.Where(e => e.ID == id).FirstOrDefault();
            }
            catch (Exception e)
            {
            }

            return(consulta);
        }
Exemplo n.º 3
0
        public JsonResult GetById(int id)
        {
            ProcesoFabricacionDAO   dao = new ProcesoFabricacionDAO();
            procesos_de_fabricacion 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));
        }
Exemplo n.º 4
0
        public JsonResult Guardar(ProcesoFabricacionModel 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())
            {
                ProcesoFabricacionDAO dao = new ProcesoFabricacionDAO();
                var entity = dao.GetById(model.Id, db);

                if (entity == null)
                {
                    entity             = new procesos_de_fabricacion();
                    entity.NOMBRE      = model.Nombre;
                    entity.DESCRIPCION = model.Descripcion;
                    entity.ACTIVO      = model.Activo;
                    db.procesos_de_fabricacion.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));
        }