示例#1
0
 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);
 }
示例#2
0
        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);
        }