public bool Post(Classes ClassesObj)
 {
     //ClassesObj._id = ClassesObj.ClassName;
     ClassesObj.LastChangeTime = DateTime.Now;
     ClassesObj.CreatedTime = DateTime.Now;
     ClassesObj.ClassStatus = "inactive";
     opm.ConnDatabase(strconn);
     var result = opm.addClass(ClassesObj);
     return result;
 }
        public bool addClass(Classes ClassesIfo)
        {
            try
            {

                var collect = this.mongoDatabase.GetCollection(CLASS_COLLECTION);
                var result = collect.Insert<Classes>(ClassesIfo);
                var Affected = result.DocumentsAffected.ToString();
                return true;
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
                return false;

            }
        }
 public bool Put(string id, Classes ClassesObj)
 {
     opm.ConnDatabase(strconn);
     if (id == "ModifyClassStudents")
     {
         var result = opm.updateClassStudentsInfo(ClassesObj);
         return result;
     }
     else if (id == "ModifySelectedLessonsInfo")
     {
         var result = opm.updateClassSelectedLessonInfo(ClassesObj);
         return result;
     }
     else if (id == "ModifyClassBasicInfo")
     {
         ClassesObj.LastChangeTime = DateTime.Now;
         var result = opm.UpdateClassBasicInfo(ClassesObj);
         return result;
     }
     else if (id == "ModifyClassStadyURL")
     {
         ClassesObj.LastChangeTime = DateTime.Now;
         var result = opm.UpdateClassStadyURL(ClassesObj);
         return result;
     }
     else if (id == "ModifyUpdateClassInfo")
     {
         ClassesObj.LastChangeTime = DateTime.Now;
         var result = opm.updateClassInfo(ClassesObj);
         return result;
     }
     else if (id == "ModifyClassStatus")
     {
         ClassesObj.LastChangeTime = DateTime.Now;
         var result = opm.updateClassStatus(ClassesObj);
         return result;
     }
     else
     {
         return false;
     }
 }
        public bool updateClassStudentsInfo(Classes ClassesInfo)
        {
            try
            {
                var collect = this.mongoDatabase.GetCollection(CLASS_COLLECTION);
                var query = Query<Classes>.EQ(p => p._id, ClassesInfo._id);
                var update = Update<Classes>.Set(i => i.StudentGroup, ClassesInfo.StudentGroup);

                collect.Update(query, update);
                return true;

            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
                return false;

            }
        }
        // update ClassStatus
        public bool updateClassStatus(Classes ClassesInfo)
        {
            try
            {
                var collect = this.mongoDatabase.GetCollection(CLASS_COLLECTION);
                var query = new QueryDocument { { "ClassName", ClassesInfo.ClassName } };
                var update = new UpdateDocument {
                { "$set", new QueryDocument {
                { "ClassStatus", ClassesInfo.ClassStatus}
                } } };
                var result = collect.Update(query, update);
                return true;
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
                return false;

            }
        }
        public bool updateClassInfo(Classes ClassesInfo)
        {
            try
            {
                var collect = this.mongoDatabase.GetCollection(CLASS_COLLECTION);
                var query = Query<Classes>.EQ(p => p._id, ClassesInfo._id);
                var update = Update<Classes>.Set(i => i.StudentGroup, ClassesInfo.StudentGroup)
                            .Set(i => i.SeletedLeassons, ClassesInfo.SeletedLeassons)
                            .Set(i => i.StudyStartTime, ClassesInfo.StudyStartTime)
                            .Set(i => i.StudyEndTime, ClassesInfo.StudyEndTime)
                            .Set(i => i.LastChangeTime, ClassesInfo.LastChangeTime)
                            .Set(i => i.ClassStatus, "active")
                            .Set(i => i.StudyURL, ClassesInfo.StudyURL)
                            .Set(i => i.LessonGroup, ClassesInfo.LessonGroup);
                collect.Update(query, update);
                return true;

            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
                return false;
            }
        }
        public bool UpdateClassBasicInfo(Classes ClassesInfo)
        {
            try
            {
                var collect = this.mongoDatabase.GetCollection(CLASS_COLLECTION);
                var query = new QueryDocument { { "_id", ClassesInfo._id } };
                var update = new UpdateDocument {
                { "$set", new QueryDocument {
                { "ClassName", ClassesInfo.ClassName},
                { "StudyStartTime", ClassesInfo.StudyStartTime},
                { "StudyEndTime", ClassesInfo.StudyEndTime},
                { "LastChangeTime", ClassesInfo.LastChangeTime},
                { "LessonGroup", ClassesInfo.LessonGroup}

                } } };
                var result = collect.Update(query, update);
                return true;
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
                return false;

            }
        }