Exemple #1
0
        public void DesassociarPromocaoNoticia(TagPromocao tag)
        {
            ZAdmin_DB.Model.zeengEntities db = new ZAdmin_DB.Model.zeengEntities();

            /*
             * FONTES:
             * 1 -> knewin
             * 2 -> interna
             */

            var idNoticia = 0;

            if (tag.fonteNoticia == 1)
            {
                idNoticia = db.noticias.Where(n => n.idnoticia_knewin == tag.idNoticia).Select(r => r.idnoticia).FirstOrDefault();
            }
            else
            {
                idNoticia = tag.idNoticia;
            }

            var noticiaExiste = db.promo_promonoticias.Where(x => x.idnoticia == idNoticia && x.idpromocao == tag.idpromocao).FirstOrDefault();

            if (noticiaExiste != null)
            {
                db.promo_promonoticias.Attach(noticiaExiste);
                db.promo_promonoticias.Remove(noticiaExiste);
                db.SaveChanges();
            }

            var listaNoticPromo = (from pro in db.promo_promocoes
                                   join n in db.promo_promonoticias on pro.idpromocao equals n.idpromocao
                                   where n.idnoticia == idNoticia
                                   select new { idpromocao = pro.idpromocao, nome = pro.nome }).ToList();


            var node     = new Uri(_server);
            var settings = new ConnectionSettings(node);

            settings.DisableDirectStreaming(true);
            settings.DefaultIndex(_indexElastic + "noticias");

            var client = new ElasticClient(settings);

            client.Update <Noticias, object>(
                idNoticia,
                d => d.Doc(new { promocoes = listaNoticPromo })
                );

            AtualizaNoticiasEmPromocaoElastic(tag.idpromocao);
        }
Exemple #2
0
        public void DesassociarPromocaoNoticia(ZAdmin_RN.Promocao.TagPromocao tag)
        {
            var RN = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            RN.DesassociarPromocaoNoticia(tag);
        }