public JsonResult Replicar(int idLocalc, int[] ids)
        {
            TanoNEEntities ctx = new TanoNEEntities();

            Locales acopiar = ctx.Locales.FirstOrDefault(a => a.idLocal == idLocalc);

            foreach (int idlocal in ids)
            {
                List <ProductosLocales> todos = ctx.ProductosLocales.Where(a => a.localId == idlocal).ToList();
                foreach (ProductosLocales prod in todos)
                {
                    ctx.ProductosLocales.Remove(prod);
                }

                if (idlocal != idLocalc)
                {
                    List <ProductosLocales> productos = ctx.ProductosLocales.Where(a => a.localId == acopiar.idLocal).ToList();
                    foreach (ProductosLocales prod in productos)
                    {
                        ProductosLocales pl = new ProductosLocales();
                        pl.Locales   = ctx.Locales.FirstOrDefault(a => a.idLocal == idlocal);
                        pl.Productos = prod.Productos;
                        ctx.ProductosLocales.Add(pl);
                    }
                }
            }

            ctx.SaveChanges();


            return(Json(new { bien = true }, JsonRequestBehavior.DenyGet));
        }
        public JsonResult Asignar(int idLocal, int[] ids)
        {
            TanoNEEntities ctx = new TanoNEEntities();

            Locales local = ctx.Locales.FirstOrDefault(a => a.idLocal == idLocal);

            List <ProductosLocales> todos = ctx.ProductosLocales.Where(a => a.localId == local.idLocal).ToList();

            foreach (ProductosLocales prod in todos)
            {
                ctx.ProductosLocales.Remove(prod);
            }

            foreach (int idprod in ids)
            {
                ProductosLocales pl = new ProductosLocales();
                pl.Locales   = local;
                pl.Productos = ctx.Productos.FirstOrDefault(a => a.idProducto == idprod);
                ctx.ProductosLocales.Add(pl);
            }

            ctx.SaveChanges();


            return(Json(new { bien = true }, JsonRequestBehavior.DenyGet));
        }