public ActionResult Create() { var userId = (int)Membership.GetUser().ProviderUserKey; var groups = groupService.GetGroupsByTrainerId(userId); var viewModel = new TrainerLessonCreateViewModel { Groups = new SelectList(groups, "Id", "Name"), }; return View(viewModel); }
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); }