Esempio n. 1
0
 /// <summary>
 /// Creates a new default GradesController
 /// </summary>
 public GradesController()
 {
     _db = new ApplicationDbContext();
     _gradeManager = new GradeManager(_db);
     _classManager = new ClassManager(_db);
 }
Esempio n. 2
0
        /// <summary>
        /// Converts a list of enrollments to a list of corresponding view-models
        /// </summary>
        /// <param name="enrollments"></param>
        /// <returns></returns>
        private async Task<List<EnrollmentViewModel>> ConvertToViewModel(IEnumerable<Enrollment> enrollments)
        {
            List<EnrollmentViewModel> result = new List<EnrollmentViewModel>();
            var gradeManager = new GradeManager(_db);
            foreach(var enroll in enrollments)
            {
                var enrollvm = new EnrollmentViewModel(enroll);
                if(!enroll.Pending)
                {
                    enrollvm.Grade = await gradeManager.GetStudentGradeAsync(enroll.Student, enroll.Class);
                }
                result.Add(enrollvm);
            }

            return result;
        }