protected void Application_Start() { //AreaRegistration.RegisterAllAreas(); //RouteConfig.RegisterRoutes(RouteTable.Routes); RouteTable.Routes.MapMvcAttributeRoutes(); string errorMessage; LecturerManager.AddLecturer(new Lecturer { Name = "Dr. John", Email = "*****@*****.**", Password = "******" }, out errorMessage); LecturerManager.AddLecturer(new Lecturer { Name = "Dr. Peter", Email = "*****@*****.**", Password = "******" }, out errorMessage); LecturerManager.AddLecturer(new Lecturer { Name = "Dr. Sarah", Email = "*****@*****.**", Password = "******" }, out errorMessage); StudentManager.AddStudent(new Student { Name = "Mary", Email = "*****@*****.**", Password = "******", Lecturer_ID = 1 }, out errorMessage); StudentManager.AddStudent(new Student { Name = "Nath", Email = "*****@*****.**", Password = "******", Lecturer_ID = 1 }, out errorMessage); StudentManager.AddStudent(new Student { Name = "Vanessa", Email = "*****@*****.**", Password = "******", Lecturer_ID = 2 }, out errorMessage); StudentManager.AddStudent(new Student { Name = "Andre", Email = "*****@*****.**", Password = "******", Lecturer_ID = 2 }, out errorMessage); StudentManager.AddStudent(new Student { Name = "Bernard", Email = "*****@*****.**", Password = "******", Lecturer_ID = 3 }, out errorMessage); //Database.SetInitializer<SchoolContext>(null); }
public static void getLecturerByID() { Lecturer lec = LecturerManager.getLecturerById(2); Assert.IsTrue(lec.Name == "Dr. Peter"); Assert.IsTrue(lec.Email == "*****@*****.**"); }
public static void getLecturerIdList() { int[] test = LecturerManager.AllLecturerIds(); Assert.NotNull(test); Assert.IsTrue(test.Length >= 3); Assert.NotNull(Array.FindIndex(test, x => x == 1)); }
public ActionResult LecturerRegister(Lecturer lec) { string errorMessage; if (!LecturerManager.AddLecturer(lec, out errorMessage)) { ViewBag.Error = errorMessage; return(RedirectToAction("LecturerRegister", new { errorMessage = errorMessage })); } //return RedirectToAction("Dashboard/Lecturer"); return(RedirectToAction("Login", "Login")); }
public static void AddLecturer() { String k = ""; var str = DateTime.Now.ToLongTimeString(); Lecturer lec = new Lecturer(); lec.Email = "*****@*****.**" + str; lec.Name = "lectest"; lec.Password = "******"; bool b = LecturerManager.AddLecturer(lec, out k); var student = LecturerManager.getLecturerById(LecturerManager.GetLecturerIdByEmail("*****@*****.**" + str)); Assert.IsTrue(student.Name == "lectest"); Assert.IsTrue(student.Email == ("*****@*****.**" + str)); Assert.IsTrue(CommonManager.Hash("123456") == student.Password); }
public ActionResult Login(Login login) { string errorMessage = String.Empty; var status = CommonManager.Login(login, out errorMessage); if (!ModelState.IsValid) { return(View()); } else if (status == CommonManager.LoginStatus.Lecturer) { Session["IsStudent"] = false; Session["Email"] = login.Email; Session["TimeOfCreation"] = DateTime.Now; Session["Id"] = LecturerManager.GetLecturerIdByEmail(login.Email); return(RedirectToAction("Manager", "Dashboard")); } else if (status == CommonManager.LoginStatus.Student) { Session["IsStudent"] = true; Session["Email"] = login.Email; Session["TimeOfCreation"] = DateTime.Now; Session["Id"] = StudentManager.GetStudentIdByEmail(login.Email); return(RedirectToAction("Manager", "Dashboard")); } if (errorMessage != "") { ViewBag.Error = errorMessage; } else if (status == CommonManager.LoginStatus.DoesntExist) { ViewBag.Error = "Invalid credentials"; } return(RedirectToAction("Login", new { errorMessage = ViewBag.Error })); }