Exemplo n.º 1
0
        public ActionResult University(String keyword){
            string searchType = "";
            if(!String.IsNullOrEmpty(Request["name"])){
                keyword = Request["name"];
                searchType = "name";
            }
            else if (!String.IsNullOrEmpty(Request["city"]))
            {
                keyword = Request["city"];
                searchType = "city";
            }
            else if (!String.IsNullOrEmpty(Request["state"]))
            {
                keyword = Request["state"];
                searchType = "state";
            }
            else if (!String.IsNullOrEmpty(Request["url"]))
            {
                keyword = Request["url"];
                searchType = "uniUrl";
            }

            ViewBag.Message = "University Page";

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            List<University> univs = new List<University>();

            univs = db.getUniversities(keyword, searchType);
            ViewData["unis"] = univs;

            return View();
        }
Exemplo n.º 2
0
        public ActionResult FavoriteUniversity()
        {
            if (ModelState.IsValid)
            {
                DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;

                String curEmail = User.Identity.Name;//get the email of the person logged in

                //get post data from request object
                List<String> favUnisData = new List<String>();

                foreach(var key in Request.Form.AllKeys)
                {
                    if (key.StartsWith("favUnis"))
                    {
                        String s = Convert.ToString(Request.Form[key]);
                        String[] values = s.Split(',');
                        foreach(var item in values)
                        {
                            db.addFavUniversity(curEmail, item); //add favUni to database
                        }//end foreach
                    }//end if
                }//end foreach


                return RedirectToAction("Index", "Home");
            }
            else
            {
                ModelState.AddModelError("","This action cannot be performed");
            }

            return View();
        }//end of post method
Exemplo n.º 3
0
        public ActionResult Program(String keyword)
        {
            string searchType = "";

            if (!String.IsNullOrEmpty(Request["name"]))
            {
                keyword    = Request["name"];
                searchType = "programname";
            }
            else if (!String.IsNullOrEmpty(Request["institution"]))
            {
                keyword    = Request["institution"];
                searchType = "schoolname";
            }
            else if (!String.IsNullOrEmpty(Request["city"]))
            {
                keyword    = Request["city"];
                searchType = "city";
            }
            else if (!String.IsNullOrEmpty(Request["state"]))
            {
                keyword    = Request["state"];
                searchType = "state";
            }

            ViewBag.Message = "Program Page";

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            progs = new List <Program>();

            progs = db.getPrograms(keyword, searchType);
            ViewData["programs"] = progs;

            return(View());
        }
Exemplo n.º 4
0
        }//end CreateAccountForm
        
        /// <summary>
        /// Creates the account page.
        /// </summary>
        /// <returns>The account page.</returns>
        public ActionResult CreateAccountPage()
        {
            ViewBag.Title = "Account Creation Page";
            //create Account model
            Account a = new Account();
            Profile p = new Profile();
            //get user response
            Console.Write(Request.HttpMethod);
            if (Request.HttpMethod == "POST")
            {
                a.email = Request.Form["email"];
                a.password = Request.Form["password"];
                a.firstName = Request.Form["firstName"];
                a.lastName = Request.Form["lastName"];
                a.birthday = Request.Form["birthday"];

                //empty profile created with account creation
                p.pEmail = Request.Form["email"];
                p.favUnis = null;
                p.deadlines = null;

                DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;

                //pass Account model object to the database to create the account
                db.createAccount(a);
                return View("/Views/Login/Login.cshtml");
            }
            return View();
        }//end CreateAccountPage()
Exemplo n.º 5
0
        public ActionResult SingleUniversity(University u, string s){

            s = "NULL";
            String curEmail = User.Identity.Name; //the user that is logged in

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            db.addURequest(u, curEmail, s);

            return RedirectToAction("University", "University");
        }
