Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

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

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

            Tournament = await _context.Tournaments.FindAsync(id);

            if (Tournament != null)
            {
                var entities = _context.TournamentUserPairs.Where(tu => tu.TournamentId == Tournament.Id);
                _context.TournamentUserPairs.RemoveRange(entities);
                _context.Tournaments.Remove(Tournament);
                await _context.SaveChangesAsync();
            }

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