public async System.Threading.Tasks.Task <IActionResult> PutUsers(int id, User users) { if (id != users.UserId) { return(BadRequest()); } _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void CheckDebtor() { var bookOnHands = context.BooksOnHands.ToList(); var books = bookOnHands.Where(book => book.ReturnDate < DateTime.Now).ToList(); if (books.Count == 0) { return; } books.ForEach(x => x.User.Debtor = true); foreach (var book in books) { context.Entry(book).State = EntityState.Modified; } context.SaveChanges(); }
public async Task <IActionResult> PutCategories(Category categories) { _context.Entry(categories).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExist(categories.CategoryId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBooks(Book books) { _context.Entry(books).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BooksExist(books.BookId)) { return(NotFound()); } else { throw; } } return(NoContent()); }