Пример #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()));
        }
Пример #2
0
        public ActionResult DenyClearance(int id)
        {
            try
            {
                PropertyClearance propertyClearance = context.PropertyClearances.Find(id);
                propertyClearance.Cleared              = false;
                propertyClearance.PropertyId           = User.Identity.GetUserId();
                context.Entry(propertyClearance).State = EntityState.Modified;

                Clearance clearance = context.Clearances.Find(propertyClearance.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()));
        }
Пример #3
0
        public ActionResult CancelClearanceRequest(int id)
        {
            try
            {
                PropertyClearance propertyClearance = context.PropertyClearances.Find(id);
                context.PropertyClearances.Remove(propertyClearance);
                context.SaveChanges();

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

            return(Redirect(base.Request.UrlReferrer.ToString()));
        }
Пример #4
0
        public ActionResult AddClearanceRequest(int id)
        {
            if (ModelState.IsValid)
            {
                PropertyClearance propertyRequest = new PropertyClearance
                {
                    ClearanceId = id
                };

                try
                {
                    context.PropertyClearances.Add(propertyRequest);
                    context.SaveChanges();

                    TempData["SuccessMessage"] = "Request forwarded to property!";
                }
                catch (Exception ex)
                {
                    TempData["ErrorMessage"] = ex.Message;
                }
            }

            return(Redirect(base.Request.UrlReferrer.ToString()));
        }
Пример #5
0
        public ActionResult Clearance(int id)
        {
            PropertyClearance propertyClearance = context.PropertyClearances.Include("Clearance").Include("Property").Single(lc => lc.PropertyClearanceId == id);

            return(View(propertyClearance));
        }