public async Task<IActionResult> PutBook(string id, Book book) { if (id != book.Isbn) { return BadRequest(); } _context.Entry(book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public async Task <IActionResult> PutStudent(string id, Student student) { if (id != student.StudentId) { return(BadRequest()); } _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAuthor(int id, Author author) { if (id != author.AuthorId) { return(BadRequest()); } _context.Entry(author).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("docId,document")] Documents documents) { if (ModelState.IsValid) { _context.Add(documents); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(documents)); }
public async Task <IActionResult> Create(LoanList lists) { if (ModelState.IsValid) { _context.loanlist.Add(lists); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(lists)); }
public async Task <ActionResult <Loan> > PostLoan(Loan loan) { _context.Loan.Add(loan); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (LoanExists(loan.Isbn)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetLoan", new { id = loan.Isbn }, loan)); }