Esempio n. 1
0
        public async Task <List <CandidateDTO> > CalculCandidatesNotes()
        {
            var candidatesDTO = new List <CandidateDTO>();
            int?note          = 0;
            var candidates    = await _repository.GetCandidatesAsync();

            var tests = await _repository.GetTestsAsync();

            var answers = await _repository.GetAnswersAsync();

            foreach (var c in candidates)
            {
                foreach (var t in tests)
                {
                    if (c.Test.Id == t.Id)
                    {
                        foreach (var cr in c.Result)
                        {
                            foreach (var a in answers)
                            {
                                if (cr.AnswerId == a.Id)
                                {
                                    if (a.IsGood == 1)
                                    {
                                        note = note + 1;
                                    }
                                }
                            }
                        }
                    }
                }
                candidatesDTO.Add(
                    new CandidateDTO(c.FirstName, c.LastName, c.Test.Title, (int)note)
                    );
                note = 0;
            }

            return(candidatesDTO);
        }