public ActionResult Create() { var userId = (int)Membership.GetUser().ProviderUserKey; var groups = groupService.GetGroupsByTrainerId(userId); var viewModel = new TrainerTestCreateViewModel { Groups = new SelectList(groups, "Id", "Name"), }; return View(viewModel); }
public ActionResult Create(TrainerTestCreateViewModel viewModel) { if (ModelState.IsValid) { var test = new Test { Name = viewModel.Name, AuthorId = (int)Membership.GetUser().ProviderUserKey, ShowTrueAnswers = viewModel.ShowTrueAnswers, SubcategoryId = viewModel.SubcategoryId, }; testService.CreateTest(test); return Redirect("/trainer/test"); } var userId = (int)Membership.GetUser().ProviderUserKey; var groups = groupService.GetGroupsByTrainerId(userId); viewModel.Groups = new SelectList(groups, "Id", "Name"); return View(viewModel); }