Beispiel #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(Quiz).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuizExists(Quiz.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("Browse"));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            //RETREIVE QUIZ
            Quiz = await _context.Quizzes.FindAsync(id);

            if (Quiz != null)
            {
                _context.Quizzes.Remove(Quiz); //DELETE RECORD AND UPDATE
                await _context.SaveChangesAsync();
            }

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