{"action":"created","comment":{"url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/comments/26930335","id":26930335,"diff_hunk":"@@ -0,0 +1,151 @@\n+﻿using Microsoft.AspNet.Identity;\n+using System;\n+using System.Collections.Generic;\n+using System.Data.Entity;\n+using System.Linq;\n+using System.Net;\n+using System.Web.Http;\n+using VotingApplication.Data.Context;\n+using VotingApplication.Data.Model;\n+using VotingApplication.Web.Api.Controllers.API_Controllers;\n+using VotingApplication.Web.Api.Models.DBViewModels;\n+\n+namespace VotingApplication.Web.Api.Controllers\n+{\n+    public class DashboardController : WebApiController\n+    {\n+        public DashboardController()\n+        {\n+        }\n+\n+        public DashboardController(IContextFactory contextFactory)\n+            : base(contextFactory)\n+        {\n+        }\n+\n+        [HttpGet]\n+        [Authorize]\n+        public List<DashboardPollResponseModel> Polls()\n+        {\n+            using (IVotingContext context = _contextFactory.CreateContext())\n+            {\n+                string userId = User.Identity.GetUserId();\n+\n+                IEnumerable<DashboardPollResponseModel> userPolls = context\n+                    .Polls\n+                    .Where(p => p.CreatorIdentity == userId)\n+                    .OrderByDescending(p => p.CreatedDate)\n+                    .Select(CreateDashboardResponseFromModel);\n+\n+                return userPolls.ToList();\n+            }\n+        }\n+\n+        private static DashboardPollResponseModel CreateDashboardResponseFromModel(Poll poll)\n+        {\n+            return new DashboardPollResponseModel()\n+            {\n+                UUID = poll.UUID,\n+                ManageId = poll.ManageId,\n+                Name = poll.Name,\n+                Creator = poll.Creator,\n+                CreatedDate = poll.CreatedDate,\n+                ExpiryDate = poll.ExpiryDate\n+            };\n+        }\n+\n+\n+        [HttpPost]\n+        [Authorize]\n+        public CopyPollResponseModel Copy(CopyPollRequestModel pollCopyRequest)\n+        {\n+            if (pollCopyRequest == null)\n+            {\n+                this.ThrowError(HttpStatusCode.BadRequest);\n+            }\n+\n+            if (!ModelState.IsValid)\n+            {\n+                this.ThrowError(HttpStatusCode.BadRequest, ModelState);\n+            }\n+\n+            using (IVotingContext context = _contextFactory.CreateContext())\n+            {\n+                string userId = User.Identity.GetUserId();\n+\n+                Poll pollToCopy = context\n+                    .Polls\n+                    .Include(p => p.Options)\n+                    .SingleOrDefault(p => p.UUID == pollCopyRequest.UUIDToCopy);\n+\n+                if (pollToCopy == null)\n+                {\n+                    this.ThrowError(HttpStatusCode.BadRequest);\n+                }\n+\n+\n+                if (pollToCopy.CreatorIdentity != userId)\n+                {\n+                    this.ThrowError(HttpStatusCode.Forbidden);\n+                }\n+\n+                Poll newPoll = CopyPoll(pollToCopy);\n+\n+                context.Polls.Add(newPoll);\n+                context.SaveChanges();\n+\n+                return new CopyPollResponseModel()\n+                {\n+                    newPollId = newPoll.UUID,\n+                    newManageId = newPoll.ManageId\n+                };\n+            }\n+        }\n+\n+        private static Poll CopyPoll(Poll pollToCopy)\n+        {\n+            return new Poll()\n+            {\n+                UUID = Guid.NewGuid(),\n+                ManageId = Guid.NewGuid(),\n+                Name = \"Copy of \" + pollToCopy.Name,","path":"VotingApplication/VotingApplication.Web/Api/Controllers/DashboardController.cs","position":111,"original_position":111,"commit_id":"1442a5c8789d00e8b6d0034a6550e036ad9457b4","original_commit_id":"3c5d26a92c7d20937618d0e06bdb674996c74310","user":{"login":"JDawes-ScottLogic","id":11292375,"avatar_url":"https://avatars.githubusercontent.com/u/11292375?v=3","gravatar_id":"","url":"https://api.github.com/users/JDawes-ScottLogic","html_url":"https://github.com/JDawes-ScottLogic","followers_url":"https://api.github.com/users/JDawes-ScottLogic/followers","following_url":"https://api.github.com/users/JDawes-ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/JDawes-ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/JDawes-ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDawes-ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/JDawes-ScottLogic/orgs","repos_url":"https://api.github.com/users/JDawes-ScottLogic/repos","events_url":"https://api.github.com/users/JDawes-ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/JDawes-ScottLogic/received_events","type":"User","site_admin":false},"body":"Currently it's not particularly easy to distinguish different polls on the dashboard. The copy would be at the top of the list, but that's the only way to tell them apart. ","created_at":"2015-03-23T11:58:44Z","updated_at":"2015-03-23T11:58:44Z","html_url":"https://github.com/Generic-Voting-Application/voting-application/pull/251#discussion_r26930335","pull_request_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/comments/26930335"},"html":{"href":"https://github.com/Generic-Voting-Application/voting-application/pull/251#discussion_r26930335"},"pull_request":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251","id":31625255,"html_url":"https://github.com/Generic-Voting-Application/voting-application/pull/251","diff_url":"https://github.com/Generic-Voting-Application/voting-application/pull/251.diff","patch_url":"https://github.com/Generic-Voting-Application/voting-application/pull/251.patch","issue_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/251","number":251,"state":"open","locked":false,"title":"Copy-poll work","user":{"login":"JDawes-ScottLogic","id":11292375,"avatar_url":"https://avatars.githubusercontent.com/u/11292375?v=3","gravatar_id":"","url":"https://api.github.com/users/JDawes-ScottLogic","html_url":"https://github.com/JDawes-ScottLogic","followers_url":"https://api.github.com/users/JDawes-ScottLogic/followers","following_url":"https://api.github.com/users/JDawes-ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/JDawes-ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/JDawes-ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDawes-ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/JDawes-ScottLogic/orgs","repos_url":"https://api.github.com/users/JDawes-ScottLogic/repos","events_url":"https://api.github.com/users/JDawes-ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/JDawes-ScottLogic/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-20T15:46:34Z","updated_at":"2015-03-23T11:58:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"35aa72c017cfffca9977d84e4d4647c29ee8a144","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251/commits","review_comments_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251/comments","review_comment_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/251/comments","statuses_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/statuses/1442a5c8789d00e8b6d0034a6550e036ad9457b4","head":{"label":"JDawes-ScottLogic:develop","ref":"develop","sha":"1442a5c8789d00e8b6d0034a6550e036ad9457b4","user":{"login":"JDawes-ScottLogic","id":11292375,"avatar_url":"https://avatars.githubusercontent.com/u/11292375?v=3","gravatar_id":"","url":"https://api.github.com/users/JDawes-ScottLogic","html_url":"https://github.com/JDawes-ScottLogic","followers_url":"https://api.github.com/users/JDawes-ScottLogic/followers","following_url":"https://api.github.com/users/JDawes-ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/JDawes-ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/JDawes-ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDawes-ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/JDawes-ScottLogic/orgs","repos_url":"https://api.github.com/users/JDawes-ScottLogic/repos","events_url":"https://api.github.com/users/JDawes-ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/JDawes-ScottLogic/received_events","type":"User","site_admin":false},"repo":{"id":31594335,"name":"voting-application","full_name":"JDawes-ScottLogic/voting-application","owner":{"login":"JDawes-ScottLogic","id":11292375,"avatar_url":"https://avatars.githubusercontent.com/u/11292375?v=3","gravatar_id":"","url":"https://api.github.com/users/JDawes-ScottLogic","html_url":"https://github.com/JDawes-ScottLogic","followers_url":"https://api.github.com/users/JDawes-ScottLogic/followers","following_url":"https://api.github.com/users/JDawes-ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/JDawes-ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/JDawes-ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDawes-ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/JDawes-ScottLogic/orgs","repos_url":"https://api.github.com/users/JDawes-ScottLogic/repos","events_url":"https://api.github.com/users/JDawes-ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/JDawes-ScottLogic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JDawes-ScottLogic/voting-application","description":"","fork":true,"url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application","forks_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/forks","keys_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/teams","hooks_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/hooks","issue_events_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/issues/events{/number}","events_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/events","assignees_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/assignees{/user}","branches_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/branches{/branch}","tags_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/tags","blobs_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/git/refs{/sha}","trees_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/statuses/{sha}","languages_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/languages","stargazers_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/stargazers","contributors_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/contributors","subscribers_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/subscribers","subscription_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/subscription","commits_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/commits{/sha}","git_commits_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/git/commits{/sha}","comments_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/comments{/number}","issue_comment_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/issues/comments{/number}","contents_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/contents/{+path}","compare_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/merges","archive_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/downloads","issues_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/issues{/number}","pulls_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/pulls{/number}","milestones_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/milestones{/number}","notifications_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/labels{/name}","releases_url":"https://api.github.com/repos/JDawes-ScottLogic/voting-application/releases{/id}","created_at":"2015-03-03T11:09:24Z","updated_at":"2015-03-20T08:02:49Z","pushed_at":"2015-03-23T11:56:04Z","git_url":"git://github.com/JDawes-ScottLogic/voting-application.git","ssh_url":"git@github.com:JDawes-ScottLogic/voting-application.git","clone_url":"https://github.com/JDawes-ScottLogic/voting-application.git","svn_url":"https://github.com/JDawes-ScottLogic/voting-application","homepage":"https://votingapp-dev.azurewebsites.net/","size":18821,"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":"Generic-Voting-Application:develop","ref":"develop","sha":"a00a6edf24d85fbc6e289e54a2d443e1a24c4dcd","user":{"login":"Generic-Voting-Application","id":9653622,"avatar_url":"https://avatars.githubusercontent.com/u/9653622?v=3","gravatar_id":"","url":"https://api.github.com/users/Generic-Voting-Application","html_url":"https://github.com/Generic-Voting-Application","followers_url":"https://api.github.com/users/Generic-Voting-Application/followers","following_url":"https://api.github.com/users/Generic-Voting-Application/following{/other_user}","gists_url":"https://api.github.com/users/Generic-Voting-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/Generic-Voting-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Generic-Voting-Application/subscriptions","organizations_url":"https://api.github.com/users/Generic-Voting-Application/orgs","repos_url":"https://api.github.com/users/Generic-Voting-Application/repos","events_url":"https://api.github.com/users/Generic-Voting-Application/events{/privacy}","received_events_url":"https://api.github.com/users/Generic-Voting-Application/received_events","type":"Organization","site_admin":false},"repo":{"id":25260852,"name":"voting-application","full_name":"Generic-Voting-Application/voting-application","owner":{"login":"Generic-Voting-Application","id":9653622,"avatar_url":"https://avatars.githubusercontent.com/u/9653622?v=3","gravatar_id":"","url":"https://api.github.com/users/Generic-Voting-Application","html_url":"https://github.com/Generic-Voting-Application","followers_url":"https://api.github.com/users/Generic-Voting-Application/followers","following_url":"https://api.github.com/users/Generic-Voting-Application/following{/other_user}","gists_url":"https://api.github.com/users/Generic-Voting-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/Generic-Voting-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Generic-Voting-Application/subscriptions","organizations_url":"https://api.github.com/users/Generic-Voting-Application/orgs","repos_url":"https://api.github.com/users/Generic-Voting-Application/repos","events_url":"https://api.github.com/users/Generic-Voting-Application/events{/privacy}","received_events_url":"https://api.github.com/users/Generic-Voting-Application/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Generic-Voting-Application/voting-application","description":"","fork":false,"url":"https://api.github.com/repos/Generic-Voting-Application/voting-application","forks_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/forks","keys_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/teams","hooks_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/hooks","issue_events_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/events{/number}","events_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/events","assignees_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/assignees{/user}","branches_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/branches{/branch}","tags_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/tags","blobs_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/git/refs{/sha}","trees_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/statuses/{sha}","languages_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/languages","stargazers_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/stargazers","contributors_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/contributors","subscribers_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/subscribers","subscription_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/subscription","commits_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/commits{/sha}","git_commits_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/git/commits{/sha}","comments_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/comments{/number}","issue_comment_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/comments{/number}","contents_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/contents/{+path}","compare_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/merges","archive_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/downloads","issues_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues{/number}","pulls_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls{/number}","milestones_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/milestones{/number}","notifications_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/labels{/name}","releases_url":"https://api.github.com/repos/Generic-Voting-Application/voting-application/releases{/id}","created_at":"2014-10-15T15:26:30Z","updated_at":"2015-03-19T17:09:50Z","pushed_at":"2015-03-23T11:56:05Z","git_url":"git://github.com/Generic-Voting-Application/voting-application.git","ssh_url":"git@github.com:Generic-Voting-Application/voting-application.git","clone_url":"https://github.com/Generic-Voting-Application/voting-application.git","svn_url":"https://github.com/Generic-Voting-Application/voting-application","homepage":"https://votingapp.azurewebsites.net/","size":21079,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251"},"html":{"href":"https://github.com/Generic-Voting-Application/voting-application/pull/251"},"issue":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/251"},"comments":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/Generic-Voting-Application/voting-application/statuses/1442a5c8789d00e8b6d0034a6550e036ad9457b4"}}}}