public List <ItemCollection> GetByTerm(string q)
        {
            var result = ConnElastic.EsClient().Search <ItemCollection>(s => s
                                                                        .Index("basecollection")
                                                                        .Type("itemcollection")
                                                                        .Query(query => query
                                                                               .QueryString(qs => qs.Query(q))));

            return(result.Documents.ToList());
        }
Esempio n. 2
0
        public List <Contact> GetByTerm(string q)
        {
            var Result = ConnElastic.EsClient().Search <Contact>(s => s
                                                                 .Index("basecollection")
                                                                 .Type("contact")
                                                                 .Query(query => query
                                                                        .QueryString(qs => qs.Query(q))));

            return(Result.Documents.ToList());
        }
Esempio n. 3
0
 public void Delete(string q)
 {
     try
     {
         ConnElastic.EsClient().Delete <Contact>(q, p => p.Index("basecollection").Type("contact"));
     }
     catch
     {
         throw new Exception("Não foi possivel remover esse contato");
     }
 }
Esempio n. 4
0
 public void Create(Contact ct)
 {
     try
     {
         ConnElastic.EsClient().Index(ct, i => i.Index("basecollection").Type("contact").Refresh());
     }
     catch
     {
         throw new Exception("Houve um erro ao tentar inserir esse contato");
     }
 }
 public void Delete(string q)
 {
     try
     {
         ConnElastic.EsClient().Delete <ItemCollection>(q, p => p.Index("basecollection").Type("itemcollection"));
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }
Esempio n. 6
0
        public List <Contact> GetAll()
        {
            var response = ConnElastic.EsClient().Search <Contact>(s => s.Index("basecollection").Type("contact"));

            var result = response.Hits.Select(h =>
            {
                h.Source.Id = h.Id;
                return(h.Source);
            }).ToList();

            return(result);
        }
 public void Create(ItemCollection item)
 {
     try
     {
         item.IdContact = "0";
         ConnElastic.EsClient().Index(item, i => i.Index("basecollection").Type("itemcollection").Refresh());
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }
Esempio n. 8
0
        public Contact GetById(string q)
        {
            var result = ConnElastic.EsClient().Search <Contact>(s => s
                                                                 .Index("basecollection")
                                                                 .Type("contact")).Hits.ToList();

            var ob = new Contact();

            for (int i = 0; i < result.Count; i++)
            {
                if (result[i].Id == q)
                {
                    ob = result[i].Source;
                    return(ob);
                }
            }
            return(null);
        }
 public void Loan(ItemCollection loan)
 {
     try
     {
         ConnElastic.EsClient().Update <ItemCollection, dynamic>(new Nest.DocumentPath <ItemCollection>(loan.Id), q => q
                                                                 .Index("basecollection")
                                                                 .Type("itemcollection")
                                                                 .Doc(new ItemCollection
         {
             Status    = loan.Status,
             IdContact = loan.IdContact
         }).Refresh());
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }
Esempio n. 10
0
 public void Edit(Contact ct)
 {
     try
     {
         ConnElastic.EsClient().Update <Contact>(ct.Id, q => q
                                                 .Index("basecollection")
                                                 .Type("contact")
                                                 .Doc(new Contact
         {
             Name  = ct.Name,
             Email = ct.Email,
             Phone = ct.Phone
         }).Refresh());
     }
     catch
     {
         throw new Exception("Não foi possivel alterar esse contato");
     }
 }
 public void Edit(ItemCollection item)
 {
     try
     {
         ConnElastic.EsClient().Update <ItemCollection>(item.Id, q => q
                                                        .Index("basecollection")
                                                        .Type("itemcollection")
                                                        .Doc(new ItemCollection
         {
             Name      = item.Name,
             Type      = item.Type,
             Author    = item.Author,
             Location  = item.Location,
             Status    = item.Status,
             IdContact = item.IdContact
         }).Refresh());
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }