public async Task Remove(BooksServ book) { book.SoftDeleted = true; _context.Entry(_mapper.Map <Books>(book)).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task <IActionResult> PutReview([FromRoute] Guid id, [FromBody] Review review) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != review.ReviewId) { return(BadRequest()); } _context.Entry(review).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReviewExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBookAuthor([FromRoute] Guid id, [FromBody] BookAuthor bookAuthor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bookAuthor.BooksId) { return(BadRequest()); } _context.Entry(bookAuthor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookAuthorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Update(AuthorServ author) { var validator = _validator.Validate(author); validator.ThrowIfInvalid(); _context.Entry(_mapper.Map <Author>(author)).State = EntityState.Modified; await _context.SaveChangesAsync(); }