Пример #1
0
 public ActionResult edit(FullProfile fullprofile)
 {
     using (MsInUsEntities connection = new MsInUsEntities())
     {
         if (Session["UserName"] != null)
         {
             int         id = Convert.ToInt32(Session["UserId"]);
             FullProfile fp = connection.FullProfiles.Where(m => m.Id == id).FirstOrDefault();
             connection.FullProfiles.Remove(fp);
             connection.SaveChanges();
             if (fullprofile.Toefl == false)
             {
                 fullprofile.Ielts = true;
             }
             if (fullprofile.Toefl == null)
             {
                 fullprofile.Toefl = false; fullprofile.Ielts = false;
             }
             fullprofile.personalScore = getscore(fullprofile);
             connection.FullProfiles.Add(fullprofile);
             connection.SaveChanges();
         }
     }
     return(RedirectToAction("MyProfile", "Profiles"));
 }
Пример #2
0
        public JsonResult searchCourses(string term, int?univid)
        {
            MsInUsEntities connection = new MsInUsEntities();
            List <string>  jsresult   = connection.University_Deadlines.Where(m => (m.Univ_Id == univid && m.Course.ToLower().Contains(term.ToLower()))).Select(m => m.Course).Distinct().ToList();

            return(Json(jsresult, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
 public void initilization(FullProfile fullprofile)
 {
     using (MsInUsEntities dtbase = new MsInUsEntities())
     {
         List <SelectListItem> items = new List <SelectListItem>();
         foreach (var c in dtbase.CourseWorks)
         {
             items.Add(new SelectListItem()
             {
                 Value = c.Course, Text = c.Course
             });
         }
         fullprofile.itemslist = items;
         List <SelectListItem> day = new List <SelectListItem>();
         for (int i = 1; i <= 31; i++)
         {
             day.Add(new SelectListItem()
             {
                 Text = Convert.ToString(i), Value = Convert.ToString(i), Selected = (DateTime.Today.Day == i)
             });
         }
         fullprofile.listday = day;
         List <SelectListItem> year = new List <SelectListItem>();
         for (int p = DateTime.Today.Year - 2; p < DateTime.Today.Year + 6; p++)
         {
             year.Add(new SelectListItem()
             {
                 Text = Convert.ToString(p), Value = Convert.ToString(p), Selected = (DateTime.Today.Year == p)
             });
         }
         fullprofile.listyear = year;
         List <SelectListItem> month = new List <SelectListItem>();
         foreach (var c in System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthGenitiveNames)
         {
             month.Add(new SelectListItem()
             {
                 Text = c, Value = c, Selected = (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Today.Month) == c)
             });
         }
         fullprofile.listMonth = month;
         List <SelectListItem> papersList = new List <SelectListItem>();
         for (int i = 0; i < papers.Length; i++)
         {
             papersList.Add(new SelectListItem()
             {
                 Text = papers[i], Value = papers[i]
             });
         }
         fullprofile.listpapers = papersList;
         List <SelectListItem> termlist = new List <SelectListItem>();
         for (int i = 0; i < term.Length; i++)
         {
             termlist.Add(new SelectListItem()
             {
                 Text = term[i], Value = term[i]
             });
         }
         fullprofile.listterm = termlist;
     }
 }
Пример #4
0
 public ActionResult add(FullProfile fullprofile)
 {
     using (MsInUsEntities connection = new MsInUsEntities())
     {
         try
         {
             if (Session["UserName"] != null)
             {
                 fullprofile.Id = Convert.ToInt32(Session["UserId"]);
                 if (fullprofile.Toefl == false)
                 {
                     fullprofile.Ielts = true;
                 }
                 else if (fullprofile.Toefl == null)
                 {
                     fullprofile.Toefl = false;
                 }
                 fullprofile.Ielts         = false;
                 fullprofile.personalScore = getscore(fullprofile);
                 connection.FullProfiles.Add(fullprofile);
                 connection.SaveChanges();
                 Session.Remove("AddProfile");
             }
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException e)
         {
             string msg = e.InnerException.Message;
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Пример #5
0
        public ActionResult settings()
        {
            MsInUsEntities        connection = new MsInUsEntities();
            List <SelectListItem> year       = new List <SelectListItem>();

            for (int p = DateTime.Today.Year - 40; p < DateTime.Today.Year - 16; p++)
            {
                year.Add(new SelectListItem()
                {
                    Text = Convert.ToString(p), Value = Convert.ToString(p), Selected = (DateTime.Today.Year - 14 == p)
                });
            }
            UserProfile        userprofile = new UserProfile();
            FullProfile        fullprofile = new FullProfile();
            ProfilesController pc          = new ProfilesController();
            int id = Convert.ToInt32(Session["UserId"]);

            userprofile = connection.UserProfiles.Find(keyValues: id);
            if (userprofile.DOB != null)
            {
                userprofile.DOBMonth = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(userprofile.DOB.Value.Month);
                userprofile.DOBYear  = userprofile.DOB.Value.Year;
                userprofile.DOBday   = userprofile.DOB.Value.Day;
            }
            pc.initilization(fullprofile);
            userprofile.FullProfile = fullprofile;
            userprofile.doBirthYear = year;
            return(View(userprofile));
        }
Пример #6
0
 public ActionResult changepassword(UserProfile userprofile)
 {
     try
     {
         MsInUsEntities connection = new MsInUsEntities();
         int            id         = Convert.ToInt32(Session["UserId"]);
         UserProfile    usobj      = connection.UserProfiles.SingleOrDefault(m => m.Id == id);
         usobj.Password         = MyEncryption.EncodePasswordToBase64(userprofile.Password);
         usobj.ConfirmPassword  = MyEncryption.EncodePasswordToBase64(userprofile.ConfirmPassword);
         usobj.Email_IdRegister = usobj.Email_Id;
         connection.SaveChanges();
         TempData["ConfirmationMessage"] = "Password Changed Successfully!";
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException e)
     {
         StreamWriter sw = new StreamWriter(@"D:\MasterStudy\MsInUsa\MsInUsa\Log\logs.txt", true);
         foreach (var c in e.EntityValidationErrors)
         {
             foreach (var ex in c.ValidationErrors)
             {
                 sw.WriteLine(ex.ErrorMessage);
             }
         }
         sw.Close();
         return(RedirectToAction("NotFound", "Error"));
     }
     return(RedirectToAction("changepassword", "Account"));
 }
Пример #7
0
 public ActionResult settings(UserProfile userprofile)
 {
     try
     {
         if (userprofile != null)
         {
             string dateobj = userprofile.DOBMonth + "/" + userprofile.DOBday + "/" + userprofile.DOBYear;
             userprofile.DOB = DateTime.Parse(dateobj);
             using (MsInUsEntities connection = new MsInUsEntities())
             {
                 var userprofileobj = connection.UserProfiles.Find(userprofile.Id);
                 userprofileobj.Email_IdRegister = userprofile.Email_Id;
                 userprofileobj.ConfirmPassword  = userprofile.Password;
                 connection.Entry(userprofileobj).CurrentValues.SetValues(userprofile);
                 connection.SaveChanges();
                 return(RedirectToAction("Myprofile", "Profiles"));
             }
         }
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException e)
     {
         StreamWriter sw = new StreamWriter(@"D:\MasterStudy\MsInUsa\MsInUsa\Log\logs.txt", true);
         foreach (var c in e.EntityValidationErrors)
         {
             foreach (var ex in c.ValidationErrors)
             {
                 sw.WriteLine(ex.ErrorMessage);
             }
         }
         sw.Close();
         return(RedirectToAction("NotFound", "Error"));
     }
     return(View());
 }
Пример #8
0
        public JsonResult searchUniversities(string term)
        {
            MsInUsEntities connection = new MsInUsEntities();
            //List<string> jsresult = connection.Universities_list.Where(m => (m.UnivName.ToLower().StartsWith(term.ToLower()) || m.NickName.ToLower().Contains(term.ToLower()))).Select(m => m.UnivName).ToList();
            Dictionary <string, string> jsresult = connection.Universities_list.Where(m => m.UnivName.ToLower().Contains(term.ToLower())).ToDictionary(m => Convert.ToString(m.UnivId), m => m.UnivName);

            return(Json(jsresult, JsonRequestBehavior.AllowGet));
        }
Пример #9
0
 public ActionResult reviews(int?id)
 {
     if (id == null)
     {
         return(RedirectToAction("Index", "Universities"));
     }
     using (MsInUsEntities connection = new MsInUsEntities())
     {
         Universities_list universities_list = connection.Universities_list.SingleOrDefault(m => m.UnivId == id);
         universities_list.universitycourses = connection.University_Deadlines.Where(m => m.Univ_Id == id).Select(m => m.Course).Distinct().ToList();
         return(View(universities_list));
     }
 }
Пример #10
0
 public ActionResult compare(string universities, int?page)
 {
     if (universities != "")
     {
         ViewBag.sortparamUniv = universities;
         string[] univ = universities.Split(',').ToArray();
         using (MsInUsEntities connection = new MsInUsEntities()){
             IPagedList <Universities_list> universitylist = connection.Universities_list.Where(m => univ.Any(y => y == m.UnivId.ToString())).ToList().ToPagedList(page ?? 1, 5);
             // universities(m.UnivId.ToString())).ToList().ToPagedList(page ?? 1, 5);
             return(View(universitylist));
         }
     }
     return(RedirectToAction("CompareUniversities", "Universities"));
 }
Пример #11
0
        public ActionResult Myprofile()
        {
            MsInUsEntities dtbase       = new MsInUsEntities();
            FullProfile    fullprofiles = new FullProfile();
            ///initilization(fullprofiles);
            int id = Convert.ToInt32(Session["UserId"]);

            fullprofiles = dtbase.FullProfiles.FirstOrDefault(m => m.Id == id);
            if (dtbase.AdmitsRejects.Any(m => m.StudentId == id))
            {
                fullprofiles.admitrejects = dtbase.AdmitsRejects.Where(m => m.StudentId == id).ToList();
            }
            return(View(fullprofiles));
        }
Пример #12
0
        public ActionResult UniversitiesDeadlines(int?page, string sortby)
        {
            MsInUsEntities ms = new MsInUsEntities();

            ViewBag.sortUniv     = String.IsNullOrEmpty(sortby) ? "Univdesc" : "";
            ViewBag.sortCourse   = sortby == "Course" ? "Coursedesc" : "Course";
            ViewBag.sortTerm     = sortby == "Term" ? "Termdesc" : "Term";
            ViewBag.sortDeadline = sortby == "Deadline" ? "Deadlinedesc" : "Deadline";
            IEnumerable <University_Deadlines> univ = ms.University_Deadlines.Where(m => m.Deadline != null).ToList();

            switch (sortby)
            {
            case "Univdesc":
                univ = univ.OrderByDescending(m => m.Universities_list.UnivName);
                break;

            case "Coursedesc":
                univ = univ.OrderByDescending(m => m.Course);
                break;

            case "Course":
                univ = univ.OrderBy(m => m.Course);
                break;

            case "Termdesc":
                univ = univ.OrderByDescending(m => m.Term);
                break;

            case "Term":
                univ = univ.OrderBy(m => m.Term);
                break;

            case "Deadline":
                univ = univ.OrderBy(m => m.Deadline);
                break;

            case "Deadlinedesc":
                univ = univ.OrderByDescending(m => m.Deadline);
                break;

            default:
                univ = univ.OrderBy(m => m.Universities_list.UnivName);
                break;
            }
            return(View(univ.ToPagedList(page ?? 1, 10)));
        }
Пример #13
0
 public ActionResult Register(UserProfile userprofile)
 {
     if (userprofile != null)
     {
         using (MsInUsEntities msInUsConnection = new MsInUsEntities())
         {
             int rowcount = msInUsConnection.UserProfiles.Count();
             userprofile.Password        = MyEncryption.EncodePasswordToBase64(userprofile.Password);
             userprofile.ConfirmPassword = MyEncryption.EncodePasswordToBase64(userprofile.ConfirmPassword);
             userprofile.Email_Id        = userprofile.Email_IdRegister;
             msInUsConnection.UserProfiles.Add(userprofile);
             msInUsConnection.SaveChanges();
             TempData["ConfirmationMessage"] = "Registered Successfully";
             //Session.Add("Registration Message", "Registered Successfully");
             if (rowcount < msInUsConnection.UserProfiles.Count())
             {
                 return(RedirectToAction("LogIn", "Account"));
             }
         }
     }
     return(RedirectToAction("NotFound", "Error"));
 }
Пример #14
0
 public ActionResult LogIn(UserProfile userprofile)
 {
     //connects and checks with the user credentials
     using (MsInUsEntities msInUsConnection = new MsInUsEntities())
     {
         if (!msInUsConnection.UserProfiles.Any(m => m.Email_Id == userprofile.Email_Id))
         {
             TempData["ErrorLogin"] = "******";
             return(RedirectToAction("LogIn", "Account"));
         }
         string userpassword = msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).Password;
         if (userpassword != null && userprofile.Password == MyEncryption.DecodeFrom64(userpassword))
         {
             removeUserSession();
             Session.Add("UserName", msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).FirstName);
             Session.Add("UserId", msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).Id);
             return(RedirectToAction("Index", "Home"));
         }
     }
     TempData["ErrorLogin"] = "******";
     return(RedirectToAction("LogIn", "Account"));
 }
Пример #15
0
        public ActionResult Index(int?page, string sortby)
        {
            using (MsInUsEntities connection = new MsInUsEntities()){
                ViewBag.sortUniv = String.IsNullOrEmpty(sortby) ? "Univdesc" : "";
                ViewBag.sortRank = sortby == "Rank" ? "Rankdesc" : "Rank";
                ViewBag.sortType = sortby == "Type" ? "Typedesc" : "Type";
                List <Universities_list> universities_list = connection.Universities_list.OrderBy(m => m.UnivName).ToList();
                ViewBag.count = universities_list.Count;
                switch (sortby)
                {
                case "Univdesc":
                    universities_list = universities_list.OrderByDescending(m => m.UnivName).ToList();
                    break;

                case "Rank":
                    universities_list = universities_list.OrderBy(m => m.Rank).ToList();
                    break;

                case "Rankdesc":
                    universities_list = universities_list.OrderByDescending(m => m.Rank).ToList();
                    break;

                case "Type":
                    universities_list = universities_list.OrderBy(m => m.UnivType).ToList();
                    break;

                case "Typedesc":
                    universities_list = universities_list.OrderByDescending(m => m.UnivType).ToList();
                    break;

                default:
                    break;
                }
                return(View(universities_list.ToPagedList(page ?? 1, 10)));
            }
        }
Пример #16
0
        //Checks whether user is availble when registering
        public JsonResult isUserAvailable(string Email_IdRegister)
        {
            MsInUsEntities connection = new MsInUsEntities();

            return(Json(!connection.UserProfiles.Any(m => m.Email_Id == Email_IdRegister), JsonRequestBehavior.AllowGet));
        }