Esempio n. 1
0
        //[Route("Home/ResultSheet/{Lastname}")]
        public IActionResult ResultSheet(int?Id)
        {
            HomeResultSheetViewModel homeResultSheetViewModel = new HomeResultSheetViewModel()
            {
                Result = _resultRepository.GetResult(Id ?? 3),
            };

            return(View(homeResultSheetViewModel));
        }
Esempio n. 2
0
        public IActionResult ResultSheet(int Id)
        {
            var NoOfCourses = context.Course.Where(c => c.ResultId == Id).Count();
            int courseValue = 0;
            int sumOfUnits  = 0;
            int totalValue  = 0;


            foreach (var course in context.Course.Where(c => c.ResultId == Id))
            {
                if (course.Grade == "A")
                {
                    courseValue = course.Unit * 5;
                }
                else if (course.Grade == "B")
                {
                    courseValue = course.Unit * 4;
                }
                else if (course.Grade == "C")
                {
                    courseValue = course.Unit * 3;
                }
                else if (course.Grade == "D")
                {
                    courseValue = course.Unit * 2;
                }
                else if (course.Grade == "E")
                {
                    courseValue = course.Unit * 1;
                }
                else if (course.Grade == "F")
                {
                    courseValue = course.Unit * 0;
                }
                totalValue += courseValue;
            }

            foreach (var course in context.Course.Where(c => c.ResultId == Id))
            {
                sumOfUnits += course.Unit;
            }

            double GP = (double)totalValue / sumOfUnits;

            HomeResultSheetViewModel homeResultSheetViewModel = new HomeResultSheetViewModel()
            {
                Result      = _resultRepository.GetResult(Id),
                Courses     = context.Course.Where(c => c.ResultId == Id).ToList(),
                ResultId    = Id,
                GP          = GP,
                NoOfCourses = context.Course.Where(c => c.ResultId == Id).Count(),
                SumOfUnits  = sumOfUnits,
            };

            context.SaveChanges();
            return(View(homeResultSheetViewModel));
        }