Exemple #1
0
        public async Task <ActionResult <API.Models.User> > PostUser(API.Models.User user)
        {
            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUser", new { id = user.Id }, user));
        }
Exemple #2
0
        public async Task <IActionResult> PutUser(int id, API.Models.User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }