Ejemplo n.º 1
0
        public ActionResult Register(mvcCards student)
        {
            try
            {
                bool anyUserExists = db.Cards.Any(x => x.SNumber == student.SNumber);

                if (anyUserExists == true)
                {
                    TempData["Student"] = student.SNumber;
                    return(RedirectToAction("CardAvail"));
                }

                else
                {
                    EmailConfiguration emails = new EmailConfiguration();
                    bool isValid = emails.Email(student);
                    if (isValid == true)
                    {
                        return(RedirectToAction("Failed"));
                    }
                    else
                    {
                        HttpResponseMessage response = GlobalVariables.webApi.PostAsJsonAsync("Cards", student).Result;
                        TempData["SuccessMessage"] = "Saved Successfully";
                        TempData["CardNumber"]     = student.SNumber;
                        return(RedirectToAction("Success"));
                    }
                }
            }
            catch (Exception Ex)
            {
                Ex.GetBaseException();
                return(RedirectToAction("Failed"));
            }
        }
Ejemplo n.º 2
0
 public ActionResult NotAvailable(mvcCards student)
 {
     if (Session["uname"] == null)
     {
         return(RedirectToAction("Login", "Auth"));
     }
     ViewBag.this_student_card = TempData["Student"];
     return(View(new mvcCards()));
 }
Ejemplo n.º 3
0
        public ActionResult LogOut(mvcCards student)
        {
            if (Session["uname"] == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Session.Remove("uname");
            return(RedirectToAction("Login", "Auth"));
        }
Ejemplo n.º 4
0
        public ActionResult RemoveSuccess(mvcCards student)
        {
            if (Session["uname"] == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewBag.this_student_card = TempData["Delete"];
            return(View(new mvcCards()));
        }
Ejemplo n.º 5
0
        public ActionResult Success(mvcCards student)
        {
            if (Session["uname"] == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewBag.Success = TempData["CardNumber"];
            return(View(new mvcCards()));
        }
Ejemplo n.º 6
0
        public ActionResult Search(mvcCards student)
        {
            bool isCard = db.Cards.Any(x => x.SNumber == student.SNumber);

            if (isCard == true)
            {
                TempData["Student"] = student.SNumber;
                return(RedirectToAction("CardAvail"));
            }

            else
            {
                TempData["Student"] = student.SNumber;
                return(RedirectToAction("NotAvailable"));
            }
        }
Ejemplo n.º 7
0
        public ActionResult CardAvail(mvcCards student)
        {
            if (Session["uname"] == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }

            else
            {
                ViewBag.Message = TempData["Student"];
                string found = (string)TempData["Student"];
                string lost  = db.Cards.Where(x => x.SNumber == found).Select(u => u.Campus).FirstOrDefault();
                ViewBag.studentCampus = lost;
                return(View(new mvcCards()));
            }
        }
Ejemplo n.º 8
0
        public ActionResult Removal(mvcCards student)
        {
            Card record = db.Cards.SingleOrDefault(x => x.SNumber == student.SNumber);

            if (record == null)
            {
                TempData["Student"] = student.SNumber;
                return(RedirectToAction("NotAvailable"));
            }

            TempData["Delete"] = student.SNumber;
            db.Cards.Remove(record);
            db.SaveChanges();

            return(RedirectToAction("RemoveSuccess"));
        }