Пример #1
0
        public async Task <ActionResult <User> > Put([FromBody] User user)
        {
            _context.Users.Update(user);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetUser), new { id = user.Id }, user));
        }
Пример #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));
        }