Exemplo n.º 1
0
        public async Task <User> Insert(User user)
        {
            _context.Entry(user).State = EntityState.Modified;
            await _context.Users.AddAsync(user);

            await _context.SaveChangesAsync();

            return(user);
        }
Exemplo n.º 2
0
        public async Task <TEntity> Insert(TEntity entity)
        {
            _context.Entry(entity).State = EntityState.Modified;
            await _context.AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutArticles(int id, [FromBody] Articles articles)
        {
            if (id != articles.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }