{"action":"created","comment":{"url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/comments/38531211","id":38531211,"diff_hunk":"@@ -55,43 +84,95 @@ public ActionResult Create(RestaurantViewModel restaurantViewModel)\n                     tablesInTheRestaurant.Add(new Table(){TableNumber = i+1});\n                 }\n                 restaurant.Tables = tablesInTheRestaurant;\n-                _dataContext.Restaurant.Add(restaurant);\n+                try\n+                {\n+                    _dataContext.Restaurant.Add(restaurant);\n+                }\n+                catch (Exception ex)\n+                {\n+                    _logger.Error(\"Exception occured while inserting data to the Restaurants table. Exception: \" + ex.Message);\n+                    return Content(\"An error occured. Restaurant hasn't been saved.\");\n+                }\n                 return RedirectToAction(\"Index\");\n             }\n             return View(restaurantViewModel);\n \n         }\n \n-        public ActionResult Edit(int? id)\n+        /// <summary>\n+        /// Gets the restaurant spesified by id and sends it to the view\n+        /// </summary>\n+        /// <param name=\"id\">Id of thre restaurant to edit</param>\n+        /// <returns>View and rends restaurant to it</returns>\n+        public ActionResult Edit(int id)\n         {\n-            Restaurant restaurant = _dataContext.Restaurant.Get(id.Value);\n+            Restaurant restaurant;\n+            try\n+            {\n+                restaurant = _dataContext.Restaurant.Get(id);\n+                if (restaurant == null)\n+                {\n+                    return Content(\"Specified Restaurant Id is not valid\");\n+                }\n+            }\n+            catch (Exception ex)\n+            {\n+                _logger.Error(\"The problem occured while connecting to the database. Exception: \" + ex.Message);\n+                return Content(\"Sorry. Restaurant cannot be found.\");\n+            }\n             return View(restaurant);\n         }\n \n+        /// <summary>\n+        /// Updates the restaurant instance with new values if the model state is valid\n+        /// </summary>\n+        /// <param name=\"restaurant\">Restaurant instance posted by user</param>\n+        /// <returns>If the restaurant has beed updated succesfully redirects to Index action. Otherwise, returns the view for editing</returns>\n         [HttpPost]\n         [ValidateAntiForgeryToken]\n         public ActionResult Edit(Restaurant restaurant)\n         {\n             if (ModelState.IsValid)\n             {\n-                _dataContext.Restaurant.Update(restaurant, restaurant.Id);\n+                try\n+                {\n+                    _dataContext.Restaurant.Update(restaurant, restaurant.Id);\n+                }\n+                catch (Exception ex)\n+                {\n+                    _logger.Error(\"Problem occured while updating Restaurant in the database. Exception: \" + ex.Message);\n+                    return Content(\"Sorry. An error occured. Restaurant hasn't been updated.\");\n+                }\n                 return RedirectToAction(\"Index\");\n             }\n             return View(restaurant);\n         }\n \n+        /// <summary>\n+        /// Deletes the restaurant specified by id\n+        /// </summary>\n+        /// <param name=\"id\">If od the restaurant to delete</param>\n+        /// <returns>Redirects to Index action</returns>\n         public ActionResult Delete(int id)\n         {\n-            _dataContext.Restaurant.Delete(id);\n+            try\n+            {\n+                _dataContext.Restaurant.Delete(id);\n+            }\n+            catch (Exception ex)\n+            {\n+                _logger.Error(\"An error occured while deleting restaurant from the database. Exception: \"+ex.Message);\n+                return Content(\"Sorry. Error occured. Can't delete the restaurant.\");\n+            }\n             return RedirectToAction(\"Index\");\n         }\n \n         protected override void Dispose(bool disposing)\n         {\n-            OdeToFoodContext _db = new OdeToFoodContext();\n+            OdeToFoodContext db = new OdeToFoodContext();","path":"OdeToFood/Controllers/RestaurantController.cs","position":177,"original_position":177,"commit_id":"c785a9d85616bafa7472bf12b9aa82a96321d00c","original_commit_id":"c785a9d85616bafa7472bf12b9aa82a96321d00c","user":{"login":"deus42","id":4549545,"avatar_url":"https://avatars.githubusercontent.com/u/4549545?v=3","gravatar_id":"","url":"https://api.github.com/users/deus42","html_url":"https://github.com/deus42","followers_url":"https://api.github.com/users/deus42/followers","following_url":"https://api.github.com/users/deus42/following{/other_user}","gists_url":"https://api.github.com/users/deus42/gists{/gist_id}","starred_url":"https://api.github.com/users/deus42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deus42/subscriptions","organizations_url":"https://api.github.com/users/deus42/orgs","repos_url":"https://api.github.com/users/deus42/repos","events_url":"https://api.github.com/users/deus42/events{/privacy}","received_events_url":"https://api.github.com/users/deus42/received_events","type":"User","site_admin":false},"body":"What is this code for?","created_at":"2015-09-02T13:32:15Z","updated_at":"2015-09-02T13:32:15Z","html_url":"https://github.com/darkleia/OdeToFood/pull/6#discussion_r38531211","pull_request_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/darkleia/OdeToFood/pulls/comments/38531211"},"html":{"href":"https://github.com/darkleia/OdeToFood/pull/6#discussion_r38531211"},"pull_request":{"href":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6","id":43968120,"html_url":"https://github.com/darkleia/OdeToFood/pull/6","diff_url":"https://github.com/darkleia/OdeToFood/pull/6.diff","patch_url":"https://github.com/darkleia/OdeToFood/pull/6.patch","issue_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/6","number":6,"state":"open","locked":false,"title":"Feature/xml comments and logging","user":{"login":"darkleia","id":13795445,"avatar_url":"https://avatars.githubusercontent.com/u/13795445?v=3","gravatar_id":"","url":"https://api.github.com/users/darkleia","html_url":"https://github.com/darkleia","followers_url":"https://api.github.com/users/darkleia/followers","following_url":"https://api.github.com/users/darkleia/following{/other_user}","gists_url":"https://api.github.com/users/darkleia/gists{/gist_id}","starred_url":"https://api.github.com/users/darkleia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkleia/subscriptions","organizations_url":"https://api.github.com/users/darkleia/orgs","repos_url":"https://api.github.com/users/darkleia/repos","events_url":"https://api.github.com/users/darkleia/events{/privacy}","received_events_url":"https://api.github.com/users/darkleia/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-02T08:58:24Z","updated_at":"2015-09-02T13:32:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"254367fae7e991de120e8d1bbfab82f007694ae6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6/commits","review_comments_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6/comments","review_comment_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls/comments{/number}","comments_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/6/comments","statuses_url":"https://api.github.com/repos/darkleia/OdeToFood/statuses/c785a9d85616bafa7472bf12b9aa82a96321d00c","head":{"label":"darkleia:feature/xml_comments_and_logging","ref":"feature/xml_comments_and_logging","sha":"c785a9d85616bafa7472bf12b9aa82a96321d00c","user":{"login":"darkleia","id":13795445,"avatar_url":"https://avatars.githubusercontent.com/u/13795445?v=3","gravatar_id":"","url":"https://api.github.com/users/darkleia","html_url":"https://github.com/darkleia","followers_url":"https://api.github.com/users/darkleia/followers","following_url":"https://api.github.com/users/darkleia/following{/other_user}","gists_url":"https://api.github.com/users/darkleia/gists{/gist_id}","starred_url":"https://api.github.com/users/darkleia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkleia/subscriptions","organizations_url":"https://api.github.com/users/darkleia/orgs","repos_url":"https://api.github.com/users/darkleia/repos","events_url":"https://api.github.com/users/darkleia/events{/privacy}","received_events_url":"https://api.github.com/users/darkleia/received_events","type":"User","site_admin":false},"repo":{"id":40979892,"name":"OdeToFood","full_name":"darkleia/OdeToFood","owner":{"login":"darkleia","id":13795445,"avatar_url":"https://avatars.githubusercontent.com/u/13795445?v=3","gravatar_id":"","url":"https://api.github.com/users/darkleia","html_url":"https://github.com/darkleia","followers_url":"https://api.github.com/users/darkleia/followers","following_url":"https://api.github.com/users/darkleia/following{/other_user}","gists_url":"https://api.github.com/users/darkleia/gists{/gist_id}","starred_url":"https://api.github.com/users/darkleia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkleia/subscriptions","organizations_url":"https://api.github.com/users/darkleia/orgs","repos_url":"https://api.github.com/users/darkleia/repos","events_url":"https://api.github.com/users/darkleia/events{/privacy}","received_events_url":"https://api.github.com/users/darkleia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/darkleia/OdeToFood","description":"","fork":false,"url":"https://api.github.com/repos/darkleia/OdeToFood","forks_url":"https://api.github.com/repos/darkleia/OdeToFood/forks","keys_url":"https://api.github.com/repos/darkleia/OdeToFood/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darkleia/OdeToFood/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darkleia/OdeToFood/teams","hooks_url":"https://api.github.com/repos/darkleia/OdeToFood/hooks","issue_events_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/events{/number}","events_url":"https://api.github.com/repos/darkleia/OdeToFood/events","assignees_url":"https://api.github.com/repos/darkleia/OdeToFood/assignees{/user}","branches_url":"https://api.github.com/repos/darkleia/OdeToFood/branches{/branch}","tags_url":"https://api.github.com/repos/darkleia/OdeToFood/tags","blobs_url":"https://api.github.com/repos/darkleia/OdeToFood/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darkleia/OdeToFood/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darkleia/OdeToFood/git/refs{/sha}","trees_url":"https://api.github.com/repos/darkleia/OdeToFood/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darkleia/OdeToFood/statuses/{sha}","languages_url":"https://api.github.com/repos/darkleia/OdeToFood/languages","stargazers_url":"https://api.github.com/repos/darkleia/OdeToFood/stargazers","contributors_url":"https://api.github.com/repos/darkleia/OdeToFood/contributors","subscribers_url":"https://api.github.com/repos/darkleia/OdeToFood/subscribers","subscription_url":"https://api.github.com/repos/darkleia/OdeToFood/subscription","commits_url":"https://api.github.com/repos/darkleia/OdeToFood/commits{/sha}","git_commits_url":"https://api.github.com/repos/darkleia/OdeToFood/git/commits{/sha}","comments_url":"https://api.github.com/repos/darkleia/OdeToFood/comments{/number}","issue_comment_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/comments{/number}","contents_url":"https://api.github.com/repos/darkleia/OdeToFood/contents/{+path}","compare_url":"https://api.github.com/repos/darkleia/OdeToFood/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darkleia/OdeToFood/merges","archive_url":"https://api.github.com/repos/darkleia/OdeToFood/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darkleia/OdeToFood/downloads","issues_url":"https://api.github.com/repos/darkleia/OdeToFood/issues{/number}","pulls_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls{/number}","milestones_url":"https://api.github.com/repos/darkleia/OdeToFood/milestones{/number}","notifications_url":"https://api.github.com/repos/darkleia/OdeToFood/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darkleia/OdeToFood/labels{/name}","releases_url":"https://api.github.com/repos/darkleia/OdeToFood/releases{/id}","created_at":"2015-08-18T15:25:46Z","updated_at":"2015-08-26T12:14:51Z","pushed_at":"2015-09-02T12:44:19Z","git_url":"git://github.com/darkleia/OdeToFood.git","ssh_url":"git@github.com:darkleia/OdeToFood.git","clone_url":"https://github.com/darkleia/OdeToFood.git","svn_url":"https://github.com/darkleia/OdeToFood","homepage":null,"size":34312,"stargazers_count":1,"watchers_count":1,"language":"C#","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":"darkleia:develop","ref":"develop","sha":"a2376fdf334e16693be73a551e7981a1e4885a67","user":{"login":"darkleia","id":13795445,"avatar_url":"https://avatars.githubusercontent.com/u/13795445?v=3","gravatar_id":"","url":"https://api.github.com/users/darkleia","html_url":"https://github.com/darkleia","followers_url":"https://api.github.com/users/darkleia/followers","following_url":"https://api.github.com/users/darkleia/following{/other_user}","gists_url":"https://api.github.com/users/darkleia/gists{/gist_id}","starred_url":"https://api.github.com/users/darkleia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkleia/subscriptions","organizations_url":"https://api.github.com/users/darkleia/orgs","repos_url":"https://api.github.com/users/darkleia/repos","events_url":"https://api.github.com/users/darkleia/events{/privacy}","received_events_url":"https://api.github.com/users/darkleia/received_events","type":"User","site_admin":false},"repo":{"id":40979892,"name":"OdeToFood","full_name":"darkleia/OdeToFood","owner":{"login":"darkleia","id":13795445,"avatar_url":"https://avatars.githubusercontent.com/u/13795445?v=3","gravatar_id":"","url":"https://api.github.com/users/darkleia","html_url":"https://github.com/darkleia","followers_url":"https://api.github.com/users/darkleia/followers","following_url":"https://api.github.com/users/darkleia/following{/other_user}","gists_url":"https://api.github.com/users/darkleia/gists{/gist_id}","starred_url":"https://api.github.com/users/darkleia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkleia/subscriptions","organizations_url":"https://api.github.com/users/darkleia/orgs","repos_url":"https://api.github.com/users/darkleia/repos","events_url":"https://api.github.com/users/darkleia/events{/privacy}","received_events_url":"https://api.github.com/users/darkleia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/darkleia/OdeToFood","description":"","fork":false,"url":"https://api.github.com/repos/darkleia/OdeToFood","forks_url":"https://api.github.com/repos/darkleia/OdeToFood/forks","keys_url":"https://api.github.com/repos/darkleia/OdeToFood/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darkleia/OdeToFood/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darkleia/OdeToFood/teams","hooks_url":"https://api.github.com/repos/darkleia/OdeToFood/hooks","issue_events_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/events{/number}","events_url":"https://api.github.com/repos/darkleia/OdeToFood/events","assignees_url":"https://api.github.com/repos/darkleia/OdeToFood/assignees{/user}","branches_url":"https://api.github.com/repos/darkleia/OdeToFood/branches{/branch}","tags_url":"https://api.github.com/repos/darkleia/OdeToFood/tags","blobs_url":"https://api.github.com/repos/darkleia/OdeToFood/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darkleia/OdeToFood/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darkleia/OdeToFood/git/refs{/sha}","trees_url":"https://api.github.com/repos/darkleia/OdeToFood/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darkleia/OdeToFood/statuses/{sha}","languages_url":"https://api.github.com/repos/darkleia/OdeToFood/languages","stargazers_url":"https://api.github.com/repos/darkleia/OdeToFood/stargazers","contributors_url":"https://api.github.com/repos/darkleia/OdeToFood/contributors","subscribers_url":"https://api.github.com/repos/darkleia/OdeToFood/subscribers","subscription_url":"https://api.github.com/repos/darkleia/OdeToFood/subscription","commits_url":"https://api.github.com/repos/darkleia/OdeToFood/commits{/sha}","git_commits_url":"https://api.github.com/repos/darkleia/OdeToFood/git/commits{/sha}","comments_url":"https://api.github.com/repos/darkleia/OdeToFood/comments{/number}","issue_comment_url":"https://api.github.com/repos/darkleia/OdeToFood/issues/comments{/number}","contents_url":"https://api.github.com/repos/darkleia/OdeToFood/contents/{+path}","compare_url":"https://api.github.com/repos/darkleia/OdeToFood/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darkleia/OdeToFood/merges","archive_url":"https://api.github.com/repos/darkleia/OdeToFood/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darkleia/OdeToFood/downloads","issues_url":"https://api.github.com/repos/darkleia/OdeToFood/issues{/number}","pulls_url":"https://api.github.com/repos/darkleia/OdeToFood/pulls{/number}","milestones_url":"https://api.github.com/repos/darkleia/OdeToFood/milestones{/number}","notifications_url":"https://api.github.com/repos/darkleia/OdeToFood/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darkleia/OdeToFood/labels{/name}","releases_url":"https://api.github.com/repos/darkleia/OdeToFood/releases{/id}","created_at":"2015-08-18T15:25:46Z","updated_at":"2015-08-26T12:14:51Z","pushed_at":"2015-09-02T12:44:19Z","git_url":"git://github.com/darkleia/OdeToFood.git","ssh_url":"git@github.com:darkleia/OdeToFood.git","clone_url":"https://github.com/darkleia/OdeToFood.git","svn_url":"https://github.com/darkleia/OdeToFood","homepage":null,"size":34312,"stargazers_count":1,"watchers_count":1,"language":"C#","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/darkleia/OdeToFood/pulls/6"},"html":{"href":"https://github.com/darkleia/OdeToFood/pull/6"},"issue":{"href":"https://api.github.com/repos/darkleia/OdeToFood/issues/6"},"comments":{"href":"https://api.github.com/repos/darkleia/OdeToFood/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/darkleia/OdeToFood/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/darkleia/OdeToFood/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/darkleia/OdeToFood/statuses/c785a9d85616bafa7472bf12b9aa82a96321d00c"}}}}