Ejemplo n.º 1
0
 public void Create(T[] items)
 {
     foreach (var item in items)
     {
         _context.Entry(item).State =
             EntityState.Added;
     }
     _context.SaveChanges();
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.UserID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutBook(int id, Book book)
        {
            if (id != book.BookID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }