Exemplo n.º 1
0
        public ActionResult Create(TrainerLessonCreateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var lesson = new Lesson
                {
                    Title = viewModel.Title,
                    AuthorId = (int)Membership.GetUser().ProviderUserKey,
                    Content = viewModel.Content,
                    CreationDate = DateTime.Now,
                    SubcategoryId = viewModel.SubcategoryId,
                };
                lessonService.CreateLesson(lesson);
                return Redirect("/trainer/lesson");
            }

            var userId = (int)Membership.GetUser().ProviderUserKey;
            var groups = groupService.GetGroupsByTrainerId(userId);
            viewModel.Groups = new SelectList(groups, "Id", "Name");
            return View(viewModel);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Edits lesson
 /// </summary>
 /// <param name="lesson">The lesson to be edited</param>
 public void EditLesson(Lesson lesson)
 {
     lessonRepo.Update(lesson);
     lessonRepo.Save();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates lesson
 /// </summary>
 /// <param name="lesson">The lesson to be created</param>
 public void CreateLesson(Lesson lesson)
 {
     lessonRepo.Add(lesson);
     lessonRepo.Save();
 }
Exemplo n.º 4
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");
     }
 }
Exemplo n.º 5
0
 public void Update(Lesson item)
 {
     var temp = this.setList.Where(x => x.Id == item.Id).First();
     this.setList.Remove(temp);
     this.setList.Add(item);
 }
Exemplo n.º 6
0
 public void Delete(Lesson item)
 {
     this.setList.Remove(item);
 }
Exemplo n.º 7
0
 public void Add(Lesson item)
 {
     this.setList.Add(item);
 }