Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,StudentId,EventId,State,SectionId,GradeEarned")] Grade grade)
        {
            if (ModelState.IsValid)
            {
                _context.Add(grade);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(grade));
        }
Пример #2
0
        public async Task <IActionResult> CreateGrade(Grade newGrade)
        {
            if (newGrade.Value > 100 || newGrade.Value < 0)
            {
                return(BadRequest("invalid % value"));
            }
            _Grades.Grades.Add(newGrade);
            await _Grades.SaveChangesAsync();

            return(Ok(newGrade));
        }
Пример #3
0
        public async Task <IActionResult> PopulateGradeSheet(int id)
        {
            int findId = 0;

            if (int.TryParse(HttpContext.Request.Form["RosterNum"], out findId))
            {
            }
            else
            {
                findId = 0;
            }

            Section section = await _context.Section.FindAsync(findId);

            Student stud = await _studContext.Student.FindAsync(id);

            //Grade grade = new Grade();

            var events = _eventContext.Event.Where(c => c.EventCode == section.EventCode);

            foreach (Event ev in events)
            {
                _gradeContext.Add(new Grade {
                    SectionId = findId,
                    StudentId = stud.Id,
                    EventId   = ev.Id
                });
            }
            await _gradeContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }