public ActionResult Create(PrimaryGuardianBorrow primaryguardianborrow)
        {
            OFRPDMSContext context = new OFRPDMSContext();
            if (ModelState.IsValid)
            {
                primaryguardianborrow.BorrowDate = System.DateTime.Now;
                context.LibraryResources.Find(primaryguardianborrow.LibraryResourceId).CheckedOut = true;
                primaryguardianborrow.DueDate = primaryguardianborrow.DueDate.AddHours(23);
                primaryguardianborrow.DueDate = primaryguardianborrow.DueDate.AddMinutes(59);
                repoService.primaryGuardianBorrowsRepo.Insert(primaryguardianborrow);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PossiblePrimaryGuardians = context.PrimaryGuardians;
            ViewBag.PossibleLibraryResources = context.LibraryResources.Where(lr => lr.CheckedOut == false);
            return View(primaryguardianborrow);
        }
 public ActionResult Edit(PrimaryGuardianBorrow primaryguardianborrow)
 {
     OFRPDMSContext context = new OFRPDMSContext();
     if (ModelState.IsValid)
     {
         if (primaryguardianborrow.Returned)
         {
             context.LibraryResources.Find(primaryguardianborrow.LibraryResourceId).CheckedOut = false;
         }
         else
         {
             return View(primaryguardianborrow);
         }
         primaryguardianborrow.ReturnDate = System.DateTime.Now;
         repoService.primaryGuardianBorrowsRepo.Update(primaryguardianborrow);
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PossiblePrimaryGuardians = context.PrimaryGuardians;
     ViewBag.PossibleLibraryResources = context.LibraryResources;
     return View(primaryguardianborrow);
 }
 //
 // We took out the edit function and turned it into check in function. The edit view is no longer in use
 public ActionResult Edit(int id)
 {
     OFRPDMSContext context = new OFRPDMSContext();
     PrimaryGuardianBorrow primaryguardianborrow = repoService.primaryGuardianBorrowsRepo.FindById(id);
     ViewBag.PossiblePrimaryGuardians = context.PrimaryGuardians;
     ViewBag.PossibleLibraryResources = context.LibraryResources;
     if (primaryguardianborrow.Returned != true)
     {
         primaryguardianborrow.Returned = true;
         primaryguardianborrow.ReturnDate = System.DateTime.Now;
         LibraryResource res = context.LibraryResources.Find(primaryguardianborrow.LibraryResourceId);
         res.CheckedOut = false;
         context.Entry(res).State = EntityState.Modified;
         repoService.primaryGuardianBorrowsRepo.Update(primaryguardianborrow);
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }