Ejemplo n.º 1
0
        public JsonResult Add(OPERACION ope)
        {
            string exist = "";

            try
            {
                if (ope.ID == 0)
                {
                    //ADD
                    var existe = repository.GetAll().Where(x => x.NOMBRE == ope.NOMBRE && x.ACTIVO == true && x.ID > 0).FirstOrDefault();
                    if (existe != null)
                    {
                        exist = ":( " + Environment.NewLine + existe.NOMBRE;
                    }
                    else
                    {
                        ope.FECHA_ALTA = DateTime.Now;
                        ope.ACTIVO     = true;
                        repository.Add(ope);
                    }
                }
                else
                {
                    //UPDATE
                    var existe = repository.GetAll().Where(x => x.ID != ope.ID && x.NOMBRE == ope.NOMBRE && x.ACTIVO == true).FirstOrDefault();
                    if (existe != null && existe.ACTIVO)
                    {
                        exist = ":( " + Environment.NewLine + existe.NOMBRE;
                    }
                    else
                    {
                        //GET OBJECT OPERACION
                        var o = repository.GetAll().Where(x => x.ID == ope.ID).FirstOrDefault();


                        //UPDATE OPERACION TABLE
                        o.FECHA_MOD = DateTime.Now;
                        o.NOMBRE    = ope.NOMBRE;
                        repository.Update(o);
                    }
                }
            }
            catch (Exception ex)
            {
                var ajas = ex.ToString();
                return(null);
            }


            if (exist != null && exist != "")
            {
                return(Json(new { exist }));
            }


            return(List());
        }
        public static Operacion MapOperacionesToBizEntity(OPERACION operacion)
        {
            return(new Operacion

            {
                ID_OPERACION = operacion.ID_OPERACION,
                NOMBRE = operacion.NOMBRE,
                URL = operacion.URL,
                ID_OPERACION_PADRE = operacion.ID_OPERACION_PADRE,
                VISIBLE_MENU = operacion.VISIBLE_MENU
            });
        }
Ejemplo n.º 3
0
        public JsonResult Filter(OPERACION ope)
        {
            try
            {
                var o = repository.GetAll().Select(
                    x => new
                {
                    x.ID,
                    x.NOMBRE,
                    x.ACTIVO,
                    FECHA_ALTA = x.FECHA_ALTA.ToShortDateString()
                }).Where(p => p.ACTIVO == true && p.ID == ope.ID).ToList();

                return(Json(o, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        //Agrego el menu
        public bool AgregarMenuCabecera(String NombreMenu, String Url, Boolean EsPadre, int MenuPadre)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                OPERACION nueva = new OPERACION();
                nueva.VISIBLE_MENU = "S";
                nueva.URL          = Url;
                if (!EsPadre)
                {
                    nueva.ID_OPERACION_PADRE = MenuPadre;
                }
                nueva.NOMBRE = NombreMenu;

                ctx.OPERACION.InsertOnSubmit(nueva);


                ctx.SubmitChanges();

                InsertarOperacionAlPerfil(MenuPadre, nueva.ID_OPERACION);
            }
            return(true);
        }