示例#1
0
        public ActionResult EditLesson(int id, string title, string text, string pdf, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the lesson with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BLesson lesson = new B2BLesson();
                    lesson = db.B2BLessons.Where(x => x.id == id).FirstOrDefault<B2BLesson>();
                    lesson.title = title;
                    lesson.Text = text;
                    lesson.inactive = inActive;
                    db.SubmitChanges();

                    B2BVideo videoObj = new B2BVideo();
                    videoObj = db.B2BVideos.Where(x => x.lessonID == lesson.id).FirstOrDefault<B2BVideo>();
                    db.SubmitChanges();

                    B2BResource pdfObj = new B2BResource();
                    pdfObj = db.B2BResources.Where(x => x.lessonID.Equals(lesson.id)).FirstOrDefault<B2BResource>();
                    pdfObj.file_path = pdf;
                    db.SubmitChanges();

                    ViewBag.lesson = lesson;
                    ViewBag.video = videoObj;
                    ViewBag.pdf = pdfObj;

                    ViewBag.msg = "The Lesson changes have been made.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
示例#2
0
文件: B2B.cs 项目: janiukjf/CurtAdmin
 public static string DeleteVideo(int id)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BVideo video = new B2BVideo();
         video = db.B2BVideos.Where(x => x.id == id).FirstOrDefault<B2BVideo>();
         db.B2BVideos.DeleteOnSubmit(video);
         db.SubmitChanges();
         return "";
     } catch (Exception) {
         return "Error while deleting";
     }
 }
示例#3
0
文件: B2B.cs 项目: janiukjf/CurtAdmin
 public static B2BVideo getVideo(int videoID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BVideo video = new B2BVideo();
         video = db.B2BVideos.Where(x => x.id == videoID).Select(x => x).FirstOrDefault<B2BVideo>();
         return video;
     } catch (Exception e) {
         throw new Exception("Could not laod the video: " + e.Message);
     }
 }
示例#4
0
文件: B2B.cs 项目: janiukjf/CurtAdmin
        public static void addVideo(int lessonID, string title, string mp4, string ogg, string webm, bool inActive)
        {
            try {
                // New Video
                B2BDataContext db = new B2BDataContext();
                B2BVideo newVideo = new B2BVideo();
                newVideo.title = title;
                newVideo.date_added = DateTime.Now;
                newVideo.sort = 1;
                newVideo.lessonID = lessonID;
                newVideo.inactive = inActive;
                db.B2BVideos.InsertOnSubmit(newVideo);
                db.SubmitChanges();
                // New Video Sources
                int videoID = newVideo.id;

                foreach (B2BVideoType videoType in getVideoTypes()) {
                    string type = videoType.type;
                    B2BVideoSource newVideoSource = new B2BVideoSource();
                    newVideoSource.videoID = videoID;
                    if (type == "mp4") {
                        newVideoSource.filePath = mp4;
                        newVideoSource.typeID = videoType.id;
                    } else if (type == "ogg") {
                        newVideoSource.filePath = ogg;
                        newVideoSource.typeID = videoType.id;
                    } else if (type == "webm") {
                        newVideoSource.filePath = webm;
                        newVideoSource.typeID = videoType.id;
                    } else {
                        continue;
                    }
                    db.B2BVideoSources.InsertOnSubmit(newVideoSource);
                    db.SubmitChanges();
                }// end foreach videoType

            } catch (Exception e) {
                throw new Exception("Could not add video: " + e.Message);
            }
        }