Exemple #1
0
        // To protect from overposting attacks, please 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(Surname).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SurnameExists(Surname.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            // Utilize HTML helper to reder the enum as a selection
            Genders = htmlHelper.GetEnumSelectList <Gender>();

            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GivenNameExists(GivenName.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please 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.Surnames.Add(Surname);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #4
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            // Utilize HTML helper to reder the enum as a selection
            Genders = htmlHelper.GetEnumSelectList <Gender>();

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.GivenNames.Add(GivenName);
            await _context.SaveChangesAsync();

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

            Surname = await _context.Surnames.FindAsync(id);

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

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