예제 #1
0
        public ActionResult SignUp(User user)
        {
            if (Session["uname"] != null)
            {
                return(RedirectToAction("userhome"));
            }

            if (ModelState.IsValid)
            {
                PAS_DatabaseEntities1 db = new PAS_DatabaseEntities1();
                User newUser             = new User();
                newUser.FirstName = user.FirstName;
                newUser.LastName  = user.LastName;
                newUser.Email     = user.Email;
                newUser.Password  = user.Password;

                db.Users.Add(newUser);
                db.SaveChanges();

                Session["uname"] = newUser.FirstName;

                return(RedirectToAction("userhome"));
            }

            return(View(user));
        }
예제 #2
0
        public ActionResult UpdateApplication()
        {
            if (Session["aname"] == null)
            {
                return(RedirectToAction("index", "Home"));
            }

            PAS_DatabaseEntities1 db = new PAS_DatabaseEntities1();

            Application application = db.Applications.Find(int.Parse(Request["applicationId"]));

            application.Subject  = Request["subject"];
            application.Body     = Request["body"];
            application.Approved = Convert.ToBoolean(int.Parse(Request["approval-status"]));

            db.SaveChanges();
            ViewBag.updated = 1;

            return(RedirectToAction("index", ViewBag));
        }
예제 #3
0
        public ActionResult SubmitApplication()
        {
            if (Session["uname"] == null)
            {
                return(RedirectToAction("index", "Home"));
            }

            PAS_DatabaseEntities1 db = new PAS_DatabaseEntities1();

            Application newApplication = new Application();

            newApplication.Subject  = Request["subject"];
            newApplication.Body     = Request["body"];
            newApplication.Approved = false;

            string s = Session["uname"].ToString();

            var query2 = from u in db.Users
                         where u.FirstName == s
                         select new
            {
                u.UserId
            };

            User user = new User();

            foreach (var u in query2)
            {
                user.UserId = u.UserId;
            }

            newApplication.UserId = user.UserId;

            db.Applications.Add(newApplication);
            db.SaveChanges();

            return(RedirectToAction("SentApplications"));
        }
예제 #4
0
        public ActionResult DeleteApplication(int applicationId = -1)
        {
            if (Session["aname"] == null)
            {
                return(RedirectToAction("index", "Home"));
            }

            if (applicationId == -1)
            {
                return(RedirectToAction("index"));
            }

            PAS_DatabaseEntities1 db = new PAS_DatabaseEntities1();

            Application application = db.Applications.Find(applicationId);

            db.Applications.Remove(application);
            db.SaveChanges();

            ViewBag.deleted = 1;


            return(RedirectToAction("index", ViewBag));
        }