public ActionResult editSchedule(int hoursPerWeek, string scheduleText, string callback, int courseID, string languageCode = "en")
        {
            ajaxReturnData data = new ajaxReturnData();
            SchoolCourse course = new SchoolCourse();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    course = DB.schoolCourses.Where(sc => sc.id == courseID).FirstOrDefault();
                    course.hoursPerWeek = hoursPerWeek;
                    course.addContent(DB, "scheduleText", scheduleText);
                    DB.SaveChanges();

                    
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "schedule updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update sschedule; " + ex.Message;
                return Json(data);
            }
        }
        public ActionResult editCourseGeneral(string name, int type, string editCourseIntroduction, HttpPostedFileWrapper introductionImage, string callback, int courseID, string languageCode = "en" )
        {
            ajaxReturnData data = new ajaxReturnData();
            SchoolCourse course = new SchoolCourse();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    course = DB.schoolCourses.Where(sc => sc.id == courseID).FirstOrDefault();
                    course.type = type;
                    DB.SaveChanges();

                    if (introductionImage != null && introductionImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/courses/" + course.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/introductionImage" + Path.GetExtension(introductionImage.FileName);
                        introductionImage.SaveAs(Server.MapPath(path));
                        course.introductionImage = path;
                        DB.Entry(course).Property(l => l.introductionImage).IsModified = true;
                    }
                    
                    course.addContent(DB, "name",name);
                    course.addContent(DB, "courseIntroduction", editCourseIntroduction);
                    DB.SaveChanges();

                }
                

                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "course updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to retrieve course; " + ex.Message;
                return Json(data);
            }
        }
        public ActionResult addCourse(string callback, int schoolID, int type, string name, string courseIntroduction,  HttpPostedFileWrapper introductionImage)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {


                    SchoolCourse sc = new SchoolCourse();
                    sc.schoolID = schoolID;
                    sc.type = type;
                    DB.schoolCourses.Add(sc);
                    sc.features = new CourseFeatures();
                    DB.SaveChanges();
                    sc.addContent(DB, "name", name);
                    sc.addContent(DB, "courseIntroduction", courseIntroduction);

                    if (introductionImage != null && introductionImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/courses/" + sc.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/introductionImage" + Path.GetExtension(introductionImage.FileName);
                        introductionImage.SaveAs(Server.MapPath(path));
                        sc.introductionImage = path;
                        DB.Entry(sc).Property(l => l.introductionImage).IsModified = true;
                        DB.SaveChanges();
                    }




                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "course added";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to add course; " + ex.Message;
                return Json(data);
            }
        }
        public ActionResult getCourse(string callback, int courseID, string languageCode="en")
        {
            ajaxReturnData data = new ajaxReturnData();
            SchoolCourse course = new SchoolCourse();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    course = DB.schoolCourses.Where(c => c.id == courseID).FirstOrDefault();
                    course.loadContent(DB);
                }

                data.data = course;


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to retrieve course; " + ex.Message;
                return Json(data);
            }
        }