public List <StudentHomeworkViewModel> GetBestHomeWorks(int id)
        {
            StudentHomeworkServices         service = new StudentHomeworkServices();
            List <StudentHomeworkViewModel> List    = service.GetStudentHomeWorks(id);
            List <StudentHomeworkViewModel> bestHM  = List.OrderBy(a => a.Grade).Take(10).ToList();

            return(List);
        }
        public StudentHomeworkViewModel GetHomeworkDetails(int studentId, int SHId)
        {
            StudentHomeworkServices         service   = new StudentHomeworkServices();
            List <StudentHomeworkViewModel> homeworks = service.GetStudentHomeWorks(studentId);
            StudentHomeworkViewModel        homework  = homeworks.Where(a => a.SHomeID == SHId).FirstOrDefault();

            return(homework);
        }
Пример #3
0
        //o lista cu toti studentii pentru fiecare profesor
        public List <StudInfoViewModel> GetStudentsByTeacherID(int id)
        {
            StudentRepository        repo     = new StudentRepository();
            List <Student>           studList = repo.GetAllStudentsByTeacherID(id);//lista cu toti studentii profesorului
            List <StudInfoViewModel> newList  = new List <StudInfoViewModel>();
            StudentHomeworkServices  service  = new StudentHomeworkServices();

            foreach (var item in studList)
            {
                int    sum     = 0;
                double average = 0;
                int    count   = 0;
                var    newStud = new StudInfoViewModel(item.StudentID, item.FirstName.ToString(), item.LastName.ToString(), item.Email.ToString(), item.PhoneNumber);

                List <StudentHomeworkViewModel> list = service.GetStudentHomeWorks(item.StudentID);//lista cu toate temele studentului
                foreach (var homework in list)
                {
                    if (homework.StatusID == "Accepted")
                    {
                        sum    = sum + homework.Grade;
                        count += 1;
                    }
                }
                if (count != 0)
                {
                    average = (double)sum / (double)count;


                    newStud.GradeAverage = average;
                }
                else
                {
                    newStud.GradeAverage = 1;
                }
                newList.Add(newStud);
            }
            return(newList);
        }