예제 #1
0
        //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));
            }
        }
예제 #2
0
 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());
     }
 }