public void TestGetUser() { SchoolhubDb db = new SchoolhubDb(); User user = new User(); user = db.GetUserByUsernamePassword("Tester", "test"); Assert.AreEqual(1, user.Id); }
public ActionResult Classes(int userId) { SchoolhubDb db = new SchoolhubDb(); ClassHomeModel model = new ClassHomeModel() { Classes = db.GetClassesByStudentId(userId), Schools = db.GetAllSchools() }; return(View(model)); }
public ActionResult AddClass(int userId) { SchoolhubDb db = new SchoolhubDb(); TeacherHomeModel model = new TeacherHomeModel(); User user = new User(); user.Id = userId; model.User = user; model.Schools = db.GetAllSchools(); return(View(model)); }
// GET: Register public JsonResult RegisterUser(User inUser, string password) { SchoolhubDb db = new SchoolhubDb(); User user = inUser; string result = db.AddUser(inUser, password); if (int.TryParse(result, out int x)) { user.Id = int.Parse(result); return(Json(new { message = "", user = user })); } return(Json(new { message = result, user = user })); }
public ActionResult StudentCalendar(int userId) { SchoolhubDb db = new SchoolhubDb(); User user = db.GetUserByUserId(userId); StudentHomeModel thisModel = new StudentHomeModel() { User = user, Events = db.GetEventsByStudentId(user.Id), Classes = db.GetClassesByStudentId(user.Id) }; return(View(thisModel)); }
public JsonResult NewStudentEvent(Event InEvent) { SchoolhubDb db = new SchoolhubDb(); bool result = db.AddStudentEvent(InEvent); if (result == true) { return(Json(new { message = "" })); } else { return(Json(new { message = result })); } }
public JsonResult EnrollStudentInClass(int userId, int ClassId) { SchoolhubDb db = new SchoolhubDb(); bool result = db.EnrollStudentInClass(userId, ClassId); if (result == true) { return(Json(new { message = "" })); } else { return(Json(new { message = result })); } }
public JsonResult AddNewClass(Class inClass) { SchoolhubDb db = new SchoolhubDb(); bool result = db.AddClass(inClass); if (result == true) { return(Json(new { message = "" })); } else { return(Json(new { message = result })); } }
public JsonResult DropStudentClass(int userId, int ClassId) { SchoolhubDb db = new SchoolhubDb(); bool result = db.RemoveStudentFromClass(userId, ClassId); if (result == true) { return(Json(new { message = "" })); } else { return(Json(new { message = result })); } }
public void TestInsertUser() { SchoolhubDb db = new SchoolhubDb(); User user = new User(); string password = "******"; user.Username = "******"; user.FirstName = "Testo"; user.LastName = "Testerson"; user.Email = "*****@*****.**"; user.RoleId = 1; string response = db.AddUser(user, password); Assert.AreEqual("A user with the username Tester2 already exists.", response); }
// GET: TeacherHome // View(model) returns a user with an id, username, etc. public ActionResult TeacherHomeIndex(int userId) { SchoolhubDb db = new SchoolhubDb(); User user = db.GetUserByUserId(userId); TeacherHomeModel model = new TeacherHomeModel { Classes = db.GetClassesByTeacherId(user.Id), Events = new List <Event>(), Schools = new List <SelectItem>(), User = user }; return(View(model)); }
public ActionResult AddStudentEvent(int userId) { SchoolhubDb db = new SchoolhubDb(); User user = db.GetUserByUserId(userId); ClassHomeModel model = new ClassHomeModel() { User = user, Classes = db.GetClassesByStudentId(userId), Schools = db.GetAllSchools(), EventTypes = db.GetAllEventTypes() }; return(View(model)); }
public ActionResult AddEvent(int ClassId, int userId) { SchoolhubDb db = new SchoolhubDb(); User user = db.GetUserByUserId(userId); Class TempClass = new Class { Id = ClassId }; EventHomeModel model = new EventHomeModel { User = user, Class = TempClass, EventTypes = db.GetAllEventTypes(), }; return(View(model)); }
public ActionResult EventHome(int ClassId, int userId) { SchoolhubDb db = new SchoolhubDb(); User user = db.GetUserByUserId(userId); Class TempClass = new Class { Id = ClassId }; EventHomeModel model = new EventHomeModel { User = user, Class = TempClass, Classes = new List <Class>(), Events = db.GetEventsByClassId(TempClass.Id), }; return(View(model)); }
public ActionResult AddDropClass(int userId, int classId = -1) { SchoolhubDb db = new SchoolhubDb(); if (classId > 0) { bool result = db.RemoveStudentFromClass(userId, classId); } User user = db.GetUserByUserId(userId); ClassHomeModel model = new ClassHomeModel() { User = user, Classes = db.GetUnenrolledClassesByStudentId(userId), EnrolledClasses = db.GetClassesByStudentId(userId), Schools = db.GetAllSchools() }; return(View(model)); }
public bool DropClass(int userId, int classId) { SchoolhubDb db = new SchoolhubDb(); return(db.RemoveStudentFromClass(userId, classId)); }
public bool AddClass(int userId, int classId) { SchoolhubDb db = new SchoolhubDb(); return(db.EnrollStudentInClass(userId, classId)); }