public static void DeleteUserItem(int UserId, string Id) { try { using (var client = new WebClient()) { client.Encoding = Encoding.UTF8; client.UploadString(TopSecret.ElasticUrl + UserId + "/" + Id, "DELETE", ""); } } catch (Exception e) { Log.LogInfo(e.Message, "error while deleting search index"); } }
public static void DeleteUserItem(int UserId, string Id) { try { var item = Utils.search_db.Table <UsersItem>().Where(f => f.UserId == UserId && f.ID == Id).SelectEntity().FirstOrDefault(); if (item == null) { throw new Exception("Item not found"); } Utils.search_db.Table <UsersItem>().Delete(item.Id); } catch (Exception e) { Log.LogInfo(e.Message, e, "error while deleting search index"); } }
public static void PutUserItem(UsersItem item) { try { JavaScriptSerializer ser = new JavaScriptSerializer(); ser.MaxJsonLength = Int32.MaxValue; string data = ser.Serialize(item); using (var client = new WebClient()) { client.Encoding = Encoding.UTF8; client.UploadString(TopSecret.ElasticUrl + item.UserId + "/" + item.ID, "PUT", data); } } catch (Exception e) { Log.LogInfo(e.Message, "error while putting to search index"); } }