Ejemplo n.º 1
0
        public IActionResult Edit(Guid id)
        {
            var test = _testsRepository.GetByIdAsync(id).Result;

            if (test == null)
            {
                return(NotFound());
            }
            var editTestTemplatesViewModel = _mapper.Map <EditTestTemplatesViewModel>(test);

            var exercises = _exercisesRepository.GetAllExercisesOfTestAsync(id).Result;

            if (exercises == null)
            {
                return(NotFound());
            }
            var editExercises = _mapper.Map <List <EditExercise> >(exercises);

            editTestTemplatesViewModel.Exercises = editExercises;

            return(View(editTestTemplatesViewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Details(Guid id)
        {
            var testInstance = await _testInstancesRepository.GetByIdAsync(id);

            if (testInstance == null)
            {
                return(NotFound());
            }
            var test = await _testsRepository.GetByIdAsync(testInstance.TestId);

            if (test == null)
            {
                return(NotFound());
            }
            var testType = _testTypesRepository.GetByIdAsync(test.TestTypeId).Result.Type;

            if (testType == null)
            {
                return(NotFound());
            }

            var group = await _groupsRepository.GetByIdAsync(testInstance.GroupId);

            if (group == null)
            {
                return(NotFound());
            }
            var userList = DetailsGetAllUsersOfGroupByGroupId(group.Id);

            if (userList == null)
            {
                return(NotFound());
            }

            var exercises = await _exercisesRepository.GetAllExercisesOfTestAsync(test.Id);

            if (exercises == null)
            {
                return(NotFound());
            }
            var exerciseList = new List <ScheduledTestDetailsExercise>();

            foreach (var item in exercises)
            {
                exerciseList.Add(new ScheduledTestDetailsExercise()
                {
                    Description = item.Description,
                    Answers     = await _answersRepository.GetAllAnswersOfExerciseAsync(item.Id)
                });
            }
            var detailsScheduledTestViewModel = new DetailsScheduledTestViewModel();
            var testDetails = new ScheduledTestDetailsTest();

            testDetails.TestType    = testType;
            testDetails.Description = test.Description;
            testDetails.Name        = test.Name;
            testDetails.Exercises   = exerciseList;

            var groupDetails = new ScheduledTestDetailsGroup();

            groupDetails.Description = group.Description;
            groupDetails.Name        = group.Name;
            groupDetails.Users       = userList;
            detailsScheduledTestViewModel.TestDetails   = testDetails;
            detailsScheduledTestViewModel.GroupDetails  = groupDetails;
            detailsScheduledTestViewModel.Id            = id;
            detailsScheduledTestViewModel.Duration      = testInstance.Duration;
            detailsScheduledTestViewModel.StartDateTime = testInstance.StartedAt;



            return(View(detailsScheduledTestViewModel));
        }