Example #1
0
        //public ActionResult Student(string school, string code)
        public ActionResult Student(string id)
        {
            if (id != null)
            {
                AccessCodeClient acc  = new AccessCodeClient();
                AccessCode       code = acc.GetByPartitionAndRowKey("accesscode", id);

                //AssessmentGroupPinCodeClient agpcc = new AssessmentGroupPinCodeClient();
                //AssessmentGroupPinCode groupInfo = agpcc.GetByPartitionAndRowKey("pincodes", id);
                if (code != null && code.School != "CareerThesaurus Demo School")
                {
                    SchoolAccountClient sac           = new SchoolAccountClient();
                    SchoolAccount       schoolAccount = sac.GetByPartitionAndRowKey("school", code.School);
                    ViewBag.SignUpSchoolZip  = schoolAccount.ZipCode;
                    ViewBag.SignUpSchool     = code.School;
                    ViewBag.SignUpSchoolName = schoolAccount.SchoolName;
                    ViewBag.SignUpCode       = code.Code;
                    ViewBag.SignUpGrade      = code.Grade;
                    ViewBag.SignUpCounselor  = code.Counselor;
                    ViewBag.SignUpGroupName  = code.GroupName;
                }
                else
                {
                    ViewBag.InvalidLink = true;
                }
            }
            return(View());
        }
 public ActionResult Groups(IEnumerable <string> year, IEnumerable <string> grade, IEnumerable <string> counselor, IEnumerable <string> groupname)
 {
     if (AuthTokens[0] == "demo")
     {
         ViewBag.DemoNextStep = NextStep("!");
         return(View());
     }
     if (year != null && grade != null && counselor != null && groupname != null)
     {
         if (year.Count() == grade.Count() && year.Count() == counselor.Count() && year.Count() == groupname.Count())
         {
             AdminAccountClient aac    = new AdminAccountClient();
             AccessCodeClient   acc    = new AccessCodeClient();
             AdminAccount       admin  = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower());
             string             school = admin.School;
             for (var i = 0; i < year.Count(); i++)
             {
                 acc.AddNewItem(new AccessCode {
                     RowKey = ShortGuidGenerator.NewGuid(), Code = PinCodeGenerator.NewPin(), Year = year.ElementAt(i), Grade = grade.ElementAt(i), Counselor = counselor.ElementAt(i), GroupName = groupname.ElementAt(i), School = school
                 });
             }
             ViewBag.CurrentYear = AccessCodeClient.CurrentGradYear();
             return(View());
         }
     }
     ViewBag.ErrorMessage = "error";
     ViewBag.CurrentYear  = AccessCodeClient.CurrentGradYear();
     return(View());
 }
