Exemple #1
0
        public void TestGetUser()
        {
            SchoolhubDb db   = new SchoolhubDb();
            User        user = new User();

            user = db.GetUserByUsernamePassword("Tester", "test");
            Assert.AreEqual(1, user.Id);
        }
Exemple #2
0
        public ActionResult Classes(int userId)
        {
            SchoolhubDb db = new SchoolhubDb();

            ClassHomeModel model = new ClassHomeModel()
            {
                Classes = db.GetClassesByStudentId(userId),
                Schools = db.GetAllSchools()
            };

            return(View(model));
        }
Exemple #3
0
        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 }));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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 }));
            }
        }
Exemple #7
0
        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 }));
            }
        }
Exemple #8
0
        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 }));
            }
        }
Exemple #9
0
        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 }));
            }
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        // 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));
        }
Exemple #12
0
        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));
        }
Exemple #15
0
        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));
        }
Exemple #16
0
        public bool DropClass(int userId, int classId)
        {
            SchoolhubDb db = new SchoolhubDb();

            return(db.RemoveStudentFromClass(userId, classId));
        }
Exemple #17
0
        public bool AddClass(int userId, int classId)
        {
            SchoolhubDb db = new SchoolhubDb();

            return(db.EnrollStudentInClass(userId, classId));
        }