Exemplo n.º 1
0
 public ActionResult AddTest(TestView testView, Guid difficultId, Guid subjectId)
 {
     if (ModelState.IsValid && difficultId != null)
     {
         var     config  = new MapperConfiguration(cfg => cfg.CreateMap <TestView, TestDTO>());
         IMapper mapper  = config.CreateMapper();
         TestDTO testDTO = new TestDTO();
         testDTO = mapper.Map <TestView, TestDTO>(testView);
         testDTO.CountQuestion = 0;
         testDTO.Id            = Guid.NewGuid();
         testService.AddNewTest(testDTO, difficultId);
         testService.AddNewCOnnectionSubjectTest(testDTO.Id, subjectId);
         Logger.Log.Info("User " + User.Identity.GetUserId() + "add new test " + testDTO.Id + " to subject " + subjectId);
         return(RedirectToAction("ViewTest", new { id = subjectId, difficultId = testDTO.Id }));
     }
     return(RedirectToAction("ViewTest", new { id = subjectId }));
 }