// 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()
        {
            var emptyGPA = new GPA();

            await TryUpdateModelAsync <GPA>(
                emptyGPA,
                "gpa",    // Prefix for form value.
                s => s.GPAID,
                s => s.GPAValue,
                s => s.StudentID,
                s => s.SemesterID,
                s => s.SubjectModuleID,
                s => s.YearID
                );

            _context.GPA.Add(emptyGPA);
            await _context.SaveChangesAsync();

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

            /*
             * if (!ModelState.IsValid)
             * {
             *  return Page();
             * }
             *
             * _context.GPA.Add(GPA);
             * await _context.SaveChangesAsync();
             *
             * return RedirectToPage("./Index");
             */
        }
        // 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(GPA).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GPAExists(GPA.GPAID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // 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()
        {
            var emptyGrade = new Grade();

            await TryUpdateModelAsync <Grade>(
                emptyGrade,
                "grade",    // Prefix for form value.
                s => s.GradeID,
                s => s.GradeChar,
                s => s.SemesterID,
                s => s.GPAID,
                s => s.DegreeID,
                s => s.StudentID,
                s => s.SubjectModuleID
                );

            _context.Grade.Add(emptyGrade);
            await _context.SaveChangesAsync();

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

            /*
             * if (!ModelState.IsValid)
             * {
             *  return Page();
             * }
             *
             * _context.Grade.Add(Grade);
             * await _context.SaveChangesAsync();
             *
             * return RedirectToPage("./Index");
             */
        }
Example #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            else
            {
                var userInDb = await _context.ApplicationUser.SingleOrDefaultAsync(u => u.Id == ApplicationUser.Id);

                if (userInDb == null)
                {
                    return(NotFound());
                }
                else
                {
                    userInDb.Email          = ApplicationUser.Email;
                    userInDb.FirstName      = ApplicationUser.FirstName;
                    userInDb.LastName       = ApplicationUser.LastName;
                    userInDb.DegreeName     = ApplicationUser.DegreeName;
                    userInDb.IntakeNumber   = ApplicationUser.IntakeNumber;
                    userInDb.FacultyName    = ApplicationUser.FacultyName;
                    userInDb.DepartmentName = ApplicationUser.DepartmentName;
                    userInDb.DegreeID       = ApplicationUser.DegreeID;
                    userInDb.DepartmentID   = ApplicationUser.DepartmentID;

                    await _context.SaveChangesAsync();

                    return(RedirectToPage("Index"));
                }
            }
        }
        // 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.SGPA.Add(SGPA);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(string?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var courseToUpdate = await _context.Degree.FindAsync(id);

            if (courseToUpdate == null)
            {
                return(NotFound());
            }

            /*
             * if (await TryUpdateModelAsync<Degree>(
             *   courseToUpdate,
             *   "degree",   // Prefix for form value.
             *   s => s.DegreeID,
             *   s => s.DegreeName,
             *   s => s.FacultyName,
             *   s => s.DegreeCode,
             *   s => s.NumOfYears,
             *   s => s.DepartmentID,
             *   s => s.DepartmentName
             *   ))
             * {
             *  await _context.SaveChangesAsync();
             *  return RedirectToPage("./Index");
             * }
             */
            await TryUpdateModelAsync <Degree>(
                courseToUpdate,
                "degree",    // Prefix for form value.
                //s => s.DegreeID,
                s => s.DegreeName,
                s => s.FacultyName,
                s => s.DegreeCode,
                s => s.NumOfYears,
                s => s.DepartmentID,
                s => s.DepartmentName
                );

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
            // Select DepartmentID if TryUpdateModelAsync fails.
            //PopulateDepartmentsDropDownList(_context, courseToUpdate.DepartmentID);
            //return Page();
        }
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SGPA = await _context.SGPA.FindAsync(id);

            if (SGPA != null)
            {
                _context.SGPA.Remove(SGPA);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #8
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Department = await _context.Department.FindAsync(id);

            if (Department != null)
            {
                _context.Department.Remove(Department);
                await _context.SaveChangesAsync();
            }

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