/// <summary>
 /// Adds the specified module.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <exception cref="CustomException"></exception>
 public void AddModule(CourseModule module)
 {
     try {
         using (var db = new ELearningDatabaseEntitiesServer()) {
             db.CourseModule.Add(module);
             db.SaveChanges();
         }
     }
     catch (InvalidOperationException ex) {
         throw new CustomException(ex.Message);
     }
 }
        public CourseModuleViewModel GetViewModel(CourseModule courseModule)
        {
            try {
                CourseModuleViewModel cmvm = new CourseModuleViewModel();
                cmvm.ModuleId = courseModule.ModuleId;
                cmvm.ModuleName = courseModule.ModuleName;
                cmvm.PreviousModuleId = courseModule.PreviousModuleId;
                cmvm.Moduledatetime = courseModule.Moduledatetime;
                cmvm.CourseId = courseModule.CourseId;

                return cmvm;
            }
            catch (Exception ex) {
                throw new CustomException(ex.Message);
            }
        }
Esempio n. 3
0
        public ActionResult CreateModule(CourseModuleViewModel courseModuleViewModel)
        {
            this.logger.Info("Entering: " + System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName + ": " + System.Reflection.MethodBase.GetCurrentMethod().Name + " --> " + User.Identity.Name);
            try {
                CourseModule cm = new CourseModule();
                cm.Moduledatetime = courseModuleViewModel.Moduledatetime;
                cm.ModuleName = courseModuleViewModel.ModuleName;
                cm.PreviousModuleId = courseModuleViewModel.PreviousModuleId;
                cm.CourseId = courseModuleViewModel.CourseId;
                this.courseManagement.AddModule(cm);

                return RedirectToAction("DisplayCourses");
            }
            catch (CustomException ce) {
                this.logger.Trace(ce, "Username: "******"Operation could not be completed! Try again.";
                return View("Error");
            }
            catch (Exception ex) {
                this.logger.Trace(ex, "Username: "******"Operation could not be completed!";
                return View("Error");
            }
        }