//Return books page called to Render public ActionResult ReturnBooks() { List <Rented> rented = null; using (var d = new UserContext()) { rented = d.Rented.Include("Book").Include("UserProfile").AsEnumerable().ToList(); ReturnBooksModel model = new ReturnBooksModel(); model.AllRented = rented; model.NewReturned = new ReturnModel(); return(View(model)); } }
public ActionResult ReturnBooks(ReturnBooksModel model) { using (var d = new UserContext()) { Rented r = d.Rented.Where(x => x.UserProfile.UserId == model.NewReturned.UserId) .Where(x => x.Book.BookKey == model.NewReturned.BookKey) .FirstOrDefault(); r.returned = true; d.SaveChanges(); addHistory(r.UserProfile, r.Book, (States)2); return(ReturnBooks()); } }