public static LanguageBO getLanguageByLanguageId(string Id) { MongoCollection<Language> objCollection = db.GetCollection<Language>("c_Language"); LanguageBO objClass = new LanguageBO(); foreach (Language item in objCollection.Find(Query.EQ("_id", ObjectId.Parse(Id)))) { objClass.Id = item._id.ToString(); objClass.UserId = item.UserId.ToString(); objClass.Name = item.Name; break; } return objClass; }
public static void insertLanguage(LanguageBO objClass) { MongoCollection<BsonDocument> objCollection = db.GetCollection<BsonDocument>("c_Language"); var query = Query.And( Query.EQ("Name", objClass.Name), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (!result.Any()) { BsonDocument doc = new BsonDocument { { "UserId" , ObjectId.Parse(objClass.UserId) }, { "Name" , objClass.Name }, }; var rt = objCollection.Insert(doc); } }
public static void updateLanguage(LanguageBO objLanguage) { LanguageDAL.updateLanguage(objLanguage); }
public static void updateLanguage(LanguageBO objClass) { MongoCollection<Language> objCollection = db.GetCollection<Language>("c_Language"); var query = Query.EQ("_id", ObjectId.Parse(objClass.Id)); var sortBy = SortBy.Descending("_id"); var update = Update.Set("UserId", ObjectId.Parse(objClass.UserId)) .Set("Name", objClass.Name) ; var result = objCollection.FindAndModify(query, sortBy, update, true); }
public static void insertLanguage(LanguageBO objLanguage) { LanguageDAL.insertLanguage(objLanguage); }