public eRESULT FindByName <T>(ref T obj, string objName) { eRESULT result = eRESULT.ERROR; if (_client != null) { var filter = new BsonDocument("$and", new BsonArray { new BsonDocument("Name", objName), new BsonDocument("ObjType", typeof(T).Name) }); obj = findObj <T>(filter).GetAwaiter().GetResult(); if (obj != null) { result = eRESULT.SUCCESS; } else if (obj == null) { result = eRESULT.OBJ_ABSENT; } } else { result = eRESULT.ERROR_CONNECT_TO_DB; } return(result); }
public eRESULT DeleteObj <T>(string objName) { eRESULT result = eRESULT.ERROR; if (_client != null) { var filter = new BsonDocument("$and", new BsonArray { new BsonDocument("Name", objName), new BsonDocument("ObjType", typeof(T).Name) }); bool isDeleted = deleteObj <T>(filter).GetAwaiter().GetResult(); if (isDeleted == true) { result = eRESULT.SUCCESS; } else { result = eRESULT.ERROR; } } else { result = eRESULT.ERROR_CONNECT_TO_DB; } return(result); }
public eRESULT InsertObj <T>(T obj) { eRESULT result = eRESULT.ERROR; if (_client != null) { insertObj <T>(obj).GetAwaiter(); } else { result = eRESULT.ERROR_CONNECT_TO_DB; } return(result); }