Ejemplo n.º 1
0
 public ActionResult Edit(int id, TrainerLessonEditViewModel viewModel)
 {
     if (viewModel.Id == id)
     {
         if (ModelState.IsValid)
         {
             var getLesson = lessonService.GetLesson(id);
             var lesson = new Lesson
             {
                 Id = viewModel.Id,
                 Title = viewModel.Title,
                 Content = viewModel.Content,
                 CreationDate = getLesson.CreationDate,
             };
             lessonService.EditLesson(lesson);
             return Redirect("/trainer/lesson");
         }
         return View(viewModel);
     }
     else
     {
         throw new Exception("Dont do this");
     }
 }
Ejemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     var lesson = lessonService.GetLesson(id);
     var viewModel = new TrainerLessonEditViewModel
     {
         Content = lesson.Content,
         Id = lesson.Id,
         Title = lesson.Title,
     };
     return View(viewModel);
 }