Esempio n. 1
0
        public linea_negocio GetById(int id, ArtexConnection dbContext = null)
        {
            linea_negocio consulta = null;

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

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

            return(consulta);
        }
Esempio n. 2
0
        public JsonResult GetById(int id)
        {
            LineaNegocioDAO dao = new LineaNegocioDAO();
            linea_negocio   c   = dao.GetById(id, db);

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

            return(Json(jsnResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public lineaDTO LineaNegocioDTO(linea_negocio linea, factor_canal_linea factorLinea)
        {
            var dto = new lineaDTO();

            dto.ID     = linea.ID;
            dto.NOMBRE = linea.NOMBRE;

            if (factorLinea != null)
            {
                dto.FACTOR_POP        = factorLinea.FACTOR_POP;
                dto.FACTOR_FRANQUICIA = factorLinea.FACTOR_FRANQUICIA;
                dto.FACTOR_CADENAS    = factorLinea.FACTOR_CADENAS;
                dto.FACTOR_PROYECTOS  = factorLinea.FACTOR_PROYECTOS;
            }



            return(dto);
        }
Esempio n. 4
0
        public JsonResult Guardar(LineaNegocioModel 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));
            }


            LineaNegocioDAO dao    = new LineaNegocioDAO();
            var             entity = dao.GetById(model.Id, db);

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