示例#1
0
        public async Task <IActionResult> PutRental_Book(int id, Rental_Book rental_Book)
        {
            if (id != rental_Book.RentalId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult <Rental_Book> > PostRental_Book(Rental_Book rental_Book)
        {
            _context.Rental_Books.Add(rental_Book);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (Rental_BookExists(rental_Book.RentalId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetRental_Book", new { id = rental_Book.RentalId }, rental_Book));
        }