public ActionResult SubmitSchool(FormCollection collection) { if (AuthTokens[0] == "demo") { ViewBag.DemoNextStep = NextStep("!"); return(View()); } string admin = AuthTokens[1]; AdminAccountClient aac = new AdminAccountClient(); AdminAccount adminAccount = aac.GetByPartitionAndRowKey("admin", admin); UserAccountClient uac = new UserAccountClient(); UserAccount user = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(admin), admin); string rowkey = Regex.Replace(collection["schoolphone"], @"[^0-9]", ""); string phone = rowkey.Substring(0, 3) + "-" + rowkey.Substring(3, 3) + "-" + rowkey.Substring(6); PendingSchoolClient psc = new PendingSchoolClient(); psc.AddNewItem(new PendingSchool { Admin = admin, SchoolName = collection["schoolname"], Address = collection["schooladdress1"], City = collection["schoolcity"], State = collection["schoolstate"], ZipCode = collection["schoolzip"], OfficialID = collection["schoolid"], PhoneNumber = phone, RowKey = rowkey }); adminAccount.SchoolSelected = true; adminAccount.School = rowkey; adminAccount.RequestStatus = ""; aac.Update(adminAccount); EmailManager emailManager = new EmailManager(); string body = "<div>Admin name: " + user.FirstName + " " + user.LastName + "</div><div>Admin phone number and extension:" + adminAccount.PhoneNumber + " x " + adminAccount.PhoneExtension + "</div><div>Admin Email: " + adminAccount.RowKey + "</div>" + "<div>School name: " + collection["schoolname"] + "</div><div>School address" + collection["schooladdress1"] + " " + collection["schoolcity"] + " " + collection["schoolstate"] + " " + collection["schoolzip"] + "</div>" + "<div>School phone number: " + phone + "</div>"; emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "School request", body); return(RedirectToAction("SchoolSubmitted")); }
public ActionResult Administrator(FormCollection collection) { UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), collection["email"].ToLower()); if (account == null) { 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 = "administrator" }); //AdminProfileClient apc = new AdminProfileClient(); //apc.AddNewItem(new AdminProfile { RowKey = collection["email"].ToLower(), PhoneNumber = collection["phonenumber"] }); AdminAccountClient aac = new AdminAccountClient(); aac.AddNewItem(new AdminAccount { RowKey = collection["email"].ToLower(), PhoneNumber = collection["phonenumber"], PhoneExtension = collection["extension"] }); } else { ViewBag.ErrorMessage = "There is an account already associated with this email. Please log in instead."; return(View()); } SendVerificationEmail(collection["email"].ToLower(), collection["firstname"]); EmailManager emailManager = new EmailManager(); string str = "<p>Full name: " + collection["firstname"] + " " + collection["lastname"] + "</p><p>Email: " + collection["email"] + "</p><p>Phone Number: " + collection["phonenumber"] + "</p><p>" + collection["extension"] + "</p>"; emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "HS Admin", str); return(RedirectToAction("ThankYou")); }
public ActionResult Index(IEnumerable <string> firstname, IEnumerable <string> lastname, IEnumerable <string> email) { if (AuthTokens[0] == "demo") { ViewBag.DemoNextStep = NextStep("!"); return(View()); } if (firstname != null && lastname != null && email != null) { if (firstname.Count() == lastname.Count() && firstname.Count() == email.Count()) { CounselorInviteClient cic = new CounselorInviteClient(); AdminAccountClient aac = new AdminAccountClient(); UserAccountClient uac = new UserAccountClient(); AdminAccount admin = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower()); UserAccount user = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(AuthTokens[1].ToLower()), AuthTokens[1].ToLower()); string school = admin.School; for (var i = 0; i < firstname.Count(); i++) { string emailLower = email.ElementAt(i).ToLower(); string guid = ShortGuidGenerator.NewGuid(); cic.AddNewItem(new CounselorInvite { FirstName = firstname.ElementAt(i), LastName = lastname.ElementAt(i), Email = emailLower, School = school, RowKey = guid }); SendInviteEmail(email.ElementAt(i).ToLower(), firstname.ElementAt(i) + " " + lastname.ElementAt(i), user.FirstName + " " + user.LastName, guid); } return(View()); } } ViewBag.ErrorMessage = "error"; return(View()); }
public HttpResponse ResendEmail(string invite) { string response; if (AuthTokens[0] != "demo") { CounselorInviteClient cic = new CounselorInviteClient(); CounselorInvite inviteEntry = cic.GetByPartitionAndRowKey("invite", invite); if (inviteEntry != null) { UserAccountClient uac = new UserAccountClient(); UserAccount user = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(AuthTokens[1].ToLower()), AuthTokens[1].ToLower()); SendInviteEmail(inviteEntry.Email, inviteEntry.FirstName + " " + inviteEntry.LastName, user.FirstName + " " + user.LastName, inviteEntry.RowKey); response = "{\"result\": \"done\"}"; } else { response = "{\"result\": \"error\"}"; } } else { response = "{\"result\": \"done\"}"; } Response.ContentType = "application/json"; Response.Write(response); Response.End(); return(null); }
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 ActionResult ChangePassword(string oldPassword, string newPassword, string confirmNewPassword) { if (AuthTokens == null) { return(RedirectToAction("LogIn")); } if (AuthTokens[0] == "demo") { ViewBag.Response = "You cannot change password in demo"; return(View()); } string email = AuthTokens[1]; UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(email), email); if (account == null) { return(RedirectToAction("LogIn")); } else if (account.Password == oldPassword && Password.checkPassword(newPassword) && newPassword == confirmNewPassword) { account.Password = newPassword; uac.Update(account); SendPasswordChangeEmail(email); ViewBag.PasswordUpdated = true; } else if (account.Password != oldPassword) { ViewBag.InvalidPassword = true; } return(View()); }
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 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 ResendVerificationEmail(string id) { if (id == null) { return(RedirectToAction("LogIn")); } UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(id), id); if (account != null) { if (account.EmailConfirmed == false) { SendVerificationEmail(id, account.FirstName); TempData["Done"] = true; return(RedirectToAction("LogIn")); } } return(RedirectToAction("LogIn")); }
public ActionResult ResetPassword(string email) { if (email.ToLower() == "*****@*****.**") { return(View()); } UserAccountClient uac = new UserAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(email), email); if (account != null) { string password = Password.TempPassword(); account.Password = password; uac.Update(account); SendResetPasswordEmail(email, password, account.FirstName); TempData["Reset"] = true; return(RedirectToAction("LogIn")); } ViewBag.Response = "Account not found"; return(View()); }
public ActionResult ChangeRole(string counselor) { if (AuthTokens[0] == "demo") { return(RedirectToAction("Index", "AdminPortal"));; } string currentAdminEmail = AuthTokens[1]; AdminAccountClient aac = new AdminAccountClient(); CounselorAccountClient cac = new CounselorAccountClient(); UserAccountClient uac = new UserAccountClient(); SchoolAccountClient sac = new SchoolAccountClient(); AdminAccount admin = aac.GetByPartitionAndRowKey("admin", currentAdminEmail); CounselorAccount counselorAccount = cac.GetByPartitionAndRowKey("counselor", counselor); UserAccount currentAdmin = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(currentAdminEmail), currentAdminEmail); UserAccount newAdmin = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(counselor), counselor); SchoolAccount school = sac.GetByPartitionAndRowKey("school", admin.School); if (admin != null && counselorAccount != null && currentAdmin != null && newAdmin != null && school != null) { aac.AddNewItem(new AdminAccount { RowKey = counselor, PhoneNumber = counselorAccount.PhoneNumber, PhoneExtension = counselorAccount.PhoneExtension, School = school.RowKey, SchoolSelected = true, ConnectionToSchoolConfirmed = true }); cac.AddNewItem(new CounselorAccount { RowKey = currentAdminEmail, PhoneNumber = admin.PhoneNumber, PhoneExtension = admin.PhoneExtension, School = school.RowKey }); currentAdmin.ProfileType = "counselor"; uac.Update(currentAdmin); newAdmin.ProfileType = "administrator"; uac.Update(newAdmin); school.Admin = counselor; sac.Update(school); aac.Delete(admin); cac.Delete(counselorAccount); } return(RedirectToAction("LogOut", "Account")); }
public ActionResult Counselor(FormCollection collection) { string adminEmail = ""; UserAccountClient uac = new UserAccountClient(); CounselorInviteClient cic = new CounselorInviteClient(); SchoolAccountClient sac = new SchoolAccountClient(); UserAccount account = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), collection["email"].ToLower()); CounselorInvite invite = cic.GetByPartitionAndRowKey("invite", collection["invite"]); SchoolAccount school = sac.GetByPartitionAndRowKey("school", collection["school"]); if (invite != null) { if (invite.Email == collection["email"].ToLower()) { if (account == null) { 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 = "counselor", EmailConfirmed = true }); CounselorAccountClient сac = new CounselorAccountClient(); AdminAccountClient aac = new AdminAccountClient(); AdminAccount admin = aac.GetBySchool(collection["school"]); if (admin != null) { adminEmail = admin.RowKey; } сac.AddNewItem(new CounselorAccount { RowKey = collection["email"].ToLower(), PhoneNumber = collection["phonenumber"], PhoneExtension = collection["extension"], School = collection["school"] }); cic.Delete(invite); } else { ViewBag.Invite = invite; ViewBag.ErrorMessage = "There is an account already associated with this email. Please log in instead."; return(View()); } } else { ViewBag.Invite = invite; ViewBag.EmailMatch = "Email has to match"; return(View()); } } else { return(RedirectToAction("Index", "Home")); } string sessionkey = ClientSession.GetClientSessionKey("user", collection["email"].ToLower(), collection["firstname"] + " " + collection["lastname"], "counselor"); Response.Cookies["sessionkey"].Value = sessionkey; Response.Cookies["sessionkey"].Expires = DateTime.UtcNow.AddDays(7); Response.Cookies["sessionusername"].Value = collection["email"].ToLower(); Response.Cookies["sessionusername"].Expires = DateTime.UtcNow.AddDays(7); Response.Cookies["cbnvm"].Value = "1"; Response.Cookies["cbnvm"].Expires = DateTime.UtcNow.AddDays(7); SendCongratulationsEmailToCounselor(collection["email"], collection["firstname"] + " " + collection["lastname"]); SendUpdateEmailToAdmin(adminEmail, collection["firstname"] + " " + collection["lastname"]); EmailManager emailManager = new EmailManager(); string schooStr = ""; if (school != null) { schooStr = "<p>School name: " + school.SchoolName + "</p>"; } string str = "<p>Full name: " + collection["firstname"] + " " + collection["lastname"] + "</p><p>Email: " + collection["email"] + "</p><p>Phone Number: " + collection["phonenumber"] + "</p><p>" + collection["extension"] + "</p>" + schooStr; emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "HS Counselor", str); TempData["counselor"] = true; return(RedirectToAction("Index", "CounselorPortal")); }
public HttpResponse AddSchoolPost(string rowkey) { if (AuthTokens[0] == "demo") { Response.ContentType = "application/json"; Response.Write("{\"result\": \"done\"}"); Response.End(); return(null); } string response = ""; SchoolAccountClient sac = new SchoolAccountClient(); SchoolAccount school = sac.GetByPartitionAndRowKey("school", rowkey); if (school != null) { AdminAccountClient aac = new AdminAccountClient(); AdminAccount admin = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower()); if (school.Admin != null && school.Admin != "") { response = "{\"result\": \"exist\"}"; } else { if (admin.SchoolSelected && !admin.ConnectionToSchoolConfirmed) { response = "{\"result\": \"not confirm\"}"; } else if (admin.ConnectionToSchoolConfirmed) { response = "{\"result\": \"dup\"}"; } else { admin.School = school.RowKey; admin.SchoolSelected = true; aac.Update(admin); UserAccountClient uac = new UserAccountClient(); UserAccount user = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(admin.RowKey), admin.RowKey); EmailManager emailManager = new EmailManager(); string body = "<div>Admin name: " + user.FirstName + " " + user.LastName + "</div><div>Admin phone number and extension:" + admin.PhoneNumber + " x " + admin.PhoneExtension + "</div><div>Admin Email: " + admin.RowKey + "</div>" + "<div>School name: " + school.SchoolName + "</div><div>School address" + school.Address + " " + school.City + " " + school.State + " " + school.ZipCode + "</div>" + "<div>School phone number: " + school.PhoneNumber + "</div>"; emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "Admin request", body); response = "{\"result\": \"done\"}"; } } } else { response = "{\"result\": \"error\"}"; } //if (school != null) //{ // //AdminProfileClient apc = new AdminProfileClient(); // //AdminProfile admin = apc.GetByPartitionAndRowKey("adminProfile", AuthTokens[1].ToLower()); // if (admin != null) // { // TeacherToSchoolConnectionClient ttscc = new TeacherToSchoolConnectionClient(); // TeacherToSchoolConnection connection = ttscc.GetByPartitionAndRowKey(rowkey, admin.RowKey); // SchoolToTeacherConnectionClient sttcc = new SchoolToTeacherConnectionClient(); // SchoolToTeacherConnection s2tconnection = sttcc.GetByPartitionAndRowKey(admin.RowKey, rowkey); // if (connection == null) // { // ttscc.AddNewItem(new TeacherToSchoolConnection { PartitionKey = rowkey, RowKey = admin.RowKey }); // sttcc.AddNewItem(new SchoolToTeacherConnection { PartitionKey = admin.RowKey, RowKey = rowkey }); // response = "{\"result\": \"done\"}"; // } // else // { // response = "{\"result\": \"already exist\"}"; // } // } // else // { // response = "{\"result\": \"fail\"}"; // } //} //else //{ // response = "{\"result\": \"fail\"}"; //} Response.ContentType = "application/json"; Response.Write(response); Response.End(); return(null); }