Exemple #1
0
        public ActionResult ClearStudent(int id)
        {
            try
            {
                LibraryClearance libraryClearance = context.LibraryClearances.Find(id);
                libraryClearance.Cleared              = true;
                libraryClearance.LibarianId           = User.Identity.GetUserId();
                context.Entry(libraryClearance).State = EntityState.Modified;

                PropertyClearance propertyClearance = new PropertyClearance
                {
                    ClearanceId = libraryClearance.ClearanceId
                };
                context.PropertyClearances.Add(propertyClearance);

                context.SaveChanges();

                // If successful, the clearance is taken care of. so, redirect to list of clearances
                TempData["SuccessMessage"] = "The student has been cleared.";
                return(RedirectToAction("Clearances"));
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;
            }
            return(Redirect(base.Request.UrlReferrer.ToString()));
        }
Exemple #2
0
        public ActionResult DenyClearance(int id)
        {
            try
            {
                LibraryClearance libraryClearance = context.LibraryClearances.Find(id);
                libraryClearance.Cleared              = false;
                libraryClearance.LibarianId           = context.Librarians.FirstOrDefault().Id;
                context.Entry(libraryClearance).State = EntityState.Modified;

                Clearance clearance = context.Clearances.Find(libraryClearance.ClearanceId);
                clearance.Cleared = false;
                context.Entry(clearance).State = EntityState.Modified;

                context.SaveChanges();

                // If successful, the clearance is taken care of. so, redirect to list of clearances
                TempData["SuccessMessage"] = "The clearance request has been denied.";
                return(RedirectToAction("Clearances"));
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;
            }
            return(Redirect(base.Request.UrlReferrer.ToString()));
        }
Exemple #3
0
        public ActionResult Clearance(int id)
        {
            LibraryClearanceDetailsViewModel model = new LibraryClearanceDetailsViewModel();
            LibraryClearance   libraryClearance    = context.LibraryClearances.Include("Clearance").Include("Librarian").Single(lc => lc.LibraryClearanceId == id);
            IEnumerable <Loan> Loans = context.Loans.Include("Book").Include("Librarian").Where(m => m.StudentId == libraryClearance.Clearance.StudentId).Where(m => m.ReturnDate == null).ToList();

            model.LibraryClearance = libraryClearance;
            model.BookLoans        = Loans;
            return(View(model));
        }
Exemple #4
0
        public ActionResult CancelClearanceRequest(int id)
        {
            try
            {
                LibraryClearance libraryClearance = context.LibraryClearances.Find(id);
                context.LibraryClearances.Remove(libraryClearance);
                context.SaveChanges();

                TempData["SuccessMessage"] = "Library clearance request has been cancelled.";
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;
            }

            return(Redirect(base.Request.UrlReferrer.ToString()));
        }
Exemple #5
0
        public ActionResult AddClearanceRequest(int id)
        {
            if (ModelState.IsValid)
            {
                LibraryClearance libraryRequest = new LibraryClearance
                {
                    ClearanceId = id
                };

                try
                {
                    context.LibraryClearances.Add(libraryRequest);
                    context.SaveChanges();

                    TempData["SuccessMessage"] = "Request forwarded to library! Check back later for the reponse.";
                }
                catch (Exception ex)
                {
                    TempData["ErrorMessage"] = ex.Message;
                }
            }

            return(Redirect(base.Request.UrlReferrer.ToString()));
        }