public bool addLessonInfo(Lessons lessonInfo) { try { lessonInfo._id = lessonInfo.LessonID; var collect = this.mongoDatabase.GetCollection(LESSON_COLLECTION); var result = collect.Insert<Lessons>(lessonInfo); return true; } catch (Exception exp) { Console.WriteLine(exp.ToString()); return false; } }
public bool updateLessonInfo(Lessons lessonInfo) { try { var collect = this.mongoDatabase.GetCollection(LESSON_COLLECTION); var query = new QueryDocument { { "LessonID", lessonInfo.LessonID } }; var update = new UpdateDocument { { "$set", new QueryDocument { { "LessonGroup", lessonInfo.LessonGroup}, { "LessonName", lessonInfo.LessonName}, { "Author", lessonInfo.Author}, { "LessonURL", lessonInfo.LessonURL}, { "ScriptURL", lessonInfo.ScriptURL}, { "LessonForder", lessonInfo.LessonForder}, { "ServerUrl", lessonInfo.ServerUrl}, { "Status", lessonInfo.Status}, { "Description", lessonInfo.Description}, { "VideoURL", lessonInfo.VideoURL} } } }; var result = collect.Update(query, update); var Affected = result.DocumentsAffected.ToString(); if (Affected != "0") { return true; } else { return false; } } catch (Exception exp) { Console.WriteLine(exp.ToString()); return false; } }
public bool changeLessonStatus(Lessons lessonInfo) { try { var collect = this.mongoDatabase.GetCollection(LESSON_COLLECTION); var query = new QueryDocument { { "LessonID", lessonInfo.LessonID } }; var update = new UpdateDocument { { "$set", new QueryDocument { { "Status", lessonInfo.Status} } } }; var result = collect.Update(query, update); var Affected = result.DocumentsAffected.ToString(); if (Affected != "0") { return true; } else { return false; } } catch (Exception exp) { Console.WriteLine(exp.ToString()); return false; } }