Esempio n. 1
0
        public async Task <IActionResult> PutBook([FromRoute] int id, [FromBody] Book book)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != book.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task AddBook(BookEntity book)
        {
            await _context.AddAsync(book);

            await _context.SaveChangesAsync();
        }
Esempio n. 3
0
        public async Task Add(ReservationEntity reservation)
        {
            await _context.Reservations.AddAsync(reservation);

            await _context.SaveChangesAsync();
        }