Example #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var studentToUpdate = await _context.FindAsync <Student>(id);

            if (await TryUpdateModelAsync(
                    studentToUpdate,
                    nameof(StudentVM),
                    s => s.FirstMidName, s => s.LastName, s => s.EnrollmentDate))
            {
                await _context.SaveChangesAsync();

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

            return(Page());
        }