{"action":"created","comment":{"url":"https://api.github.com/repos/frankibem/UniWatch/pulls/comments/89664888","pull_request_review_id":10209072,"id":89664888,"diff_hunk":"@@ -9,75 +9,74 @@\n \n namespace UniWatch.Controllers\n {\n+    [Authorize(Roles = \"Teacher\")]\n     public class ClassController : Controller\n     {\n         private IDataAccess _dataAccess;\n \n-        public ClassController()\n+        public ClassController() : this(new DataAccess.DataAccess())\n         {\n-            _dataAccess = new DataAccess.DataAccess();\n         }\n-         public ClassController(IDataAccess dataAccess)\n+\n+        public ClassController(IDataAccess dataAccess)\n         {\n             _dataAccess = dataAccess;\n         }\n+\n         //GET: Index\n         /// <summary>\n         /// Displays all classes taught by the teacher\n         /// </summary>\n-        /// <param name=\"teacherId\">Id of the teacher</param>\n-        public ActionResult Index(int teacherId)\n+        [OverrideAuthorization]\n+        [Authorize]\n+        public ActionResult Index()\n         {\n-            var teacher = _dataAccess.UserManager.GetTeacherById(teacherId);\n-                if (teacher==null)\n+            // TODO: modify view to show appropriate information for either user type\n+            var user = _dataAccess.UserManager.GetUser();\n+            if(user is Teacher)\n+            {\n+                Teacher teacher = user as Teacher;\n+                return View(_dataAccess.ClassManager.GetClassesForTeacher(teacher.Id));\n+            }\n+            else\n             {\n-                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);\n+                Student student = user as Student;\n+                return View(_dataAccess.ClassManager.GetClassesForStudent(student.Id));\n             }\n-            ViewBag.TeacherId = teacherId;\n-            return View(_dataAccess.ClassManager.GetClassesForTeacher(teacherId));\n         }\n \n-\n         // GET: Create\n         /// <summary>\n-        /// Sends user to the create class page\n+        /// Returns the view to create a new class\n         /// </summary>\n-        /// <param name=\"teacherId\">Id of the teacher</param>\n-        public ActionResult Create(int teacherId)\n+        public ActionResult Create()\n         {\n-            var teacher = _dataAccess.UserManager.GetTeacherById(teacherId);\n-            if (teacher == null)\n-            {\n-                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);\n-            }\n-           // var teacher = _dataAccess.UserManager.GetTeacherById(teacherId);\n-            return View(new Class() { Teacher = teacher });\n+            return View();\n         }\n \n         //POST: Create\n         /// <summary>\n         /// Create class for the teacher\n         /// </summary>\n         /// <param name=\"class\">Model containing information to create the class</param>\n-        /// <param name=\"teacherId\">Id of the teacher</param>\n         [HttpPost]\n         [ValidateAntiForgeryToken]\n-        public ActionResult Create([Bind(Include = \"Name,Number,Section,Semester,Year\")] Class @class, int teacherId)\n+        public ActionResult Create([Bind(Include = \"Name,Number,Section,Semester,Year\")] Class @class)\n         {\n-            if (!ModelState.IsValid)\n+            if(!ModelState.IsValid)\n             {\n                 return View(@class);\n             }\n             try\n             {\n-                var created = _dataAccess.ClassManager.CreateClass(@class.Name, @class.Number, @class.Section, @class.Semester, @class.Year, teacherId);\n+                var teacher = _dataAccess.UserManager.GetUser() as Teacher;\n+                var created = _dataAccess.ClassManager.CreateClass(@class.Name, @class.Number, @class.Section, @class.Semester, @class.Year, teacher.Id);\n                 return RedirectToAction(\"Index\", new { teacherId = created.Teacher.Id });","path":"UniWatch/Controllers/ClassController.cs","position":91,"original_position":91,"commit_id":"1c40d8baab4acbd9581b33fec51dd8e86def1c3b","original_commit_id":"1c40d8baab4acbd9581b33fec51dd8e86def1c3b","user":{"login":"the-pat","id":22896198,"avatar_url":"https://avatars.githubusercontent.com/u/22896198?v=3","gravatar_id":"","url":"https://api.github.com/users/the-pat","html_url":"https://github.com/the-pat","followers_url":"https://api.github.com/users/the-pat/followers","following_url":"https://api.github.com/users/the-pat/following{/other_user}","gists_url":"https://api.github.com/users/the-pat/gists{/gist_id}","starred_url":"https://api.github.com/users/the-pat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-pat/subscriptions","organizations_url":"https://api.github.com/users/the-pat/orgs","repos_url":"https://api.github.com/users/the-pat/repos","events_url":"https://api.github.com/users/the-pat/events{/privacy}","received_events_url":"https://api.github.com/users/the-pat/received_events","type":"User","site_admin":false},"body":"Remove the `routeValues` object from `RedirectToAction`.","created_at":"2016-11-26T03:46:14Z","updated_at":"2016-11-26T04:01:31Z","html_url":"https://github.com/frankibem/UniWatch/pull/12#discussion_r89664888","pull_request_url":"https://api.github.com/repos/frankibem/UniWatch/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/comments/89664888"},"html":{"href":"https://github.com/frankibem/UniWatch/pull/12#discussion_r89664888"},"pull_request":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/frankibem/UniWatch/pulls/12","id":95359032,"html_url":"https://github.com/frankibem/UniWatch/pull/12","diff_url":"https://github.com/frankibem/UniWatch/pull/12.diff","patch_url":"https://github.com/frankibem/UniWatch/pull/12.patch","issue_url":"https://api.github.com/repos/frankibem/UniWatch/issues/12","number":12,"state":"open","locked":false,"title":"Authorization","user":{"login":"frankibem","id":7945507,"avatar_url":"https://avatars.githubusercontent.com/u/7945507?v=3","gravatar_id":"","url":"https://api.github.com/users/frankibem","html_url":"https://github.com/frankibem","followers_url":"https://api.github.com/users/frankibem/followers","following_url":"https://api.github.com/users/frankibem/following{/other_user}","gists_url":"https://api.github.com/users/frankibem/gists{/gist_id}","starred_url":"https://api.github.com/users/frankibem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankibem/subscriptions","organizations_url":"https://api.github.com/users/frankibem/orgs","repos_url":"https://api.github.com/users/frankibem/repos","events_url":"https://api.github.com/users/frankibem/events{/privacy}","received_events_url":"https://api.github.com/users/frankibem/received_events","type":"User","site_admin":false},"body":"Login and registration are verified to be working. Pages now require authorization based on user type and has been tested to work. For now, user is redirected to login page when they try to do something outside their role (will update in future if time and found to be important)\r\n\r\nRemark: Views are yet to be updated to show information relevant to students e.g. Class/index, Lecture/index","created_at":"2016-11-26T02:57:43Z","updated_at":"2016-11-26T04:01:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0ba6f9960ac8909179bdafb576931260ecda36f","assignee":{"login":"the-pat","id":22896198,"avatar_url":"https://avatars.githubusercontent.com/u/22896198?v=3","gravatar_id":"","url":"https://api.github.com/users/the-pat","html_url":"https://github.com/the-pat","followers_url":"https://api.github.com/users/the-pat/followers","following_url":"https://api.github.com/users/the-pat/following{/other_user}","gists_url":"https://api.github.com/users/the-pat/gists{/gist_id}","starred_url":"https://api.github.com/users/the-pat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-pat/subscriptions","organizations_url":"https://api.github.com/users/the-pat/orgs","repos_url":"https://api.github.com/users/the-pat/repos","events_url":"https://api.github.com/users/the-pat/events{/privacy}","received_events_url":"https://api.github.com/users/the-pat/received_events","type":"User","site_admin":false},"assignees":[{"login":"the-pat","id":22896198,"avatar_url":"https://avatars.githubusercontent.com/u/22896198?v=3","gravatar_id":"","url":"https://api.github.com/users/the-pat","html_url":"https://github.com/the-pat","followers_url":"https://api.github.com/users/the-pat/followers","following_url":"https://api.github.com/users/the-pat/following{/other_user}","gists_url":"https://api.github.com/users/the-pat/gists{/gist_id}","starred_url":"https://api.github.com/users/the-pat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-pat/subscriptions","organizations_url":"https://api.github.com/users/the-pat/orgs","repos_url":"https://api.github.com/users/the-pat/repos","events_url":"https://api.github.com/users/the-pat/events{/privacy}","received_events_url":"https://api.github.com/users/the-pat/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/frankibem/UniWatch/pulls/12/commits","review_comments_url":"https://api.github.com/repos/frankibem/UniWatch/pulls/12/comments","review_comment_url":"https://api.github.com/repos/frankibem/UniWatch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/frankibem/UniWatch/issues/12/comments","statuses_url":"https://api.github.com/repos/frankibem/UniWatch/statuses/1c40d8baab4acbd9581b33fec51dd8e86def1c3b","head":{"label":"frankibem:authorization","ref":"authorization","sha":"1c40d8baab4acbd9581b33fec51dd8e86def1c3b","user":{"login":"frankibem","id":7945507,"avatar_url":"https://avatars.githubusercontent.com/u/7945507?v=3","gravatar_id":"","url":"https://api.github.com/users/frankibem","html_url":"https://github.com/frankibem","followers_url":"https://api.github.com/users/frankibem/followers","following_url":"https://api.github.com/users/frankibem/following{/other_user}","gists_url":"https://api.github.com/users/frankibem/gists{/gist_id}","starred_url":"https://api.github.com/users/frankibem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankibem/subscriptions","organizations_url":"https://api.github.com/users/frankibem/orgs","repos_url":"https://api.github.com/users/frankibem/repos","events_url":"https://api.github.com/users/frankibem/events{/privacy}","received_events_url":"https://api.github.com/users/frankibem/received_events","type":"User","site_admin":false},"repo":{"id":72463667,"name":"UniWatch","full_name":"frankibem/UniWatch","owner":{"login":"frankibem","id":7945507,"avatar_url":"https://avatars.githubusercontent.com/u/7945507?v=3","gravatar_id":"","url":"https://api.github.com/users/frankibem","html_url":"https://github.com/frankibem","followers_url":"https://api.github.com/users/frankibem/followers","following_url":"https://api.github.com/users/frankibem/following{/other_user}","gists_url":"https://api.github.com/users/frankibem/gists{/gist_id}","starred_url":"https://api.github.com/users/frankibem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankibem/subscriptions","organizations_url":"https://api.github.com/users/frankibem/orgs","repos_url":"https://api.github.com/users/frankibem/repos","events_url":"https://api.github.com/users/frankibem/events{/privacy}","received_events_url":"https://api.github.com/users/frankibem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frankibem/UniWatch","description":null,"fork":false,"url":"https://api.github.com/repos/frankibem/UniWatch","forks_url":"https://api.github.com/repos/frankibem/UniWatch/forks","keys_url":"https://api.github.com/repos/frankibem/UniWatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frankibem/UniWatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frankibem/UniWatch/teams","hooks_url":"https://api.github.com/repos/frankibem/UniWatch/hooks","issue_events_url":"https://api.github.com/repos/frankibem/UniWatch/issues/events{/number}","events_url":"https://api.github.com/repos/frankibem/UniWatch/events","assignees_url":"https://api.github.com/repos/frankibem/UniWatch/assignees{/user}","branches_url":"https://api.github.com/repos/frankibem/UniWatch/branches{/branch}","tags_url":"https://api.github.com/repos/frankibem/UniWatch/tags","blobs_url":"https://api.github.com/repos/frankibem/UniWatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frankibem/UniWatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frankibem/UniWatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/frankibem/UniWatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frankibem/UniWatch/statuses/{sha}","languages_url":"https://api.github.com/repos/frankibem/UniWatch/languages","stargazers_url":"https://api.github.com/repos/frankibem/UniWatch/stargazers","contributors_url":"https://api.github.com/repos/frankibem/UniWatch/contributors","subscribers_url":"https://api.github.com/repos/frankibem/UniWatch/subscribers","subscription_url":"https://api.github.com/repos/frankibem/UniWatch/subscription","commits_url":"https://api.github.com/repos/frankibem/UniWatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/frankibem/UniWatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/frankibem/UniWatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/frankibem/UniWatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/frankibem/UniWatch/contents/{+path}","compare_url":"https://api.github.com/repos/frankibem/UniWatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frankibem/UniWatch/merges","archive_url":"https://api.github.com/repos/frankibem/UniWatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frankibem/UniWatch/downloads","issues_url":"https://api.github.com/repos/frankibem/UniWatch/issues{/number}","pulls_url":"https://api.github.com/repos/frankibem/UniWatch/pulls{/number}","milestones_url":"https://api.github.com/repos/frankibem/UniWatch/milestones{/number}","notifications_url":"https://api.github.com/repos/frankibem/UniWatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frankibem/UniWatch/labels{/name}","releases_url":"https://api.github.com/repos/frankibem/UniWatch/releases{/id}","deployments_url":"https://api.github.com/repos/frankibem/UniWatch/deployments","created_at":"2016-10-31T18:00:50Z","updated_at":"2016-11-04T13:54:49Z","pushed_at":"2016-11-26T02:57:43Z","git_url":"git://github.com/frankibem/UniWatch.git","ssh_url":"git@github.com:frankibem/UniWatch.git","clone_url":"https://github.com/frankibem/UniWatch.git","svn_url":"https://github.com/frankibem/UniWatch","homepage":null,"size":1030,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"frankibem:master","ref":"master","sha":"e5b6fd785ebdb1f0e272de9817869652ff983815","user":{"login":"frankibem","id":7945507,"avatar_url":"https://avatars.githubusercontent.com/u/7945507?v=3","gravatar_id":"","url":"https://api.github.com/users/frankibem","html_url":"https://github.com/frankibem","followers_url":"https://api.github.com/users/frankibem/followers","following_url":"https://api.github.com/users/frankibem/following{/other_user}","gists_url":"https://api.github.com/users/frankibem/gists{/gist_id}","starred_url":"https://api.github.com/users/frankibem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankibem/subscriptions","organizations_url":"https://api.github.com/users/frankibem/orgs","repos_url":"https://api.github.com/users/frankibem/repos","events_url":"https://api.github.com/users/frankibem/events{/privacy}","received_events_url":"https://api.github.com/users/frankibem/received_events","type":"User","site_admin":false},"repo":{"id":72463667,"name":"UniWatch","full_name":"frankibem/UniWatch","owner":{"login":"frankibem","id":7945507,"avatar_url":"https://avatars.githubusercontent.com/u/7945507?v=3","gravatar_id":"","url":"https://api.github.com/users/frankibem","html_url":"https://github.com/frankibem","followers_url":"https://api.github.com/users/frankibem/followers","following_url":"https://api.github.com/users/frankibem/following{/other_user}","gists_url":"https://api.github.com/users/frankibem/gists{/gist_id}","starred_url":"https://api.github.com/users/frankibem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankibem/subscriptions","organizations_url":"https://api.github.com/users/frankibem/orgs","repos_url":"https://api.github.com/users/frankibem/repos","events_url":"https://api.github.com/users/frankibem/events{/privacy}","received_events_url":"https://api.github.com/users/frankibem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frankibem/UniWatch","description":null,"fork":false,"url":"https://api.github.com/repos/frankibem/UniWatch","forks_url":"https://api.github.com/repos/frankibem/UniWatch/forks","keys_url":"https://api.github.com/repos/frankibem/UniWatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frankibem/UniWatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frankibem/UniWatch/teams","hooks_url":"https://api.github.com/repos/frankibem/UniWatch/hooks","issue_events_url":"https://api.github.com/repos/frankibem/UniWatch/issues/events{/number}","events_url":"https://api.github.com/repos/frankibem/UniWatch/events","assignees_url":"https://api.github.com/repos/frankibem/UniWatch/assignees{/user}","branches_url":"https://api.github.com/repos/frankibem/UniWatch/branches{/branch}","tags_url":"https://api.github.com/repos/frankibem/UniWatch/tags","blobs_url":"https://api.github.com/repos/frankibem/UniWatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frankibem/UniWatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frankibem/UniWatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/frankibem/UniWatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frankibem/UniWatch/statuses/{sha}","languages_url":"https://api.github.com/repos/frankibem/UniWatch/languages","stargazers_url":"https://api.github.com/repos/frankibem/UniWatch/stargazers","contributors_url":"https://api.github.com/repos/frankibem/UniWatch/contributors","subscribers_url":"https://api.github.com/repos/frankibem/UniWatch/subscribers","subscription_url":"https://api.github.com/repos/frankibem/UniWatch/subscription","commits_url":"https://api.github.com/repos/frankibem/UniWatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/frankibem/UniWatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/frankibem/UniWatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/frankibem/UniWatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/frankibem/UniWatch/contents/{+path}","compare_url":"https://api.github.com/repos/frankibem/UniWatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frankibem/UniWatch/merges","archive_url":"https://api.github.com/repos/frankibem/UniWatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frankibem/UniWatch/downloads","issues_url":"https://api.github.com/repos/frankibem/UniWatch/issues{/number}","pulls_url":"https://api.github.com/repos/frankibem/UniWatch/pulls{/number}","milestones_url":"https://api.github.com/repos/frankibem/UniWatch/milestones{/number}","notifications_url":"https://api.github.com/repos/frankibem/UniWatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frankibem/UniWatch/labels{/name}","releases_url":"https://api.github.com/repos/frankibem/UniWatch/releases{/id}","deployments_url":"https://api.github.com/repos/frankibem/UniWatch/deployments","created_at":"2016-10-31T18:00:50Z","updated_at":"2016-11-04T13:54:49Z","pushed_at":"2016-11-26T02:57:43Z","git_url":"git://github.com/frankibem/UniWatch.git","ssh_url":"git@github.com:frankibem/UniWatch.git","clone_url":"https://github.com/frankibem/UniWatch.git","svn_url":"https://github.com/frankibem/UniWatch","homepage":null,"size":1030,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/12"},"html":{"href":"https://github.com/frankibem/UniWatch/pull/12"},"issue":{"href":"https://api.github.com/repos/frankibem/UniWatch/issues/12"},"comments":{"href":"https://api.github.com/repos/frankibem/UniWatch/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/frankibem/UniWatch/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/frankibem/UniWatch/statuses/1c40d8baab4acbd9581b33fec51dd8e86def1c3b"}}}}
{"actor":{"display_login":"the-pat"}}