예제 #1
0
        public ActionResult Index(DateTime date)
        {
            Student s = UserBinding.getStudent(User.Identity.GetUserId());

            UserBinding.RequestPrize(s.StudentID, date);
            return(View());
        }
예제 #2
0
 public ActionResult Index()
 {
     if (Request.IsAuthenticated)
     {
         var            AspNetUser = UserManager.FindById(User.Identity.GetUserId());
         IndexViewModel model      = new IndexViewModel
         {
             userClassroomRole = AspNetUser.ClassroomRole
         };
         if (AspNetUser.ClassroomRole == "Student")
         {
             Student studentUser = UserBinding.getStudent(AspNetUser.Id);
             if (studentUser == null)
             {
                 return(View(new IndexViewModel()));
             }
             model.userfname = studentUser.studentFirst;
             if (studentUser.classID == null)
             {
                 model.userClassrooms = null;
                 return(View(model));
             }
             model.userClassrooms = new List <Classroom>();
             model.userClassrooms.Add(ClassroomBinding.GetClassroomFromID(studentUser.classID));
         }
         else if (AspNetUser.ClassroomRole == "Parent")
         {
             Parent parentUser = UserBinding.getParent(AspNetUser.Id);
             model.userfname = parentUser.parentFirst;
         }
         else if (AspNetUser.ClassroomRole == "Teacher")
         {
             Teacher teacherUser = UserBinding.getTeacher(AspNetUser.Id);
             if (teacherUser == null)
             {
                 //TODO add log?
                 return(View(new IndexViewModel()));
             }
             model.userfname      = teacherUser.teacherFirst;
             model.userlname      = teacherUser.teacherLast;
             model.userClassrooms = UserBinding.getTeacherClassrooms(teacherUser.TeacherID);
         }
         return(View(model));
     }
     return(View());
 }
예제 #3
0
        public ActionResult Add(NewBehaviorViewModel model, FormCollection form)
        {
            if (!ModelState.IsValid || model.DatePerformed == null || model.BehaviorTypePerformedID == null)
            {
                return(RedirectToAction("Home", "Index"));
            }
            Student student = UserBinding.getStudent(model.StudentUserID);

            if (student.classID == null)
            {
                return(RedirectToAction("Home", "Index"));
            }

            BehaviorType bt = ClassroomBinding.GetBehaviorType((decimal)student.classID, Convert.ToDecimal(model.BehaviorTypePerformedID));

            UserBinding.AddBehaviorToStudent(student, bt, model.DatePerformed);
            return(RedirectToAction("Index", "Classroom", new { classcode = ClassroomBinding.GetClassroomFromID(student.classID).classCode }));
        }
예제 #4
0
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.Error ? "An error has occurred." : "";

            var AspNetUser = UserManager.FindById(User.Identity.GetUserId());
            var model      = new IndexViewModel
            {
                userClassroomRole = AspNetUser.ClassroomRole
            };

            if (AspNetUser.ClassroomRole == "Student")
            {
                Student studentUser = UserBinding.getStudent(AspNetUser.Id);
                if (studentUser == null)
                {
                    studentUser = new Student();
                }
                model.userfname = studentUser.studentFirst;
            }
            else if (AspNetUser.ClassroomRole == "Parent")
            {
                Parent parentUser = UserBinding.getParent(AspNetUser.Id);
                //TODO null check
                model.userfname = parentUser.parentFirst;
            }
            else if (AspNetUser.ClassroomRole == "Teacher")
            {
                Teacher teacherUser = UserBinding.getTeacher(AspNetUser.Id);
                if (teacherUser == null)
                {
                    //TODO add log?
                    return(View(new IndexViewModel()));
                }
                else
                {
                    model.userfname = teacherUser.teacherFirst;
                    model.userlname = teacherUser.teacherLast;
                }
            }
            return(View(model));
        }
예제 #5
0
        public ActionResult Index(string role, string fname, string lname)
        {
            if (role != null)
            {
                if (role == "Student")
                {
                    var student = UserBinding.getStudent(User.Identity.GetUserId());
                    if (student != null)
                    {
                        student.studentFirst = fname;
                        UserBinding.SaveStudent(student);
                    }
                    else
                    {
                        var newstudent = new Student
                        {
                            StudentID       = UserBinding.GenerateStudentId(),
                            studentFirst    = fname,
                            UserID          = User.Identity.GetUserId(),
                            studentUsername = User.Identity.GetUserName()
                        };
                        UserBinding.SaveStudent(newstudent);
                    }
                }
                else if (role == "Teacher")
                {
                    var teacher = UserBinding.getTeacher(User.Identity.GetUserId());
                    if (teacher != null)
                    {
                        teacher.teacherFirst = fname;
                        teacher.teacherLast  = lname;
                        UserBinding.SaveTeacher(teacher);
                    }
                    else
                    {
                        var newteacher = new Teacher
                        {
                            TeacherID       = UserBinding.GenerateTeacherId(),
                            teacherFirst    = fname,
                            teacherLast     = lname,
                            UserID          = User.Identity.GetUserId(),
                            teacherUsername = User.Identity.GetUserName()
                        };
                        UserBinding.SaveTeacher(newteacher);
                    }
                }
                else if (role == "Parent")
                {
                    var parent = new Parent
                    {
                        parentID       = UserBinding.GenerateParentId(),
                        parentFirst    = fname,
                        UserID         = User.Identity.GetUserId(),
                        parentUsername = User.Identity.GetUserName()
                    };
                    UserBinding.SaveParent(parent);
                }
                //get logged in user from browser context
                ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());
                user.ClassroomRole = role;
                UserManager.Update(user);
            }


            var vmodel = new IndexViewModel
            {
                userClassroomRole = role
            };

            return(View(vmodel));
        }