コード例 #1
0
 public ActionResult Create(CourseThemeUserViewModel ctu)
 {
     try
     {
         if (ModelState.IsValid)
         {
             courseService.CreateCourse(ctu);
             return RedirectToAction("Index");
         }
         else
         {
             ctu.Themes = courseService.GetActual<Theme>();
             ctu.Users = userService.GetUsersInRole<ApplicationUser>("teacher");
             return View(ctu);
         }
     }
     catch(Exception ex)
     {
         return View();
     }
 }
コード例 #2
0
        public ActionResult Edit(CourseThemeUserViewModel ctu, int id)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    courseService.UpdateCourse(ctu, id);
                    return RedirectToAction("Index");
                }
                else
                {
                    ctu.Themes = courseService.GetAll<Theme>();
                    ctu.Users = userService.GetUsersInRole<ApplicationUser>("teacher");
                    return View(ctu);
                }

            }
            catch
            {
                return View();
            }
        }