public T Get(int id)
        {
            var entity = context.Set <T>().Find(id);

            context.Entry(entity).State = EntityState.Deleted;
            context.Entry(entity).State = EntityState.Modified;
            return(entity);
        }
Beispiel #2
0
        public async Task <ActionResult <Tournament> > AddTournament([FromBody] Tournament tournament)
        {
            tournament.BowlingAlleyId = tournament.BowlingAlley.Id;
            tournament.BowlingAlley   = null;
            tournament.OrganiserId    = tournament.Organiser.Id;
            tournament.Organiser      = null;
            _context.Tournaments.Add(tournament);
            _context.Entry(tournament).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetTournament), new { id = tournament.Id }, tournament));
        }