Example #3
0
        public HttpResponse GetTeacherAndGroup(string pincode, string school, string grade)
        {
            string response;

            AccessCodeClient acc  = new AccessCodeClient();
            AccessCode       code = acc.GetBySchoolPinCodeGradeCurrent(school, pincode, grade);

            //AssessmentGroupClient agc = new AssessmentGroupClient();
            //AssessmentGroup group = agc.GetByPartitionAndRowKey(school, pincode);
            if (code != null)
            {
                if (code.School == school && code.Grade == grade)
                {
                    response = "{\"result\": \"ok\", \"counselor\":\"" + code.Counselor + "\", \"grade\":\"" + code.Grade + "\", \"year\":\"" + code.Year + "\", \"groupname\":\"" + code.GroupName + "\"}";
                }
                else
                {
                    response = "{\"result\": \"error\"}";
                }
            }
            else
            {
                response = "{\"result\": \"error\"}";
            }
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
        public HttpResponse CreateGroup(string school, string counselor, string groupname, string year, string grade)
        {
            if (AuthTokens[0] == "demo")
            {
                Response.ContentType = "application/json";
                Response.Write("{\"result\": \"ok\", \"pincode\": \"demo1\", \"url\": \"demo\"}");
                Response.End();
                return(null);
            }
            string response;
            string pincode = getUniquePinCode(school);
            string guid    = ShortGuidGenerator.NewGuid();

            AccessCodeClient acc = new AccessCodeClient();

            acc.AddNewItem(new AccessCode {
                RowKey = guid, Code = pincode, Counselor = counselor, Grade = grade, School = school, Year = year, GroupName = groupname
            });

            //AssessmentGroupClient agc = new AssessmentGroupClient();
            //AssessmentGroupPinCodeClient agpcc = new AssessmentGroupPinCodeClient();
            //agc.AddNewItem(new AssessmentGroup { PartitionKey = school, RowKey = pincode, Teacher = teacher, Group = group });
            //agpcc.AddNewItem(new AssessmentGroupPinCode { RowKey = guid, PinCode = pincode, School = school, Teacher = teacher, Group = group });
            response             = "{\"result\": \"ok\", \"pincode\": \"" + pincode + "\", \"url\": \"" + guid + "\"}";
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
 public ActionResult Index(IEnumerable <string> year, IEnumerable <string> grade, IEnumerable <string> groupname)
 {
     if (AuthTokens[0] == "demo")
     {
         return(View());
     }
     if (year != null && grade != null && groupname != null)
     {
         if (year.Count() == grade.Count() && year.Count() == groupname.Count())
         {
             string counselor               = AuthTokens[1].ToLower();
             CounselorAccountClient cac     = new CounselorAccountClient();
             AccessCodeClient       acc     = new AccessCodeClient();
             CounselorAccount       account = cac.GetByPartitionAndRowKey("counselor", counselor);
             string school = account.School;
             for (var i = 0; i < year.Count(); i++)
             {
                 acc.AddNewItem(new AccessCode {
                     RowKey = ShortGuidGenerator.NewGuid(), Code = PinCodeGenerator.NewPin(), Year = year.ElementAt(i), Grade = grade.ElementAt(i), Counselor = counselor, GroupName = groupname.ElementAt(i), School = school
                 });
             }
             return(RedirectToAction("Index"));
         }
     }
     TempData["error"] = true;
     return(RedirectToAction("Index"));
 }
        public ActionResult Index()
        {
            string               counselor = AuthTokens[1];
            AccessCodeClient     acc       = new AccessCodeClient();
            JavaScriptSerializer jss       = new JavaScriptSerializer();
            List <AccessCode>    groups    = new List <AccessCode>(acc.GetAllByCounselor(counselor));
            string               years     = "[]";
            string               grades    = "[]";

            if (groups.Count != 0)
            {
                years  = JsonConvert.SerializeObject(groups.Select(x => x.Year).Distinct().ToList());
                grades = JsonConvert.SerializeObject(groups.Select(x => x.Grade).Distinct().ToList());
            }
            if (TempData["counselor"] != null)
            {
                ViewBag.FirstVisit = true;
            }
            ViewBag.CurrentYear = AccessCodeClient.CurrentGradYear();
            ViewBag.Groups      = JsonConvert.SerializeObject(groups);
            ViewBag.Years       = years;
            ViewBag.Grades      = grades;
            if (TempData["error"] != null)
            {
                ViewBag.ErrorMessage = true;
            }
            return(View());
        }
 public ActionResult Groups()
 {
     if (AuthTokens[0] == "demo")
     {
         ViewBag.DemoNextStep = NextStep("g");
     }
     ViewBag.CurrentYear = AccessCodeClient.CurrentGradYear();
     return(View());
 }
        // private functions ===============================================================================================================================================
        private string getUniquePinCode(string school)
        {
            string pincode = PinCodeGenerator.NewPin();

            AccessCodeClient acc  = new AccessCodeClient();
            AccessCode       code = acc.GetBySchoolAndPinCode(school, pincode);

            //AssessmentGroupClient agc = new AssessmentGroupClient();
            //AssessmentGroup groupEntry = agc.GetByPartitionAndRowKey(school, pincode);
            while (code != null)
            {
                pincode = PinCodeGenerator.NewPin();
                code    = acc.GetBySchoolAndPinCode(school, pincode);
            }
            return(pincode);
        }
        public ActionResult AccessCode(string id)
        {
            Regex reg = new Regex("^[a-zA-Z0-9]*$");

            if (id != null && reg.IsMatch(id))
            {
                AccessCodeClient acc        = new AccessCodeClient();
                AccessCode       accessCode = acc.GetByPartitionAndRowKey("accesscode", id);
                if (accessCode != null)
                {
                    ViewBag.AccessCode = id;
                    return(View());
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #10
0
        public ActionResult Student(FormCollection collection)
        {
            UserAccountClient uac     = new UserAccountClient();
            UserAccount       account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), collection["email"]);

            if (account == null)
            {
                AccessCodeClient aac  = new AccessCodeClient();
                AccessCode       code = aac.GetBySchoolPinCodeCounselorGrade(collection["school"], collection["accesscode"], collection["counselor"], collection["grade"]);

                if (code == null || code.School == "7181234567")
                {
                    ViewBag.ErrorMessage = "Invalid fields";
                    return(RedirectToAction("Index"));
                }

                uac.AddNewItem(new UserAccount {
                    PartitionKey = UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), RowKey = collection["email"].ToLower(), FirstName = collection["firstname"], LastName = collection["lastname"], Email = collection["email"], Password = collection["password"], ProfileType = "student"
                });

                StudentAccountClient sac = new StudentAccountClient();
                sac.AddNewItem(new StudentAccount {
                    PartitionKey = StudentAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), RowKey = collection["email"].ToLower(), Gender = collection["gender"], StudentID = collection["studentid"], School = collection["school"], Counselor = collection["counselor"], Year = code.Year, Grade = collection["grade"], GroupName = code.GroupName
                });

                //StudentProfileClient spc = new StudentProfileClient();
                //spc.AddNewItem(new StudentProfile { PartitionKey = StudentProfileClient.GetPartitionKeyForEmail(collection["email"]), RowKey = collection["email"].ToLower(), Gender = collection["gender"], GradYear = collection["gradyear"], School = school, SchoolZip = collection["zipcode"], Teacher = teacher, Group = group });
            }
            else
            {
                ViewBag.ErrorMessage = "There is an account already associated with this email. Please log in instead.";
                return(View());
            }

            SendVerificationEmail(collection["email"].ToLower(), collection["firstname"]);

            SchoolAccountClient saclient      = new SchoolAccountClient();
            SchoolAccount       schoolAccount = saclient.GetByPartitionAndRowKey("school", collection["school"]);
            UserAccount         adminAccount  = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(collection["counselor"]), collection["counselor"]);
            EmailManager        emailManager  = new EmailManager();
            string str = "<p>Full name: " + collection["firstname"] + " " + collection["lastname"] + "</p><p>Email: " + collection["email"].ToLower() + "</p><p>School: " + (schoolAccount != null ? schoolAccount.SchoolName : "") + "</p><p>Counselor: " + (adminAccount != null ? adminAccount.FirstName + " " + adminAccount.LastName : "") + "</p><p>Grade: " + collection["grade"] + "</p><p>Year: " + collection["year"] + "</p>";

            emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "HS Student", str);
            return(RedirectToAction("Complete"));
        }
        public ActionResult Index()
        {
            string user = AuthTokens[1];

            StudentAccountClient      sac     = new StudentAccountClient();
            StudentAccount            student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user);
            AssessmentInterestClient  aic     = new AssessmentInterestClient();
            List <AssessmentInterest> importantThingRatings = new List <AssessmentInterest>(aic.GetAllCurrentByStudent(student.School, user, student.Year, student.Grade));
            AssessmentCareerClient    acc           = new AssessmentCareerClient();
            List <AssessmentCareer>   careerRatings = new List <AssessmentCareer>(acc.GetAllCurrentByStudent(student.School, user, student.Year, student.Grade));

            //StudentProfileClient spc = new StudentProfileClient();
            //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user);
            //AssessmentInterestRatingClient airc = new AssessmentInterestRatingClient();
            //List<AssessmentInterestRating> importantThingRatings = new List<AssessmentInterestRating>(airc.GetAllBySchoolAndStudent(student.School, user));
            //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient();
            //List<AssessmentCareerRating> careerRatings = new List<AssessmentCareerRating>(acrc.GetAllBySchoolAndStudent(student.School, user));
            ViewBag.CareersRated = careerRatings.Count == 0 ? "no" : "yes";
            ViewBag.School       = student.School;
            JavaScriptSerializer jss = new JavaScriptSerializer();

            ViewBag.interestsRated = jss.Serialize(importantThingRatings.Where(x => x.Value == "1").Select(x => x.Interest).ToList());
            if (importantThingRatings.Where(x => x.Value == "1").ToList().Count == 3)
            {
                ViewBag.ImportantThings = "yes";
            }
            else
            {
                ViewBag.ImportantThings = "no";
            }
            if (TempData["message"] != null)
            {
                ViewBag.Message = TempData["message"];
            }
            if (TempData["successmessage"] != null)
            {
                ViewBag.Successmessage = TempData["successmessage"];
            }
            ViewBag.UpdateAccessCode = student.Year != AccessCodeClient.CurrentGradYear();
            return(View());
        }
        public ActionResult Index(string grade, string accesscode, string zipcode)
        {
            string user = AuthTokens[1];

            StudentAccountClient sac        = new StudentAccountClient();
            StudentAccount       student    = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user);
            AccessCodeClient     acc        = new AccessCodeClient();
            AccessCode           accessCode = acc.GetByPinCodeAndGradeCurrent(accesscode, grade);

            if (accessCode != null)
            {
                if (student.Active)
                {
                    if (student.School != accessCode.School)
                    {
                        TempData["message"] = "You still have an active status in another school";
                    }
                    else if (student.Year == accessCode.Year)
                    {
                        TempData["message"] = "You already updated your information with new access code this year";
                    }
                    else
                    {
                        student.Year               = accessCode.Year;
                        student.Grade              = accessCode.Grade;
                        student.Counselor          = accessCode.Counselor;
                        student.GroupName          = accessCode.GroupName;
                        student.AssessmentComplete = false;
                        student.RatedCareers       = 0;
                        student.RatedDimensions    = 0;
                        student.RatedInterests     = 0;
                        sac.Update(student);
                        TempData["successmessage"] = "Your information was updated for this year";
                    }
                }
                else
                {
                    if (student.School != accessCode.School)
                    {
                        student.School             = accessCode.School;
                        student.Year               = accessCode.Year;
                        student.Grade              = accessCode.Grade;
                        student.Counselor          = accessCode.Counselor;
                        student.GroupName          = accessCode.GroupName;
                        student.AssessmentComplete = false;
                        student.RatedCareers       = 0;
                        student.RatedDimensions    = 0;
                        student.RatedInterests     = 0;
                        sac.Update(student);
                        TempData["successmessage"] = "Your information and school was updated for this year";
                    }
                    else
                    {
                        TempData["message"] = "Your account was marked as inactive";
                    }
                }
            }
            else
            {
                TempData["message"] = "Access link you used is invalid or expired";
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult LogIn(FormCollection collection)
        {
            string            accessurl = collection["accessurl"];
            UserAccountClient uac       = new UserAccountClient();
            UserAccount       account   = uac.Logon(collection["email"].ToLower(), collection["password"]);

            if (account == null)
            {
                if (accessurl != null)
                {
                    ViewBag.AccessCode = accessurl;
                }
                ViewBag.InvalidEmail = collection["email"].ToLower();
                return(View());
            }
            else if (account.EmailConfirmed == false)
            {
                ViewBag.VerifyEmail             = collection["email"].ToLower();
                ViewBag.ResendConfirmationEmail = true;
                return(View());
            }
            if (account.ProfileType == "su")
            {
                SaveSessionCookie(collection["email"].ToLower(), account.FirstName + " " + account.LastName, account.ProfileType);
            }
            else if (account.ProfileType == "administrator")
            {
                AdminAccountClient aac   = new AdminAccountClient();
                AdminAccount       admin = aac.GetByPartitionAndRowKey("admin", account.RowKey);
                SaveSessionCookie(collection["email"].ToLower(), account.FirstName + " " + account.LastName, account.ProfileType);
                if (admin.SchoolSelected)
                {
                    return(RedirectToAction("Index", "AdminPortal"));
                }
                else
                {
                    return(RedirectToAction("AddSchool", "AdminPortal"));
                }
            }
            else if (account.ProfileType == "counselor")
            {
                CounselorAccountClient cac       = new CounselorAccountClient();
                CounselorAccount       counselor = cac.GetByPartitionAndRowKey("counselor", account.RowKey);
                if (counselor.Active)
                {
                    SaveSessionCookie(collection["email"].ToLower(), account.FirstName + " " + account.LastName, account.ProfileType);
                    return(RedirectToAction("Index", "CounselorPortal"));
                }
                else
                {
                    ViewBag.ErrorMessage = "Not Active";
                    return(View());
                }
            }
            else if (account.ProfileType == "student")
            {
                StudentAccountClient sac        = new StudentAccountClient();
                StudentAccount       student    = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(account.Email), account.Email);
                AccessCodeClient     acc        = new AccessCodeClient();
                AccessCode           accessCode = acc.GetByPartitionAndRowKey("accesscode", accessurl);
                if (accessCode != null && accessCode.Year == AccessCodeClient.CurrentGradYear())
                {
                    if (student.Active)
                    {
                        if (student.School != accessCode.School)
                        {
                            TempData["activeschool"] = true;
                        }
                        else if (student.Year == accessCode.Year)
                        {
                            TempData["sameyear"] = true;
                        }
                        else
                        {
                            student.Year               = accessCode.Year;
                            student.Grade              = accessCode.Grade;
                            student.Counselor          = accessCode.Counselor;
                            student.GroupName          = accessCode.GroupName;
                            student.AssessmentComplete = false;
                            sac.Update(student);
                        }
                    }
                    else
                    {
                        if (student.School != accessCode.School)
                        {
                            student.School             = accessCode.School;
                            student.Year               = accessCode.Year;
                            student.Grade              = accessCode.Grade;
                            student.Counselor          = accessCode.Counselor;
                            student.GroupName          = accessCode.GroupName;
                            student.AssessmentComplete = false;
                            sac.Update(student);
                        }
                        else
                        {
                            TempData["inactive"] = true;
                        }
                    }
                }
                else
                {
                    TempData["invalid"] = true;
                }
                SaveSessionCookie(collection["email"].ToLower(), account.FirstName + " " + account.LastName, account.ProfileType);
                //StudentProfileClient spc = new StudentProfileClient();
                //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(account.Email), account.Email);
                Response.Cookies["firstname"].Value   = account.FirstName;
                Response.Cookies["firstname"].Expires = DateTime.UtcNow.AddDays(7);
                Response.Cookies["lastname"].Value    = account.LastName;
                Response.Cookies["lastname"].Expires  = DateTime.UtcNow.AddDays(7);
                Response.Cookies["email"].Value       = account.Email;
                Response.Cookies["email"].Expires     = DateTime.UtcNow.AddDays(7);
                Response.Cookies["gender"].Value      = student.Gender;
                Response.Cookies["gender"].Expires    = DateTime.UtcNow.AddDays(7);
                Response.Cookies["clr"].Value         = "1";
                Response.Cookies["clr"].Expires       = DateTime.UtcNow.AddDays(7);
                Response.Cookies["cbnvm"].Value       = "1";
                Response.Cookies["cbnvm"].Expires     = DateTime.UtcNow.AddDays(7);

                AssessmentDimensionClient adc = new AssessmentDimensionClient();
                AssessmentInterestClient  aic = new AssessmentInterestClient();

                //AssessmentDimensionsRatingClient adrc = new AssessmentDimensionsRatingClient();
                //AssessmentInterestRatingClient airc = new AssessmentInterestRatingClient();
                JavaScriptSerializer      jss = new JavaScriptSerializer();
                List <AssessmentInterest> importantThingRatings = new List <AssessmentInterest>(aic.GetAllCurrentByStudent(student.School, account.RowKey, student.Year, student.Grade));
                //List<AssessmentInterestRating> importantThingRatings = new List<AssessmentInterestRating>(airc.GetAllBySchoolAndStudent(student.School, account.RowKey));
                Response.Cookies["interests"].Value   = jss.Serialize(importantThingRatings.Where(x => x.Value == "1").Select(x => x.Interest).ToList());
                Response.Cookies["interests"].Expires = DateTime.UtcNow.AddDays(7);
                for (var i = 0; i < dimensions.Length; i++)
                {
                    //AssessmentDimensionsRating dimensionsRating = adrc.GetByPartitionAndRowKey(student.School, account.Email + dimensions[i]);
                    AssessmentDimension dimensionsRating = adc.GetByPartitionAndRowKey(student.School, account.Email + student.Year + student.Grade + dimensions[i]);
                    if (dimensionsRating != null)
                    {
                        Response.Cookies[dimensions[i]].Value   = dimensionsRating.Value;
                        Response.Cookies[dimensions[i]].Expires = DateTime.UtcNow.AddDays(7);
                        if (i == 0)
                        {
                            Response.Cookies["question1"].Value   = (dimensionsRating.Misc != null ? dimensionsRating.Misc : dimensionsRating.Value);
                            Response.Cookies["question1"].Expires = DateTime.UtcNow.AddDays(7);
                        }
                    }
                }
                return(RedirectToAction("Index", "StudentPortal"));
            }
            return(RedirectToAction("Index", "Home"));
        }