public List <GroupWithStudentsWithAttemptsOutputModel> ConvertStudentsVSTestsDTOAndTeacherGroupsWithStudentsDTOToGroupWithStudentsWithAttemptsOutputModel(List <StudentsVSTestsDTO> students, List <TeacherGroupsWithStudentsDTO> groups, List <TestDTO> tests) { List <GroupWithStudentsWithAttemptsOutputModel> result = new List <GroupWithStudentsWithAttemptsOutputModel>(); foreach (var a in groups) { if (a != null) { GroupWithStudentsWithAttemptsOutputModel tmp = new GroupWithStudentsWithAttemptsOutputModel() { Id = a.GroupID, Name = a.GroupName, EndDate = a.EndDate, StartDate = a.StartDate, Students = new List <StudentOutputModel>() }; foreach (var b in a.Students) { if (b != null) { StudentOutputModel tmp2 = new StudentOutputModel() { ID = b.ID, FirstName = b.FirstName, LastName = b.LastName, DTO = new List <TestAttemptOutputModel>() }; foreach (var c in students) { if (tmp2.ID == c.Id) { TestAttemptOutputModel tmp3 = new TestAttemptOutputModel() { AttemptCount = c.NumberOfAttempts, Name = c.TestName, BestResult = c.MaxResult, ID = c.TestId, }; foreach (var t in tests) { if (t.ID == tmp3.ID) { tmp3.SuccessScore = Convert.ToInt32(t.SuccessScore); } } tmp2.DTO.Add(tmp3); } } tmp.Students.Add(tmp2); } } result.Add(tmp); } } return(result); }
public List <TestAttemptOutputModel> ConvertTestAttemptDTOToTestAttemptModel(List <TestAttemptDTO> tests) { List <TestAttemptOutputModel> model = new List <TestAttemptOutputModel>(); foreach (TestAttemptDTO a in tests) { TestAttemptOutputModel test = new TestAttemptOutputModel() { AttemptCount = a.AttemptCount, ID = a.ID, BestResult = a.BestResult, DurationTime = a.DurationTime, Name = a.Name, SuccessScore = a.SuccessScore }; model.Add(test); } return(model); }