public HttpResponse StudentStatus(string user) { string response; if (AuthTokens[0] != "demo") { StudentAccountClient sac = new StudentAccountClient(); StudentAccount account = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); if (account != null) { account.Active = !account.Active; sac.Update(account); response = "{\"result\": \"done\"}"; } else { response = "{\"result\": \"error\"}"; } } else { response = "{\"result\": \"done\"}"; } Response.ContentType = "application/json"; Response.Write(response); Response.End(); return(null); }
public void SaveDimension(string user, string dimension, string value, string misc) { StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); if (student != null) { AssessmentDimensionClient adc = new AssessmentDimensionClient(); AssessmentDimension dimensionRating = adc.GetByPartitionAndRowKey(student.School, user + student.Year + student.Grade + dimension); if (dimensionRating == null) { student.RatedDimensions++; sac.Update(student); adc.AddNewItem(new AssessmentDimension { PartitionKey = student.School, RowKey = user + student.Year + student.Grade + dimension, Value = value, Misc = misc, Counselor = student.Counselor, Student = user, Grade = student.Grade, GroupName = student.GroupName, Dimension = dimension, Year = student.Year }); //adrc.AddNewItem(new AssessmentDimensionsRating { PartitionKey = student.School, RowKey = user + dimension, Dimension = dimension, Value = value, Misc = misc, GradYear = student.GradYear, Student = student.RowKey, Teacher = student.Teacher, Group = student.Group }); } else { dimensionRating.Value = value; dimensionRating.Misc = misc; adc.Update(dimensionRating); } } //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user); //AssessmentDimensionsRatingClient adrc = new AssessmentDimensionsRatingClient(); //AssessmentDimensionsRating dimensionRating = adrc.GetByPartitionAndRowKey(student.School, user + dimension); }
public ActionResult Report(string id) { if (id != null && id != "") { StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(id), id); //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(id), id); if (student != null && AuthTokens[3] == "administrator" && student.Counselor == AuthTokens[1]) { UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(id), id); // ViewBag.StudentName = account.FirstName + " " + account.LastName; ViewBag.StudentFirstName = account.FirstName; ViewBag.StudentLastName = account.LastName; ViewBag.StudentToShow = id; } } else if (AuthTokens[3] == "administrator") { return(RedirectToAction("Assessment", "Index")); } return(View()); }
public HttpResponse GetCareerRatings(string user) { JavaScriptSerializer jss = new JavaScriptSerializer(); StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); 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); //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient(); //List<AssessmentCareerRating> careerRatings = new List<AssessmentCareerRating>(acrc.GetAllBySchoolAndStudent(student.School, user)); List <CareerRating> results = new List <CareerRating>(); string response; if (careerRatings.Count != 0) { foreach (AssessmentCareer careerRating in careerRatings) { results.Add(new CareerRating { dolcode = careerRating.DolCode, rating = careerRating.Value }); } response = "{\"result\": \"ok\", \"results\":" + jss.Serialize(results) + "}"; } else { response = "{\"result\": \"ok\", \"results\":[]}"; } Response.ContentType = "application/json"; Response.Write(response); Response.End(); return(null); }
public void SaveInterest(string user, string interest, string rating) { StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); if (student != null) { AssessmentInterestClient aic = new AssessmentInterestClient(); AssessmentInterest interestRating = aic.GetByPartitionAndRowKey(student.School, user + student.Year + student.Grade + interest); if (interestRating == null) { aic.AddNewItem(new AssessmentInterest { PartitionKey = student.School, RowKey = user + student.Year + student.Grade + interest, Value = rating, Counselor = student.Counselor, Student = user, Grade = student.Grade, GroupName = student.GroupName, Interest = interest, Year = student.Year }); //airc.AddNewItem(new AssessmentInterestRating { PartitionKey = student.School, RowKey = user + interest, Rating = rating, GradYear = student.GradYear, Student = user, Teacher = student.Teacher, Group = student.Group }); } else { interestRating.Value = rating; aic.Update(interestRating); } } //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user); //AssessmentInterestRatingClient airc = new AssessmentInterestRatingClient(); //AssessmentInterestRating interestRating = airc.GetByPartitionAndRowKey(student.School, user + interest); }
public ActionResult ConfirmEmail(string id) { if (id != null) { SimpleAES aes = new SimpleAES(); string email = aes.DecryptString(id); UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(email), email); if (account != null) { account.EmailConfirmed = true; uac.Update(account); if (account.ProfileType == "student") { StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(account.Email), account.Email); //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(account.Email), account.Email); string sessionkey = ClientSession.GetClientSessionKey("user", account.Email, account.FirstName + " " + account.LastName, "student"); Response.Cookies["sessionkey"].Value = sessionkey; Response.Cookies["sessionkey"].Expires = DateTime.UtcNow.AddDays(7); Response.Cookies["sessionusername"].Value = account.Email; Response.Cookies["sessionusername"].Expires = DateTime.UtcNow.AddDays(7); 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["cbnvm"].Value = "1"; Response.Cookies["cbnvm"].Expires = DateTime.UtcNow.AddDays(7); SendCongratulationsEmailToStudent(account.Email, account.FirstName); return(RedirectToAction("Index", "StudentPortal")); } else if (account.ProfileType == "administrator") { string sessionkey = ClientSession.GetClientSessionKey("user", account.Email, account.FirstName + " " + account.LastName, "administrator"); Response.Cookies["sessionkey"].Value = sessionkey; Response.Cookies["sessionkey"].Expires = DateTime.UtcNow.AddDays(7); Response.Cookies["sessionusername"].Value = account.Email; Response.Cookies["sessionusername"].Expires = DateTime.UtcNow.AddDays(7); Response.Cookies["cbnvm"].Value = "1"; Response.Cookies["cbnvm"].Expires = DateTime.UtcNow.AddDays(7); SendCongratulationsEmailToAdmin(account.Email, account.FirstName + " " + account.LastName); return(RedirectToAction("AddSchool", "AdminPortal")); } return(View()); } else { ViewBag.ErrorMessage = "No account found"; } } return(RedirectToAction("LogIn")); }
public void SaveCareerRating(string user, string career, string rating) { StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); if (student != null) { AssessmentCareerClient acc = new AssessmentCareerClient(); AssessmentCareer careerRating = acc.GetByPartitionAndRowKey(student.School, user + student.Year + student.Grade + career); if (careerRating == null) { acc.AddNewItem(new AssessmentCareer { PartitionKey = student.School, RowKey = user + student.Year + student.Grade + career, Value = rating, Counselor = student.Counselor, Student = user, Grade = student.Grade, GroupName = student.GroupName, DolCode = career, Year = student.Year }); //acrc.AddNewItem(new AssessmentCareerRating { PartitionKey = student.School, RowKey = user + career, DolCode = career, Rating = rating, GradYear = student.GradYear, Student = user, Teacher = student.Teacher, Group = student.Group }); if (rating == "1") { student.RatedCareers++; } else { student.DislikeCareers++; } sac.Update(student); } else { if (careerRating.Value != rating) { if (rating == "1") { student.DislikeCareers--; student.RatedCareers++; } else { student.DislikeCareers++; student.RatedCareers--; } sac.Update(student); } careerRating.Value = rating; acc.Update(careerRating); } } //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user); //AssessmentCareerRatingClient acrc = new AssessmentCareerRatingClient(); //AssessmentCareerRating careerRating = acrc.GetByPartitionAndRowKey(student.School, user + career); }
public ActionResult RateInterests() { string user = AuthTokens[1]; StudentAccountClient sac = new StudentAccountClient(); StudentAccount student = sac.GetByPartitionAndRowKey(StudentAccountClient.GetPartitionKeyForEmail(user), user); //StudentProfileClient spc = new StudentProfileClient(); //StudentProfile student = spc.GetByPartitionAndRowKey(StudentProfileClient.GetPartitionKeyForEmail(user), user); ViewBag.School = student.School; ViewBag.Year = student.Year; ViewBag.Grade = student.Grade; ViewBag.importantThings = importantThings; return(View()); }
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")); }