Esempio n. 1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Internship).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InternshipExists(Internship.StudentID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Enrollment.midterm != null && Enrollment.final != null)
            {
                grade = (int)(Enrollment.midterm * 0.3 + Enrollment.final * 0.7);
                if (grade >= 90)
                {
                    Enrollment.grade = "AA";
                }
                else if (grade >= 85)
                {
                    Enrollment.grade = "BA";
                }
                else if (grade >= 80)
                {
                    Enrollment.grade = "BB";
                }
                else if (grade >= 70)
                {
                    Enrollment.grade = "CB";
                }
                else if (grade >= 60)
                {
                    Enrollment.grade = "CC";
                }
                else if (grade >= 50)
                {
                    Enrollment.grade = "DD";
                }
                else
                {
                    Enrollment.grade = "FF";
                }
            }
            _context.Attach(Enrollment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnrollmentExists(Enrollment.EnrollmentID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }