{"action":"created","comment":{"url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/comments/37391975","id":37391975,"diff_hunk":"@@ -0,0 +1,134 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Web.Mvc;\n+using AutoMapper;\n+using Core.DomainModel;\n+using Core.DomainServices;\n+using Web.Models;\n+\n+namespace Web.Controllers\n+{\n+    [Authorize]\n+    public class StudentController : Controller\n+    {\n+        private readonly IGenericRepository<Student> _studentRepository;\n+        private readonly IUnitOfWork _unitOfWork;\n+\n+        // Hardcoded pagingsize\n+        private const int PageSize = 3;\n+\n+        /* The constructor takes GenericRepositories as argument, which is automatically created by ninject in NinjectWebCommon.\n+         * This enables us to quickly get references to our context, by simply typing, for \n+         * example, \"IGenericRepository<Course> courseRepository\", which we can use right away.\n+         * Whenever a changes is made, use _unitOfWork.Save() to save any changes.\n+         */\n+        public StudentController(IUnitOfWork unitOfWork, IGenericRepository<Student> studentRepository)\n+        {\n+            _studentRepository = studentRepository;\n+            _unitOfWork = unitOfWork;\n+        }\n+\n+        public ActionResult Index()\n+        {\n+            ViewBag.Message = \"Students are here.\";\n+\n+            // We're putting the SelectListItems into a ViewBag, because we do not need to send it back.\n+            // We only send the selectedId back.\n+            ViewBag.StudentIds = _studentRepository.AsQueryable().Select(s =>\n+                new SelectListItem()\n+                {\n+                    Value = s.Id.ToString(),\n+                    Text = s.Id.ToString()\n+                });\n+\n+            // Example of a dropdown menu.\n+            var model = new IndexStudentViewModel()\n+            {\n+                PagedStudents = \n+                    new PagedData<Student>()\n+                    {\n+                        Data = _studentRepository.AsQueryable().OrderBy(p => p.Name).Take(PageSize).ToList(),\n+                        NumberOfPages = PageingsSizeHelper()\n+                    }\n+            };\n+            return View(model);\n+        }\n+\n+        private int PageingsSizeHelper()\n+        {\n+            return Convert.ToInt32(Math.Ceiling((double) _studentRepository.Count()/PageSize));\n+        }\n+\n+        public ActionResult _Students(int page)\n+        {\n+            var model = new IndexStudentViewModel()\n+            {\n+                PagedStudents = new PagedData<Student>()\n+                {\n+                    Data = _studentRepository.AsQueryable().OrderBy(p => p.Name).Skip(PageSize * (page -1)).Take(PageSize).ToList(),","path":"Presentation.Web/Controllers/ExampleStudentController.cs","position":69,"original_position":69,"commit_id":"b554090bdf1541c70dad160f1465572cbe4182fb","original_commit_id":"b554090bdf1541c70dad160f1465572cbe4182fb","user":{"login":"snebjorn","id":1266245,"avatar_url":"https://avatars.githubusercontent.com/u/1266245?v=3","gravatar_id":"","url":"https://api.github.com/users/snebjorn","html_url":"https://github.com/snebjorn","followers_url":"https://api.github.com/users/snebjorn/followers","following_url":"https://api.github.com/users/snebjorn/following{/other_user}","gists_url":"https://api.github.com/users/snebjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/snebjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snebjorn/subscriptions","organizations_url":"https://api.github.com/users/snebjorn/orgs","repos_url":"https://api.github.com/users/snebjorn/repos","events_url":"https://api.github.com/users/snebjorn/events{/privacy}","received_events_url":"https://api.github.com/users/snebjorn/received_events","type":"User","site_admin":false},"body":"Map to view model","created_at":"2015-08-19T08:44:48Z","updated_at":"2015-08-19T08:44:48Z","html_url":"https://github.com/snebjorn/mvc-onion-template/pull/2#discussion_r37391975","pull_request_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/comments/37391975"},"html":{"href":"https://github.com/snebjorn/mvc-onion-template/pull/2#discussion_r37391975"},"pull_request":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2","id":42787082,"html_url":"https://github.com/snebjorn/mvc-onion-template/pull/2","diff_url":"https://github.com/snebjorn/mvc-onion-template/pull/2.diff","patch_url":"https://github.com/snebjorn/mvc-onion-template/pull/2.patch","issue_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/2","number":2,"state":"open","locked":false,"title":"Tests and examples of usage.","user":{"login":"Jeffe747","id":13761283,"avatar_url":"https://avatars.githubusercontent.com/u/13761283?v=3","gravatar_id":"","url":"https://api.github.com/users/Jeffe747","html_url":"https://github.com/Jeffe747","followers_url":"https://api.github.com/users/Jeffe747/followers","following_url":"https://api.github.com/users/Jeffe747/following{/other_user}","gists_url":"https://api.github.com/users/Jeffe747/gists{/gist_id}","starred_url":"https://api.github.com/users/Jeffe747/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jeffe747/subscriptions","organizations_url":"https://api.github.com/users/Jeffe747/orgs","repos_url":"https://api.github.com/users/Jeffe747/repos","events_url":"https://api.github.com/users/Jeffe747/events{/privacy}","received_events_url":"https://api.github.com/users/Jeffe747/received_events","type":"User","site_admin":false},"body":"xUnit.net\r\nnSubstitue\r\nFake DbContext\r\nFaker.net\r\nLogin\r\nDatabase\r\n\r\nDropdownList\r\nPaging","created_at":"2015-08-19T08:10:08Z","updated_at":"2015-08-19T08:44:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e55cea9fa691804cf1e78f2a6dca08da4296c586","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2/commits","review_comments_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2/comments","review_comment_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/2/comments","statuses_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/statuses/b554090bdf1541c70dad160f1465572cbe4182fb","head":{"label":"Jeffe747:UnitTest","ref":"UnitTest","sha":"b554090bdf1541c70dad160f1465572cbe4182fb","user":{"login":"Jeffe747","id":13761283,"avatar_url":"https://avatars.githubusercontent.com/u/13761283?v=3","gravatar_id":"","url":"https://api.github.com/users/Jeffe747","html_url":"https://github.com/Jeffe747","followers_url":"https://api.github.com/users/Jeffe747/followers","following_url":"https://api.github.com/users/Jeffe747/following{/other_user}","gists_url":"https://api.github.com/users/Jeffe747/gists{/gist_id}","starred_url":"https://api.github.com/users/Jeffe747/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jeffe747/subscriptions","organizations_url":"https://api.github.com/users/Jeffe747/orgs","repos_url":"https://api.github.com/users/Jeffe747/repos","events_url":"https://api.github.com/users/Jeffe747/events{/privacy}","received_events_url":"https://api.github.com/users/Jeffe747/received_events","type":"User","site_admin":false},"repo":{"id":40586186,"name":"mvc-onion-template","full_name":"Jeffe747/mvc-onion-template","owner":{"login":"Jeffe747","id":13761283,"avatar_url":"https://avatars.githubusercontent.com/u/13761283?v=3","gravatar_id":"","url":"https://api.github.com/users/Jeffe747","html_url":"https://github.com/Jeffe747","followers_url":"https://api.github.com/users/Jeffe747/followers","following_url":"https://api.github.com/users/Jeffe747/following{/other_user}","gists_url":"https://api.github.com/users/Jeffe747/gists{/gist_id}","starred_url":"https://api.github.com/users/Jeffe747/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jeffe747/subscriptions","organizations_url":"https://api.github.com/users/Jeffe747/orgs","repos_url":"https://api.github.com/users/Jeffe747/repos","events_url":"https://api.github.com/users/Jeffe747/events{/privacy}","received_events_url":"https://api.github.com/users/Jeffe747/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Jeffe747/mvc-onion-template","description":"MVC template using Onion architecture","fork":true,"url":"https://api.github.com/repos/Jeffe747/mvc-onion-template","forks_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/forks","keys_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/teams","hooks_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/hooks","issue_events_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/issues/events{/number}","events_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/events","assignees_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/assignees{/user}","branches_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/branches{/branch}","tags_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/tags","blobs_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/git/refs{/sha}","trees_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/statuses/{sha}","languages_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/languages","stargazers_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/stargazers","contributors_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/contributors","subscribers_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/subscribers","subscription_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/subscription","commits_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/commits{/sha}","git_commits_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/git/commits{/sha}","comments_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/comments{/number}","issue_comment_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/issues/comments{/number}","contents_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/contents/{+path}","compare_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/merges","archive_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/downloads","issues_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/issues{/number}","pulls_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/pulls{/number}","milestones_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/milestones{/number}","notifications_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/labels{/name}","releases_url":"https://api.github.com/repos/Jeffe747/mvc-onion-template/releases{/id}","created_at":"2015-08-12T07:20:14Z","updated_at":"2015-08-12T07:20:15Z","pushed_at":"2015-08-19T08:07:34Z","git_url":"git://github.com/Jeffe747/mvc-onion-template.git","ssh_url":"git@github.com:Jeffe747/mvc-onion-template.git","clone_url":"https://github.com/Jeffe747/mvc-onion-template.git","svn_url":"https://github.com/Jeffe747/mvc-onion-template","homepage":null,"size":18433,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snebjorn:master","ref":"master","sha":"4d4fff7dc46bc1f2b0f33c8d1f0a008a790058a4","user":{"login":"snebjorn","id":1266245,"avatar_url":"https://avatars.githubusercontent.com/u/1266245?v=3","gravatar_id":"","url":"https://api.github.com/users/snebjorn","html_url":"https://github.com/snebjorn","followers_url":"https://api.github.com/users/snebjorn/followers","following_url":"https://api.github.com/users/snebjorn/following{/other_user}","gists_url":"https://api.github.com/users/snebjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/snebjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snebjorn/subscriptions","organizations_url":"https://api.github.com/users/snebjorn/orgs","repos_url":"https://api.github.com/users/snebjorn/repos","events_url":"https://api.github.com/users/snebjorn/events{/privacy}","received_events_url":"https://api.github.com/users/snebjorn/received_events","type":"User","site_admin":false},"repo":{"id":23317147,"name":"mvc-onion-template","full_name":"snebjorn/mvc-onion-template","owner":{"login":"snebjorn","id":1266245,"avatar_url":"https://avatars.githubusercontent.com/u/1266245?v=3","gravatar_id":"","url":"https://api.github.com/users/snebjorn","html_url":"https://github.com/snebjorn","followers_url":"https://api.github.com/users/snebjorn/followers","following_url":"https://api.github.com/users/snebjorn/following{/other_user}","gists_url":"https://api.github.com/users/snebjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/snebjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snebjorn/subscriptions","organizations_url":"https://api.github.com/users/snebjorn/orgs","repos_url":"https://api.github.com/users/snebjorn/repos","events_url":"https://api.github.com/users/snebjorn/events{/privacy}","received_events_url":"https://api.github.com/users/snebjorn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/snebjorn/mvc-onion-template","description":"MVC template using Onion architecture","fork":false,"url":"https://api.github.com/repos/snebjorn/mvc-onion-template","forks_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/forks","keys_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/teams","hooks_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/hooks","issue_events_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/events{/number}","events_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/events","assignees_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/assignees{/user}","branches_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/branches{/branch}","tags_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/tags","blobs_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/git/refs{/sha}","trees_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/statuses/{sha}","languages_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/languages","stargazers_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/stargazers","contributors_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/contributors","subscribers_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/subscribers","subscription_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/subscription","commits_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/commits{/sha}","git_commits_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/git/commits{/sha}","comments_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/comments{/number}","issue_comment_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/comments{/number}","contents_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/contents/{+path}","compare_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/merges","archive_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/downloads","issues_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues{/number}","pulls_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls{/number}","milestones_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/milestones{/number}","notifications_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/labels{/name}","releases_url":"https://api.github.com/repos/snebjorn/mvc-onion-template/releases{/id}","created_at":"2014-08-25T14:47:16Z","updated_at":"2015-02-05T12:21:12Z","pushed_at":"2015-08-19T08:10:09Z","git_url":"git://github.com/snebjorn/mvc-onion-template.git","ssh_url":"git@github.com:snebjorn/mvc-onion-template.git","clone_url":"https://github.com/snebjorn/mvc-onion-template.git","svn_url":"https://github.com/snebjorn/mvc-onion-template","homepage":null,"size":18584,"stargazers_count":1,"watchers_count":1,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2"},"html":{"href":"https://github.com/snebjorn/mvc-onion-template/pull/2"},"issue":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/2"},"comments":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/snebjorn/mvc-onion-template/statuses/b554090bdf1541c70dad160f1465572cbe4182fb"}}}}