Example #1
0
 public static bool deleteEmployee(string searchID)
 {
     bool status;
     var response = ConnectionToES.EsClient().Delete<DocumentAttributes>(searchID, d => d
     .Index("employee")
     .Type("doc"));
     if (response.IsValid)
     {
         status = true;
     }
     else
     {
         status = false;
     }
     return status;
 }
Example #2
0
 public static Tuple<string, string, string, string> GetEmployeeByID(string ID)
 {
     string id = "";
     string name = "";
     string address = "";
     string MobileNo = "";
     var response = ConnectionToES.EsClient().Search<DocumentAttributes>(s => s
     .Index("employee")
     .Type("doc")
     .Query(q => q.Term(t => t.Field("_id").Value(ID)))); //Search based on employeeID
     foreach (var hit in response.Hits)
     {
         id = hit.Id.ToString();
         name = Convert.ToString(hit.Source.name);
         address = Convert.ToString(hit.Source.address);
         MobileNo = Convert.ToString(hit.Source.MobileNo);
     }
     return Tuple.Create(id, name, address, MobileNo);
 }
Example #3
0
 public static DataTable getAllDocument()
 {
     DataTable dataTable = new DataTable("Employee");
     dataTable.Columns.Add("ID", typeof(string));
     dataTable.Columns.Add("Name", typeof(string));
     dataTable.Columns.Add("address", typeof(string));
     dataTable.Columns.Add("MobileNo", typeof(string));
     var res = ConnectionToES.EsClient().Search<Employee>(s => s
     .Index("employee")
     .Type("doc")
     .From(0)
     .Size(1000)
     .Query(q => q.MatchAll()));
     foreach (var hit in res.Hits)
     {
         dataTable.Rows.Add(hit.Id.ToString(), Convert.ToString(hit.Source.name), Convert.ToString(hit.Source.address), Convert.ToString(hit.Source.MobileNo));
     }
     return dataTable;
 }
Example #4
0
 public static bool insertEmployee(int ID, string Name, string Address, string MobileNO)
 {
     bool status;
     var myJson = new
     {
         name = Name,
         address = Address,
         MobileNo = MobileNO
     };
     var response = ConnectionToES.EsClient().Index(myJson, i => i.Index("employee").Type("doc").Id(ID));
     if (response.IsValid)
     {
         status = true;
     }
     else
     {
         status = false;
     }
     return status;
 }
Example #5
0
 public static bool updateEmployee(int ID, string Name, string Address, string MobileNO)
 {
     bool status;
     var response = ConnectionToES.EsClient().Update<DocumentAttributes, UpdateDocumentAttributes>(ID, d => d
     .Index("employee")
     .Type("doc")
     .Doc(new UpdateDocumentAttributes
     {
         name = Name,
         address = Address,
         MobileNo = MobileNO
     }));
     if (response.IsValid)
     {
         status = true;
     }
     else
     {
         status = false;
     }
     return status;
 }