public ActionResult Welcome(StudentSignUpView studentSignUp) { if ((UserStatus)TempData["StudentStatus"] == UserStatus.NowAuthenticated) { using (var dbContext = new ceit_gwa_databaseEntities1()) { StudentWelcomeInfo studentWelcomeInfo = new StudentWelcomeInfo(); studentWelcomeInfo.CourseList = dbContext.CeitCourses.ToList().Select(p => new SelectListItem { Value = Convert.ToString(p.CourseId), Text = p.Text }); studentWelcomeInfo.YearLevelList = dbContext.CeitYearLevels.ToList().Select(p => new SelectListItem { Value = Convert.ToString(p.YearLevelId), Text = p.YearLevel }); studentWelcomeInfo.SecurityQuestionList = dbContext.CeitSecurityQuestions.ToList().Select(p => new SelectListItem { Value = Convert.ToString(p.QuestionsId), Text = p.SecurityQuestions }); studentWelcomeInfo.GenderList = new SelectList(Enum.GetValues(typeof(Gender))); return(View("Welcome", studentWelcomeInfo)); } } return(View()); }
public ActionResult Register(StudentSignUpView studentSignUp) { if (ModelState.IsValid) { UserManager userManager = new UserManager(); userManager.AddStudent(studentSignUp); FormsAuthentication.SetAuthCookie(studentSignUp.LoginAccount, false); TempData["StudentStatus"] = UserStatus.NowAuthenticated; return(RedirectToAction("Welcome", "Student", studentSignUp)); } return(View("Register", studentSignUp)); }
//Adding student public void AddStudent(StudentSignUpView user) { using (var db = new ceit_gwa_databaseEntities1()) { string rolefor = "Students"; string newid = Convert.ToString(Guid.NewGuid()); CeitStudent StudentData = new CeitStudent(); StudentData.StudentNumber = user.LoginAccount; StudentData.StudentID = newid; db.CeitStudents.Add(StudentData); CeitUser UserData = new CeitUser(); UserData.StudentAccount = StudentData.StudentID; UserData.LoginAccount = user.LoginAccount; UserData.Password = user.Password; UserData.Roles = GetRoleId(rolefor); UserData.DateUpdated = DateTime.Now; UserData.DateCreated = DateTime.Now; db.CeitUsers.Add(UserData); db.SaveChanges(); } }