public ActionResult DeleteConfirmed(Guid id)
        {
            MostrarAtributo mostrarAtributo = db.MostrarAtributos.Find(id);

            db.MostrarAtributos.Remove(mostrarAtributo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Lista(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var tipoPieza = db.TipoPiezas.Find(id);

            if (tipoPieza == null)
            {
                return(HttpNotFound());
            }

            tipoPieza.Atributos = tipoPieza.Atributos.OrderBy(a => a.Orden).ToList();

            var listaTM = db.TipoMostarlos.Where(a => a.Status).OrderBy(a => a.Nombre).ToList();

            foreach (var att in tipoPieza.Atributos)
            {
                //buscar si att esta en listaTM
                foreach (var tm in listaTM)
                {
                    var x = tm.MostrarAtributos.Where(a => a.AtributoID == att.AtributoID).FirstOrDefault();

                    if (x == null)
                    {
                        x = new MostrarAtributo()
                        {
                            TipoMostrarID = tm.TipoMostrarID,
                            AtributoID    = att.AtributoID,
                            Status        = false,
                            Orden         = att.Orden
                        };


                        db.MostrarAtributos.Add(x);
                        db.SaveChanges();
                    }
                }

                att.MostrarAtributos = att.MostrarAtributos.Where(a => a.TipoMostrar.Status).OrderBy(a => a.TipoMostrar.Nombre).ToList();
            }

            ViewBag.totalRegistros = tipoPieza.Atributos.Count;
            ViewBag.id             = tipoPieza.TipoPiezaID;
            ViewBag.nombre         = tipoPieza.Nombre;
            ViewBag.listaTM        = db.TipoMostarlos.Where(a => a.Status).Select(a => a.Nombre).OrderBy(a => a).ToList();


            return(PartialView("_Lista", tipoPieza.Atributos));
        }
        // GET: MostrarAtributo/Eliminar/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MostrarAtributo mostrarAtributo = db.MostrarAtributos.Find(id);

            if (mostrarAtributo == null)
            {
                return(HttpNotFound());
            }
            return(View(mostrarAtributo));
        }
        public ActionResult Editar(Guid?id, Guid?AtributoID)
        {
            if (id == null || AtributoID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MostrarAtributo mostrarAtributo = db.MostrarAtributos.Find(id, AtributoID);

            if (mostrarAtributo == null)
            {
                return(HttpNotFound());
            }

            return(PartialView("_Editar", mostrarAtributo));
        }
        public ActionResult Editar([Bind(Include = "TipoMostrarID,AtributoID,Orden,InicioHTML,FinHTML,Status")] MostrarAtributo mostrarAtributo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(mostrarAtributo).State = EntityState.Modified;
                db.SaveChanges();

                var TipoPiezaID = db.Atributos.FirstOrDefault(a => a.AtributoID == mostrarAtributo.AtributoID).TipoPiezaID;
                var Nombre      = db.TipoMostarlos.FirstOrDefault(a => a.TipoMostrarID == mostrarAtributo.TipoMostrarID).Nombre;


                AlertaInfo(string.Format("Mostrar en: <b>{0}</b> editado.", Nombre), true);

                string url = Url.Action("Lista", "Atributo", new { id = TipoPiezaID });

                return(Json(new { success = true, url = url }));
            }

            return(PartialView("_Editar", mostrarAtributo));
        }