示例#1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            current_id = id;
            item       = await _context.Students.FindAsync(id);

            _context.Students.Remove(item);
            await _context.SaveChangesAsync();

            return(Redirect("/Student"));
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync(int id, string FirstName, string LastName, double GPA)
        {
            current_id = id;
            item       = await _context.Students.FindAsync(id);

            item.FirstName = FirstName;
            item.LastName  = LastName;
            item.GPA       = GPA;
            _context.Students.Update(item);
            await _context.SaveChangesAsync();

            return(Redirect("/Student"));
        }
示例#3
0
        public async Task <IActionResult> OnPostAsync(string FirstName, string LastName, double GPA)
        {
            if (FirstName.Length <= 1 || LastName.Length <= 1)
            {
                return(Redirect("/Student"));
            }
            item           = new Models.Student();
            item.FirstName = FirstName;
            item.LastName  = LastName;
            item.GPA       = GPA;
            _context.Students.Add(item);
            await _context.SaveChangesAsync();

            return(Redirect("/Student"));
        }