Пример #1
0
        public void AddSlideToCourse(String courseId, CourseContent content)
        {
            if (String.IsNullOrEmpty(courseId))
            {
                throw new ArgumentException("courseId");
            }
            if (!CourseExists(courseId))
            {
                throw new ArgumentException("course cannot be found!");
            }

            var targetCourse = m_contextCoursesModel.GetCourse(courseId);
            targetCourse.CourseSlides.Add(content);
            m_contextCoursesModel.AddOrUpdateCourse(targetCourse);
        }
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         var contentToSubmit = new CourseContent
         {
             CourseContentType = (ContentType)Enum.Parse(typeof(ContentType), collection["CourseContentType"], true),
             Description = collection["description"],
             IndexInSquence = Int32.Parse(collection["IndexInSquence"]),
             ResourcePath = collection["ResourcePath"],
             Title = collection["Title"]
         };
         m_contextCoursesService.AddSlideToCourse(collection["courseId"], contentToSubmit);
         return RedirectToAction("Create");
     }
     catch (Exception ex)
     {
         ViewBag.Message = ex.Message;
         return View("Error");
     }
 }
        /// <summary>
        /// GetSlide
        /// </summary>
        /// <param name="courseId"></param>
        /// <param name="slideIndex"></param>
        /// <returns></returns>
        public ActionResult GetSlide(String courseId, int slideIndex)
        {
            String viewName = "Error";
            CourseContent targetSlide = new CourseContent(); //empty
            try
            {
                var enrollmentInfo = m_contextEnrollmentService.GetEnrollmentInfo(
                    User.Identity.Name, courseId);

                targetSlide = m_contextCoursesService.GetCourseSlide(
                    courseId,
                    slideIndex);
                if (targetSlide == null)
                {
                    throw new Exception("this class doesn't have any slides, yet!");
                }
                switch (targetSlide.CourseContentType)
                {
                    case ContentType.Audio:
                        viewName = "AudioContent";
                        break;
                    case ContentType.Video:
                        viewName = "VideoContent";
                        break;
                    case ContentType.Document:
                        viewName = "DocumentContent";
                        break;
                    case ContentType.Presentation:
                        viewName = "PresentationContent";
                        break;
                    case ContentType.Interactive:
                        viewName = "InteractiveContent";
                        break;
                    case ContentType.Unknown:
                    default:
                        break;
                }

            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return View("Error");
            }

            return View(viewName, targetSlide);
        }
        public ActionResult Edit(String id, String courseId, FormCollection collection)
        {
            try
            {
                // TO DO:
                // ADD THE EDIT LOGIC.

                var contentToSubmit = new CourseContent
               {
                   CourseContentType = (ContentType)Enum.Parse(typeof(ContentType), collection["CourseContentType"], true),
                   Description = collection["description"],
                   IndexInSquence = Int32.Parse(collection["IndexInSquence"]),
                   ResourcePath = collection["ResourcePath"],
                   Title = collection["Title"]
               };
                m_contextCoursesService.AddSlideToCourse(courseId, contentToSubmit);

                return Redirect(Request.UrlReferrer.AbsoluteUri.ToString());

            }
            catch
            {
                return View();
            }
        }