public ActionResult Add(DateTime start, DateTime end, string classcode)
        {
            Teacher t = UserBinding.getTeacher(User.Identity.GetUserId());

            //TODO clean parameters
            if (t == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (ClassroomBinding.GetClassroomFromCode(classcode)?.classID != null)
            {
                ViewBag.ErrorMessage = "Error: please enter a unique class code.";
                return(View());
            }
            var classroom = new Classroom {
                classID       = ClassroomBinding.GenerateClassId(),
                semesterStart = start,
                semesterEnd   = end,
                classCode     = classcode,
                teacherID     = t.TeacherID
            };

            ClassroomBinding.SaveRoom(classroom);
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Add(string studentuserID, string classcode)
        {
            if (classcode == null)
            {
                //error message
                return(RedirectToAction("Classroom", "Index", new { classcode = classcode }));
            }
            Classroom cr = ClassroomBinding.GetClassroomFromCode(classcode);

            if (cr == null)
            {
                //error message
                return(RedirectToAction("Classroom", "Index", new { classcode = classcode }));
            }

            NewBehaviorViewModel model = new NewBehaviorViewModel()
            {
                ClassCode     = classcode,
                StudentUserID = User.Identity.GetUserId()
            };

            model.BehaviorTypes = new List <SelectListItem>();
            List <BehaviorType> bts = cr.BehaviorType.ToList();

            foreach (BehaviorType bt in bts)
            {
                model.BehaviorTypes.Add(new SelectListItem {
                    Text = bt.behaviorTitle, Value = bt.behaviorID.ToString()
                });
            }
            return(View(model));
        }
        public ActionResult Join(string classCode)
        {
            var       user = User.Identity.GetUserId();
            Classroom cr   = ClassroomBinding.GetClassroomFromCode(classCode);

            if (user == null || cr == null || classCode == null)
            {
                ViewBag.ErrorMessage = "Error: There was an issue joining a classroom.";
                return(View());
            }
            UserBinding.JoinClass(user, classCode);
            return(View());
        }
        public ActionResult AddType(AddTypeViewModel type)
        {
            //TODO null check
            var behavior = new BehaviorType
            {
                behaviorID          = BehaviorBinding.GenerateBehaviorId(),
                behaviorTitle       = type.Title,
                behaviorDescription = type.Description,
                pointValue          = type.PointValue,
                classID             = ClassroomBinding.GetClassroomFromCode(type.ClassCode).classID
            };

            BehaviorBinding.SaveBehavior(behavior);
            return(View());
        }
        public ActionResult Index(string classcode)
        {
            Teacher   t  = UserBinding.getTeacher(User.Identity.GetUserId());
            Classroom cr = ClassroomBinding.GetClassroomFromCode(classcode);

            if (cr == null || t == null || classcode == null)
            {
                //TODO add viewbag error?
                return(RedirectToAction("Index", "Home"));
            }
            ClassroomIndexViewModel model = new ClassroomIndexViewModel();

            model.Classroom = cr;
            model.Teacher   = t;
            model.Students  = cr.Student.ToList();

            return(View(model));
        }