Exemplo n.º 6
0
        public ActionResult DeleteProfile()
        {
            string userEmail = User.Identity.Name;

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            db.deleteAccount(userEmail);                       //delete account
            System.Web.Security.FormsAuthentication.SignOut(); //reset auth cookie

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 7
0
        }//UniversitiesByState

        public static void ProgramScrape()
        {
            //get the university state, name and city
            DBUtilities.DBUtilities db   = DBUtilities.DBUtilities.Instance;
            List <University>       unis = db.displayUniversities();

            string s = "";

            foreach (var u in unis)
            {
                s = u.name;                   //the university name
                var    sArray = s.Split(' '); //separate each word in the name into a string array
                string endURL = "";

                //loop over the array to fix the url with appropriate dashes
                for (int i = 0; i < sArray.Length; i++)
                {
                    if (sArray[i].Equals("of"))
                    {
                        sArray[i] = "";
                    }
                    if (sArray[i].Contains("'"))
                    {
                        string st  = sArray[i];
                        string str = "";             //string that has no apostrophes
                        var    arr = st.Split('\''); //handles apostrophes

                        for (var item = 0; item < arr.Length; item++)
                        {
                            str += arr[item];
                        }


                        sArray[i] = str; //put the correct string back into the array
                        endURL   += sArray[i] + "-";
                    }
                    else
                    {
                        endURL += sArray[i] + "-";
                    }
                }//end for

                endURL += u.city.Replace(' ', '-'); //concatinate the city name to the university name for scraping purposes

                string url = "https://www.gradschools.com/graduate-schools-in-united-states/";
                url += u.state.Replace(' ', '-') + "/" + endURL + "?page=";

                ProgramScrape(url);
            } //foreach
        }     //end ProgramScrape()
Exemplo n.º 8
0
        public ActionResult University(int page = 0)
        {
            const int pageSize = 15; //number of elements per page

            ViewBag.Message = "University Page";

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            List <University> univs = new List<University>();

            univs = db.getUniversities("", "");
            var count = univs.Count;
            var data = univs.Skip(page * pageSize).Take(pageSize).ToList();
            ViewBag.MaxPage = (count / pageSize) - (count % pageSize == 0 ? 1 : 0);
            ViewBag.Page = page;

            ViewData["unis"] = data;

            return View(data); //automatically returns the University View
        }//end of get method
Exemplo n.º 9
0
        // GET: Program
        public ActionResult Program(int page = 0)
        {
            const int pageSize = 15; //number of elements per page

            ViewBag.Message = "Program Page";

            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
            progs = new List <Program>();

            progs = db.getPrograms("", "");
            var count = progs.Count;
            var data  = progs.Skip(page * pageSize).Take(pageSize).ToList();

            ViewBag.MaxPage = (count / pageSize) - (count % pageSize == 0 ? 1 : 0);
            ViewBag.Page    = page;

            ViewData["programs"] = data;
            return(View(data));
        }
Exemplo n.º 10
0
        public ActionResult Login(Account acc)
        {
            if (ModelState.IsValid)
            {
                DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;
                if (db.loginChecker(acc.email, acc.password))
                {
                    String name = db.getAccName(acc.email);

                    //set the account attribute, firstName, to the user's first name by
                    //quering the database for the name
                    //acc.firstName = name;
                    FormsAuthentication.SetAuthCookie(acc.email, true);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                } //else
            }     //if
            return(View(acc));
        }         //login
Exemplo n.º 11
0
        [Authorize] //if you are not authorized, it wont let you to the page
        public ActionResult Profile()
        {
            DBUtilities.DBUtilities db = DBUtilities.DBUtilities.Instance;

            String            userEmail = User.Identity.Name;
            String            name      = db.getAccName(userEmail);
            List <Program>    favProgs  = new List <Program>();
            List <University> favUnis   = db.getFavUniversities(userEmail);
            var size = favUnis.Count;

            if (size == 0)
            {
                University u = new University
                {
                    name        = "",
                    fundingtype = "",
                    city        = "",
                    state       = "",
                    environment = ""
                };
                favUnis.Add(u);
            }
            favProgs             = db.getFavPrograms(userEmail);
            ViewData["favUnis"]  = favUnis;
            ViewData["favProgs"] = favProgs;
            var    fullname = name.Split(' ');
            string fname    = fullname[0];
            string lname    = fullname[1];
            string bio      = "Ya win some ya lose some";

            ViewBag.fname = fname;
            ViewBag.lname = lname;
            ViewBag.bio   = bio;

            return(View());
        }