public async Task <bool> DeleteTestQuestion(int id)
        {
            var test_question = await testQuestionRepository.GetQuestion(id);

            var test = await testRepository.GetTest(test_question.TestId);

            var question = await testQuestionRepository.GetQuestion(id);

            if (question == null)
            {
                return(false);
            }
            if ((int)test_question.Complexity == 3)
            {
                test.TimeOfTest -= 5;
            }
            else if ((int)test_question.Complexity == 2)
            {
                test.TimeOfTest -= 3;
            }
            else if ((int)test_question.Complexity == 1)
            {
                test.TimeOfTest -= 1;
            }
            question.isDelete = true;
            testRepository.Update(test);
            await testRepository.SaveChangesAsync();

            answersRepository.SetValueIsDeleteOnQuestion(question.NumberOfIdentification);
            testQuestionRepository.Update(question);
            await testQuestionRepository.SaveChangesAsync();

            return(true);
        }
Пример #2
0
        public async Task <bool> DeleteSubject(int id)
        {
            var subject = await subjectRepository.GetSubjectById(id);

            subject.isDelete = true;
            if (subject == null)
            {
                return(false);
            }
            testQuestionRepository.SetValueIsDeleteOnSubject(subject.Id);
            answersRepository.SetValueIsDeleteOnSubject(subject.Id);
            subjectRepository.Update(subject);
            await subjectRepository.SaveChangesAsync();

            await testQuestionRepository.SaveChangesAsync();

            await answersRepository.SaveChangesAsync();

            return(true);
        }