{"action":"created","comment":{"url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/comments/189893529","pull_request_review_id":122157001,"id":189893529,"diff_hunk":"@@ -0,0 +1,95 @@\n+﻿using RefuelService.Core.Messaging;\n+using RefuelService.Core.Models;\n+using RefuelService.Core.Services;\n+using System.Threading.Tasks;\n+using Utf8Json;\n+\n+namespace RefuelService.App.Messaging\n+{\n+    public class RefuelEventHandler : IEventHandlerCallback\n+    {\n+        private readonly IRefuelService _refuelService;\n+\n+        public RefuelEventHandler(IRefuelService refuelService)\n+        {\n+            _refuelService = refuelService;\n+        }\n+\n+        public async Task<bool> HandleEventAsync(EventTypes eventType, string message)\n+        {\n+            switch (eventType)\n+            {\n+                case EventTypes.ShipDocked:\n+                    {\n+                        return await HandleShipDocked(message);\n+                    }\n+                case EventTypes.ShipUndocked:\n+                    {\n+\n+                        return await HandleShipUndocked(message);\n+                    }\n+                case EventTypes.ServiceRequested:\n+                    {\n+                        return await HandleServiceRequested(message);\n+                    }\n+                case EventTypes.Unknown:\n+                    {\n+                        return true;\n+                    }\n+            }\n+\n+            return true;\n+        }\n+\n+        private async Task<bool> HandleShipUndocked(string message)\n+        {\n+\n+            Ship receivedShip = JsonSerializer.Deserialize<Ship>(message);\n+            Ship existingShip = await _refuelService.GetShipAsync(receivedShip.Id);\n+\n+            await _refuelService.DeleteShipAsync(existingShip.Id);\n+            //TODO? use enum to set ship as undocked so we dont have to delete and recreate it all the time?\n+\n+            Task.Run(() => _refuelService.SendShipUndockedAsync(existingShip));\n+            return true;\n+        }\n+\n+        private async Task<bool> HandleShipDocked(string message)\n+        {\n+            //1. Deserialize ship\n+            Ship receivedShip = JsonSerializer.Deserialize<Ship>(message);\n+            //2. Dump ship in db\n+            Ship createdShip = await _refuelService.CreateShipAsync(receivedShip);","path":"RefuelService.App/Messaging/RefuelEventHandler.cs","position":59,"original_position":62,"commit_id":"7fe967bc11793e5b3807196a4845f7f5be66a5ec","original_commit_id":"f1a307e80dc8348efb1d774700877b9d7c5e5c30","user":{"login":"Aplicticus","id":7248024,"avatar_url":"https://avatars3.githubusercontent.com/u/7248024?v=4","gravatar_id":"","url":"https://api.github.com/users/Aplicticus","html_url":"https://github.com/Aplicticus","followers_url":"https://api.github.com/users/Aplicticus/followers","following_url":"https://api.github.com/users/Aplicticus/following{/other_user}","gists_url":"https://api.github.com/users/Aplicticus/gists{/gist_id}","starred_url":"https://api.github.com/users/Aplicticus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aplicticus/subscriptions","organizations_url":"https://api.github.com/users/Aplicticus/orgs","repos_url":"https://api.github.com/users/Aplicticus/repos","events_url":"https://api.github.com/users/Aplicticus/events{/privacy}","received_events_url":"https://api.github.com/users/Aplicticus/received_events","type":"User","site_admin":false},"body":"Use C# default conventions:\r\nFor example: var receivedShip = JsonSerialier.Deserializer(message);","created_at":"2018-05-22T13:09:59Z","updated_at":"2018-05-22T13:49:09Z","html_url":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1#discussion_r189893529","pull_request_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/comments/189893529"},"html":{"href":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1#discussion_r189893529"},"pull_request":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1","id":189187174,"html_url":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1","diff_url":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1.diff","patch_url":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1.patch","issue_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/1","number":1,"state":"open","locked":false,"title":"Feature/refuel service","user":{"login":"DaanTacoSchool","id":29249777,"avatar_url":"https://avatars2.githubusercontent.com/u/29249777?v=4","gravatar_id":"","url":"https://api.github.com/users/DaanTacoSchool","html_url":"https://github.com/DaanTacoSchool","followers_url":"https://api.github.com/users/DaanTacoSchool/followers","following_url":"https://api.github.com/users/DaanTacoSchool/following{/other_user}","gists_url":"https://api.github.com/users/DaanTacoSchool/gists{/gist_id}","starred_url":"https://api.github.com/users/DaanTacoSchool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaanTacoSchool/subscriptions","organizations_url":"https://api.github.com/users/DaanTacoSchool/orgs","repos_url":"https://api.github.com/users/DaanTacoSchool/repos","events_url":"https://api.github.com/users/DaanTacoSchool/events{/privacy}","received_events_url":"https://api.github.com/users/DaanTacoSchool/received_events","type":"User","site_admin":false},"body":"Up and running","created_at":"2018-05-19T13:01:30Z","updated_at":"2018-05-22T13:49:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ba9abfa475dc3935577180e48fe670d00eedbde","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1/commits","review_comments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1/comments","review_comment_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/1/comments","statuses_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/statuses/7fe967bc11793e5b3807196a4845f7f5be66a5ec","head":{"label":"GiethoornInternationalHarbor:feature/refuelService","ref":"feature/refuelService","sha":"7fe967bc11793e5b3807196a4845f7f5be66a5ec","user":{"login":"GiethoornInternationalHarbor","id":38727921,"avatar_url":"https://avatars3.githubusercontent.com/u/38727921?v=4","gravatar_id":"","url":"https://api.github.com/users/GiethoornInternationalHarbor","html_url":"https://github.com/GiethoornInternationalHarbor","followers_url":"https://api.github.com/users/GiethoornInternationalHarbor/followers","following_url":"https://api.github.com/users/GiethoornInternationalHarbor/following{/other_user}","gists_url":"https://api.github.com/users/GiethoornInternationalHarbor/gists{/gist_id}","starred_url":"https://api.github.com/users/GiethoornInternationalHarbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiethoornInternationalHarbor/subscriptions","organizations_url":"https://api.github.com/users/GiethoornInternationalHarbor/orgs","repos_url":"https://api.github.com/users/GiethoornInternationalHarbor/repos","events_url":"https://api.github.com/users/GiethoornInternationalHarbor/events{/privacy}","received_events_url":"https://api.github.com/users/GiethoornInternationalHarbor/received_events","type":"Organization","site_admin":false},"repo":{"id":131711188,"name":"RefuelService","full_name":"GiethoornInternationalHarbor/RefuelService","owner":{"login":"GiethoornInternationalHarbor","id":38727921,"avatar_url":"https://avatars3.githubusercontent.com/u/38727921?v=4","gravatar_id":"","url":"https://api.github.com/users/GiethoornInternationalHarbor","html_url":"https://github.com/GiethoornInternationalHarbor","followers_url":"https://api.github.com/users/GiethoornInternationalHarbor/followers","following_url":"https://api.github.com/users/GiethoornInternationalHarbor/following{/other_user}","gists_url":"https://api.github.com/users/GiethoornInternationalHarbor/gists{/gist_id}","starred_url":"https://api.github.com/users/GiethoornInternationalHarbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiethoornInternationalHarbor/subscriptions","organizations_url":"https://api.github.com/users/GiethoornInternationalHarbor/orgs","repos_url":"https://api.github.com/users/GiethoornInternationalHarbor/repos","events_url":"https://api.github.com/users/GiethoornInternationalHarbor/events{/privacy}","received_events_url":"https://api.github.com/users/GiethoornInternationalHarbor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GiethoornInternationalHarbor/RefuelService","description":null,"fork":false,"url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService","forks_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/forks","keys_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/teams","hooks_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/hooks","issue_events_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/events{/number}","events_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/events","assignees_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/assignees{/user}","branches_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/branches{/branch}","tags_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/tags","blobs_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/refs{/sha}","trees_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/statuses/{sha}","languages_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/languages","stargazers_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/stargazers","contributors_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/contributors","subscribers_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/subscribers","subscription_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/subscription","commits_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/commits{/sha}","git_commits_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/commits{/sha}","comments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/comments{/number}","issue_comment_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/comments{/number}","contents_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/contents/{+path}","compare_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/merges","archive_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/downloads","issues_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues{/number}","pulls_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls{/number}","milestones_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/milestones{/number}","notifications_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/labels{/name}","releases_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/releases{/id}","deployments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/deployments","created_at":"2018-05-01T12:35:26Z","updated_at":"2018-05-01T12:35:29Z","pushed_at":"2018-05-22T13:45:54Z","git_url":"git://github.com/GiethoornInternationalHarbor/RefuelService.git","ssh_url":"git@github.com:GiethoornInternationalHarbor/RefuelService.git","clone_url":"https://github.com/GiethoornInternationalHarbor/RefuelService.git","svn_url":"https://github.com/GiethoornInternationalHarbor/RefuelService","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GiethoornInternationalHarbor:master","ref":"master","sha":"a56da1970b3c4970dcc59c03e759e8a58ff2cd78","user":{"login":"GiethoornInternationalHarbor","id":38727921,"avatar_url":"https://avatars3.githubusercontent.com/u/38727921?v=4","gravatar_id":"","url":"https://api.github.com/users/GiethoornInternationalHarbor","html_url":"https://github.com/GiethoornInternationalHarbor","followers_url":"https://api.github.com/users/GiethoornInternationalHarbor/followers","following_url":"https://api.github.com/users/GiethoornInternationalHarbor/following{/other_user}","gists_url":"https://api.github.com/users/GiethoornInternationalHarbor/gists{/gist_id}","starred_url":"https://api.github.com/users/GiethoornInternationalHarbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiethoornInternationalHarbor/subscriptions","organizations_url":"https://api.github.com/users/GiethoornInternationalHarbor/orgs","repos_url":"https://api.github.com/users/GiethoornInternationalHarbor/repos","events_url":"https://api.github.com/users/GiethoornInternationalHarbor/events{/privacy}","received_events_url":"https://api.github.com/users/GiethoornInternationalHarbor/received_events","type":"Organization","site_admin":false},"repo":{"id":131711188,"name":"RefuelService","full_name":"GiethoornInternationalHarbor/RefuelService","owner":{"login":"GiethoornInternationalHarbor","id":38727921,"avatar_url":"https://avatars3.githubusercontent.com/u/38727921?v=4","gravatar_id":"","url":"https://api.github.com/users/GiethoornInternationalHarbor","html_url":"https://github.com/GiethoornInternationalHarbor","followers_url":"https://api.github.com/users/GiethoornInternationalHarbor/followers","following_url":"https://api.github.com/users/GiethoornInternationalHarbor/following{/other_user}","gists_url":"https://api.github.com/users/GiethoornInternationalHarbor/gists{/gist_id}","starred_url":"https://api.github.com/users/GiethoornInternationalHarbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiethoornInternationalHarbor/subscriptions","organizations_url":"https://api.github.com/users/GiethoornInternationalHarbor/orgs","repos_url":"https://api.github.com/users/GiethoornInternationalHarbor/repos","events_url":"https://api.github.com/users/GiethoornInternationalHarbor/events{/privacy}","received_events_url":"https://api.github.com/users/GiethoornInternationalHarbor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GiethoornInternationalHarbor/RefuelService","description":null,"fork":false,"url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService","forks_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/forks","keys_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/teams","hooks_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/hooks","issue_events_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/events{/number}","events_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/events","assignees_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/assignees{/user}","branches_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/branches{/branch}","tags_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/tags","blobs_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/refs{/sha}","trees_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/statuses/{sha}","languages_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/languages","stargazers_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/stargazers","contributors_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/contributors","subscribers_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/subscribers","subscription_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/subscription","commits_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/commits{/sha}","git_commits_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/git/commits{/sha}","comments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/comments{/number}","issue_comment_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/comments{/number}","contents_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/contents/{+path}","compare_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/merges","archive_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/downloads","issues_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues{/number}","pulls_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls{/number}","milestones_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/milestones{/number}","notifications_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/labels{/name}","releases_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/releases{/id}","deployments_url":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/deployments","created_at":"2018-05-01T12:35:26Z","updated_at":"2018-05-01T12:35:29Z","pushed_at":"2018-05-22T13:45:54Z","git_url":"git://github.com/GiethoornInternationalHarbor/RefuelService.git","ssh_url":"git@github.com:GiethoornInternationalHarbor/RefuelService.git","clone_url":"https://github.com/GiethoornInternationalHarbor/RefuelService.git","svn_url":"https://github.com/GiethoornInternationalHarbor/RefuelService","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1"},"html":{"href":"https://github.com/GiethoornInternationalHarbor/RefuelService/pull/1"},"issue":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/1"},"comments":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/GiethoornInternationalHarbor/RefuelService/statuses/7fe967bc11793e5b3807196a4845f7f5be66a5ec"}},"author_association":"NONE"}}
{"actor":{"display_login":"Aplicticus"}}