{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments/181937234","pull_request_review_id":112641165,"id":181937234,"diff_hunk":"@@ -0,0 +1,79 @@\n+// Copyright (c) Microsoft. All rights reserved.\n+\n+using System.Threading.Tasks;\n+using Microsoft.AspNetCore.Mvc;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Diagnostics;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v2.Exceptions;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v2.Filters;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v2.Models;\n+using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v2.Models.DeviceModelApiModel;\n+\n+namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v2.Controllers\n+{\n+    [Route(Version.PATH + \"/[controller]\"), ExceptionsFilter]\n+    public class DeviceModelsController : Controller\n+    {\n+        private readonly IDeviceModels deviceModelsService;\n+        private readonly ILogger log;\n+\n+        public DeviceModelsController(\n+            IDeviceModels deviceModelsService,\n+            ILogger logger)\n+        {\n+            this.deviceModelsService = deviceModelsService;\n+            this.log = logger;\n+        }\n+\n+        [HttpGet]\n+        public async Task<DeviceModelListApiModel> GetAsync()\n+        {\n+            return DeviceModelListApiModel.FromServiceModel(await this.deviceModelsService.GetListAsync());\n+        }\n+\n+        [HttpGet(\"{id}\")]\n+        public async Task<DeviceModelApiModel> GetAsync(string id)\n+        {\n+            return DeviceModelApiModel.FromServiceModel(await this.deviceModelsService.GetAsync(id));\n+        }\n+\n+        [HttpPost]\n+        public async Task<DeviceModelApiModel> PostAsync(\n+            [FromBody] DeviceModelApiModel deviceModel)\n+        {\n+            deviceModel?.ValidateInputRequest(this.log);\n+\n+            if (deviceModel == null)\n+            {\n+                this.log.Warn(\"No data or invalid data provided\", () => new { deviceModel });\n+                throw new BadRequestException(\"No data or invalid data provided.\");\n+            }\n+\n+            return DeviceModelApiModel.FromServiceModel(\n+                await this.deviceModelsService.InsertAsync(deviceModel.ToServiceModel()));\n+        }\n+\n+        [HttpPut(\"{id}\")]\n+        public async Task<DeviceModelApiModel> PutAsync(\n+            [FromBody] DeviceModelApiModel deviceModel,\n+            string id = \"\")\n+        {\n+            deviceModel?.ValidateInputRequest(this.log);\n+\n+            if (deviceModel == null)","path":"WebService/v2/Controllers/DeviceModelsController.cs","position":63,"original_position":63,"commit_id":"efbf59c255af00862c4d12fb6d68abb6e19e365e","original_commit_id":"efbf59c255af00862c4d12fb6d68abb6e19e365e","user":{"login":"avanikp","id":32693971,"avatar_url":"https://avatars1.githubusercontent.com/u/32693971?v=4","gravatar_id":"","url":"https://api.github.com/users/avanikp","html_url":"https://github.com/avanikp","followers_url":"https://api.github.com/users/avanikp/followers","following_url":"https://api.github.com/users/avanikp/following{/other_user}","gists_url":"https://api.github.com/users/avanikp/gists{/gist_id}","starred_url":"https://api.github.com/users/avanikp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avanikp/subscriptions","organizations_url":"https://api.github.com/users/avanikp/orgs","repos_url":"https://api.github.com/users/avanikp/repos","events_url":"https://api.github.com/users/avanikp/events{/privacy}","received_events_url":"https://api.github.com/users/avanikp/received_events","type":"User","site_admin":false},"body":"same here, put null check before input validation","created_at":"2018-04-17T02:28:43Z","updated_at":"2018-04-17T02:36:45Z","html_url":"https://github.com/Azure/device-simulation-dotnet/pull/199#discussion_r181937234","pull_request_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments/181937234"},"html":{"href":"https://github.com/Azure/device-simulation-dotnet/pull/199#discussion_r181937234"},"pull_request":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199","id":181547113,"html_url":"https://github.com/Azure/device-simulation-dotnet/pull/199","diff_url":"https://github.com/Azure/device-simulation-dotnet/pull/199.diff","patch_url":"https://github.com/Azure/device-simulation-dotnet/pull/199.patch","issue_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/199","number":199,"state":"open","locked":false,"title":"Custom device model management","user":{"login":"maple10001","id":8744187,"avatar_url":"https://avatars0.githubusercontent.com/u/8744187?v=4","gravatar_id":"","url":"https://api.github.com/users/maple10001","html_url":"https://github.com/maple10001","followers_url":"https://api.github.com/users/maple10001/followers","following_url":"https://api.github.com/users/maple10001/following{/other_user}","gists_url":"https://api.github.com/users/maple10001/gists{/gist_id}","starred_url":"https://api.github.com/users/maple10001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maple10001/subscriptions","organizations_url":"https://api.github.com/users/maple10001/orgs","repos_url":"https://api.github.com/users/maple10001/repos","events_url":"https://api.github.com/users/maple10001/events{/privacy}","received_events_url":"https://api.github.com/users/maple10001/received_events","type":"User","site_admin":false},"body":"# Description and Motivation <!-- Info & Context so we can review your pull request -->\r\n- Add CRUD methods for custom device models\r\n- Add API version 2\r\n- Save custom device models to storage\r\n\r\n# Change type <!-- [x] in all the boxes that apply -->\r\n\r\n- [ ] Bug fix\r\n- [x] New feature\r\n- [ ] Enhancement\r\n- [ ] Breaking change (breaks backward compatibility)\r\n\r\n**Checklist:**\r\n\r\n- [x] All tests passed\r\n- [ ] The code follows the code style and conventions of this project\r\n- [ ] The change requires a change to the documentation\r\n- [ ] I have updated the documentation accordingly\r\n","created_at":"2018-04-13T17:13:51Z","updated_at":"2018-04-17T02:36:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a16a26a94b66bdaf095b7bc56944e234a468e961","assignee":null,"assignees":[],"requested_reviewers":[{"login":"dluc","id":371009,"avatar_url":"https://avatars2.githubusercontent.com/u/371009?v=4","gravatar_id":"","url":"https://api.github.com/users/dluc","html_url":"https://github.com/dluc","followers_url":"https://api.github.com/users/dluc/followers","following_url":"https://api.github.com/users/dluc/following{/other_user}","gists_url":"https://api.github.com/users/dluc/gists{/gist_id}","starred_url":"https://api.github.com/users/dluc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dluc/subscriptions","organizations_url":"https://api.github.com/users/dluc/orgs","repos_url":"https://api.github.com/users/dluc/repos","events_url":"https://api.github.com/users/dluc/events{/privacy}","received_events_url":"https://api.github.com/users/dluc/received_events","type":"User","site_admin":false},{"login":"timlaverty","id":5084013,"avatar_url":"https://avatars2.githubusercontent.com/u/5084013?v=4","gravatar_id":"","url":"https://api.github.com/users/timlaverty","html_url":"https://github.com/timlaverty","followers_url":"https://api.github.com/users/timlaverty/followers","following_url":"https://api.github.com/users/timlaverty/following{/other_user}","gists_url":"https://api.github.com/users/timlaverty/gists{/gist_id}","starred_url":"https://api.github.com/users/timlaverty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timlaverty/subscriptions","organizations_url":"https://api.github.com/users/timlaverty/orgs","repos_url":"https://api.github.com/users/timlaverty/repos","events_url":"https://api.github.com/users/timlaverty/events{/privacy}","received_events_url":"https://api.github.com/users/timlaverty/received_events","type":"User","site_admin":false},{"login":"ppathan","id":16170750,"avatar_url":"https://avatars2.githubusercontent.com/u/16170750?v=4","gravatar_id":"","url":"https://api.github.com/users/ppathan","html_url":"https://github.com/ppathan","followers_url":"https://api.github.com/users/ppathan/followers","following_url":"https://api.github.com/users/ppathan/following{/other_user}","gists_url":"https://api.github.com/users/ppathan/gists{/gist_id}","starred_url":"https://api.github.com/users/ppathan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppathan/subscriptions","organizations_url":"https://api.github.com/users/ppathan/orgs","repos_url":"https://api.github.com/users/ppathan/repos","events_url":"https://api.github.com/users/ppathan/events{/privacy}","received_events_url":"https://api.github.com/users/ppathan/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199/commits","review_comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199/comments","review_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/199/comments","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/efbf59c255af00862c4d12fb6d68abb6e19e365e","head":{"label":"Azure:device-model-management","ref":"device-model-management","sha":"efbf59c255af00862c4d12fb6d68abb6e19e365e","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":89741887,"name":"device-simulation-dotnet","full_name":"Azure/device-simulation-dotnet","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/device-simulation-dotnet","description":"IoT Simulation service","fork":false,"url":"https://api.github.com/repos/Azure/device-simulation-dotnet","forks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/forks","keys_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/teams","hooks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/events","assignees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/tags","blobs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/languages","stargazers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscription","commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/merges","archive_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/downloads","issues_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/deployments","created_at":"2017-04-28T20:20:08Z","updated_at":"2018-04-17T00:38:51Z","pushed_at":"2018-04-13T22:52:10Z","git_url":"git://github.com/Azure/device-simulation-dotnet.git","ssh_url":"git@github.com:Azure/device-simulation-dotnet.git","clone_url":"https://github.com/Azure/device-simulation-dotnet.git","svn_url":"https://github.com/Azure/device-simulation-dotnet","homepage":"","size":975,"stargazers_count":15,"watchers_count":15,"language":"C#","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":64,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":64,"watchers":15,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"ea79508aea783b2f05bc9a00535c6613abf2011e","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":89741887,"name":"device-simulation-dotnet","full_name":"Azure/device-simulation-dotnet","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/device-simulation-dotnet","description":"IoT Simulation service","fork":false,"url":"https://api.github.com/repos/Azure/device-simulation-dotnet","forks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/forks","keys_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/teams","hooks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/events","assignees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/tags","blobs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/languages","stargazers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscription","commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/merges","archive_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/downloads","issues_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/deployments","created_at":"2017-04-28T20:20:08Z","updated_at":"2018-04-17T00:38:51Z","pushed_at":"2018-04-13T22:52:10Z","git_url":"git://github.com/Azure/device-simulation-dotnet.git","ssh_url":"git@github.com:Azure/device-simulation-dotnet.git","clone_url":"https://github.com/Azure/device-simulation-dotnet.git","svn_url":"https://github.com/Azure/device-simulation-dotnet","homepage":"","size":975,"stargazers_count":15,"watchers_count":15,"language":"C#","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":64,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":64,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199"},"html":{"href":"https://github.com/Azure/device-simulation-dotnet/pull/199"},"issue":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/199"},"comments":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/efbf59c255af00862c4d12fb6d68abb6e19e365e"}},"author_association":"NONE"}}
{"actor":{"display_login":"avanikp"}}