diff options
| author | transtrike <transtrike@gmail.com> | 2021-03-28 19:16:15 +0300 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-03-28 19:16:15 +0300 |
| commit | a789a23c3c8ddde8188f2da40402a1803f838f89 (patch) | |
| tree | daff292b6562a7f49cc2900e249a77243b8919e9 | |
| parent | 4f6d554f95afac9c4eb7358596e4a7ce3aeb5a30 (diff) | |
| parent | 15904cb3d2ef9442b682322353c378ab321520e5 (diff) | |
| download | DevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.tar DevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.tar.gz DevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.zip | |
Dev changes merged into ProfilePicLayer branch
24 files changed, 1459 insertions, 4251 deletions
diff --git a/docs/API-Endpoints.md b/docs/API-Endpoints.md new file mode 100644 index 0000000..503bfc4 --- /dev/null +++ b/docs/API-Endpoints.md @@ -0,0 +1,864 @@ +### Contents: +- [/api/User](#apiuser) + - [/Login](#login) + - [/Register](#register) + - [/GetUser](#getuser) + - [/ProfilePicture](#profilepicture) + - [Get User By Id](#get-user-by-id) + - [Update User By Id](#update-user-by-id) + - [Delete User By Id](#delete-user-by-id) +- [/api/Role](#apirole) + - [Create Role](#create-role) + - [Get Role By Id](#get-role-by-id) + - [Update Role By Id](#update-role-by-id) + - [Delete Role By Id](#delete-role-by-id) +- [/api/Feed](#apifeed) + - [/GetPosts](#getposts) + - [/GetUserPosts](#getuserposts) +- [/api/Post](#apipost) + - [Create Post](#create-post) + - [Get Post By Id](#get-post-by-id) + - [Update Post By Id](#update-post-by-id) + - [Delete Post By Id](#delete-post-by-id) +- [/api/Comment](#apicomment) + - [Create Comment](#create-comment) + - [Get Comment By Id](#get-comment-by-id) + - [Update Comment By Id](#update-comment-by-id) + - [Delete Comment By Id](#delete-comment-by-id) +- [/api/Language](#apilanguage) + - [/GetLanguages](#getlanguages) + - [Create Language](#create-language) + - [Get Language By Id](#get-language-by-id) + - [Update Language By Id](#update-language-by-id) + - [Delete Language By Id](#delete-language-by-id) +- [/api/Technology](#apitechnology) + - [/GetTechnologies](#gettechnologies) + - [Create Technology](#create-technology) + - [Get Technology By Id](#get-technology-by-id) + - [Update Technology By Id](#update-technology-by-id) + - [Delete Technology By Id](#delete-technology-by-id) + +*** + +# /api/User + +## /Login + +||| +|---|---| +|Description|Get a JWT for an existing user| +|Type|POST| +|URL structure|`http://localhost:5000/api/User/login`| +|Authentication|None| +|Body|JSON| +|Returns|JSON; The JWT| +||| + +Sample body: +```json +{ + "userName": "string", + "password": "string" +} +``` +Sample response: +```json +{ + "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJJRCI6IjFiMTU2ZTY3LTVhZmItNGZmMi1hYzRmLTY4NjVmZWI5NzFiYiIsIlVzZXJuYW1lIjoieW9yZ3VzIiwicm9sZSI6IlVzZXIiLCJuYmYiOjE2MTIzMzg5NzIsImV4cCI6MTYxMjkwODAwMCwiaWF0IjoxNjEyMzM4OTcyfQ.dneQidggMu9FD7UXBzn5td3phX3OIgp7y4BygHTqq5Un5D67xH1jZTRQpi9Zqcq76mODvUToAo7j4PFdJtIdtg" +} +``` + +## /Register + +||| +|---|---| +|Description|Add an account to the database and get a JWT| +|Type|POST| +|URL structure|`http://localhost:5000/api/User/register`| +|Authentication|None| +|Body|JSON| +|Returns|JSON; The JWT| + +Sample body: +```json +{ + "userName": "string", + "email": "user@example.com", + "firstName": "string", + "lastName": "string", + "password": "string" +} +``` +Sample response: +```json +{ + "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJJRCI6IjFiMTU2ZTY3LTVhZmItNGZmMi1hYzRmLTY4NjVmZWI5NzFiYiIsIlVzZXJuYW1lIjoieW9yZ3VzIiwicm9sZSI6IlVzZXIiLCJuYmYiOjE2MTIzMzg5NzIsImV4cCI6MTYxMjkwODAwMCwiaWF0IjoxNjEyMzM4OTcyfQ.dneQidggMu9FD7UXBzn5td3phX3OIgp7y4BygHTqq5Un5D67xH1jZTRQpi9Zqcq76mODvUToAo7j4PFdJtIdtg" +} +``` + +## /GetUser + +||| +|---|---| +|Description|Get a user via his UserName| +|Type|GET| +|URL structure|`http://localhost:5000/api/User/GetUser?UserName=test`| +|Authentication|None| +|Body|None| +|Returns|JSON; The object of the user| +||| + +Sample response: +```json +{ + "profilePictureURL": "https://avatars.githubusercontent.com/u/75525529?s=60&v=4", + "roles": [ + { + "name": "User" + } + ], + "friends": [ + ], + "languages": [ + { + "id": "cf40034d-75d7-4792-821d-c16220a5b928" + } + ], + "technologies": [ + { + "id": "907421d9-1b60-411b-b780-85e65a004b56" + } + ], + "posts": [ + { + "id": "850d0655-72cb-4477-b69b-35e8645db266" + } + ], + "userName": "test", + "email": "test@bg.com", + "firstName": "Test", + "lastName": "Test" +} +``` + +## /ProfilePicture + +||| +|---|---| +|Description|Update the profile picture of the given User| +|Type|PUT| +|URL structure|`http://localhost:5000/api/User/ProfilePicture?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|Multipart Form| +|Returns|JSON; The link to the uploaded profile picture| +||| + +Sample body: +|Name|Value| +|---|---| +|Picture|`new-profile-picture.png` (this is the actual file)| + +Sample response: +```json +{ + "profilePictureURL": "https://avatars.githubusercontent.com/u/75525529?s=60&v=4" +} +``` + +## Get User By Id + +||| +|---|---| +|Description|Get a user via his Id| +|Type|GET| +|URL structure|`http://localhost:5000/api/User?Id=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|JSON; The object of the user| +||| + +Sample response: +```json +{ + "profilePictureURL": "https://avatars.githubusercontent.com/u/75525529?s=60&v=4", + "roles": [ + { + "name": "User" + } + ], + "friends": [ + ], + "languages": [ + { + "id": "cf40034d-75d7-4792-821d-c16220a5b928" + } + ], + "technologies": [ + { + "id": "907421d9-1b60-411b-b780-85e65a004b56" + } + ], + "posts": [ + { + "id": "850d0655-72cb-4477-b69b-35e8645db266" + } + ], + "userName": "test", + "email": "test@bg.com", + "firstName": "Test", + "lastName": "Test" +} +``` + +## Update User By Id + +||| +|---|---| +|Description|Modify the values in an existing user (account)| +|Type|PUT| +|URL structure|`http://localhost:5000/api/User?Id=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The updated user object| +||| + +Sample body: +```json +{ + "userName": "string", + "email": "user@example.com", + "firstName": "string", + "lastName": "string", + "password": "string", + "friends": [ + { + "userName": "string" + } + ], + "roles": [ + { + "name": "string" + } + ], + "languages": [ + { + "name": "string" + } + ], + "technologies": [ + { + "name": "string" + } + ] +} +``` +Sample response: +```json +{ + "profilePictureURL": "https://avatars.githubusercontent.com/u/75525529?s=60&v=4", + "roles": [ + { + "name": "User" + } + ], + "friends": [], + "languages": [ + { + "id": "33397a3b-46eb-424f-8e19-d88dbf3e953b" + }, + { + "id": "cea85a74-4820-42ff-b64f-61d7e9bfc696" + } + ], + "technologies": [ + { + "id": "907421d9-1b60-411b-b780-85e65a004b56" + } + ], + "posts": [], + "userName": "test", + "email": "test1@bg.com", + "firstName": "Tester", + "lastName": "Tester" +} +``` + +## Delete User By Id + +||| +|---|---| +|Description|Delete an existing user from the database `WARNING: THIS IS IRREVERSIBLE`| +|Type|DELETE| +|URL structure|`http://localhost:5000/api/User?Id=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|Nothing| +||| + +*** + +# /api/Role + +## Create Role + +||| +|---|---| +|Description|Add a new Role to the DataBase| +|Type|POST| +|URL structure|`http://localhost:5000/api/Role`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The result role object, only with the role Id| +||| + +Sample body: +```json +{ + "name": "string" +} +``` +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Get Role By Id + +||| +|---|---| +|Description|Get an existing Role via it's Id| +|Type|GET| +|URL structure|`http://localhost:5000/api/Role?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|JSON; The role object, only with it's name| +||| + +Sample response: +```json +{ + "name": "Test" +} +``` + +## Update Role By Id + +||| +|---|---| +|Description|Modify the values (name) of an existing role| +|Type|PUT| +|URL structure|`http://localhost:5000/api/Role?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|Nothing| +||| + +Sample body: +```json +{ + "name": "string" +} +``` + +## Delete Role By Id + +||| +|---|---| +|Description|Remove an existing Role from the DataBase| +|Type|POST| +|URL structure|`http://localhost:5000/api/Role?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|Nothing| +||| + +*** + +# /api/Feed + +## /GetPosts + +||| +|---|---| +|Description|Get a certain amount of the latest posts of a User's friends| +|Type|POST| +|URL structure|`http://localhost:5000/api/Feed/GetPosts?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; An array with the selected posts| +||| + +Sample body: +```json +{ + "pageNumber": 1, + "firstPageTimeIssued": "2022-01-30T18:43:01.082Z", + "pageSize": 5 +} +``` +Sample response: +```json +{ + "posts": [ + { + "postId": "850d0655-72cb-4477-b69b-35e8645db266", + "creatorFirstName": "test", + "creatorLastName": "Test", + "creatorUsername": "Test", + "message": "A sample post", + "timeCreated": "2021-02-03T10:52:38.271647", + "comments": [], + "fileUrls": [] + } + ] +} +``` + +## /GetUserPosts + +||| +|---|---| +|Description|Get a certain amount of the latest posts from a User| +|Type|POST| +|URL structure|`http://localhost:5000/api/GetUserPosts?UserName=test`| +|Authentication|None| +|Body|JSON| +|Returns|JSON; An array with the selected posts| +||| + +Sample body: +```json +{ + "pageNumber": 1, + "firstPageTimeIssued": "2022-01-30T18:43:01.082Z", + "pageSize": 5 +} +``` +Sample response: +```json +{ + "posts": [ + { + "postId": "850d0655-72cb-4477-b69b-35e8645db266", + "creatorFirstName": "test", + "creatorLastName": "Test", + "creatorUsername": "Test", + "message": "A sample post", + "timeCreated": "2021-02-03T10:52:38.271647", + "comments": [], + "fileUrls": [] + } + ] +} +``` + +*** + +# /api/Post + +## Create Post + +||| +|---|---| +|Description|Add a new Post to the DataBase| +|Type|POST| +|URL structure|`http://localhost:5000/api/Post?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|Multipart Form| +|Returns|JSON; The result Post object, only with the Post Id| +||| + +Sample body: +|Name|Value| +|---|---| +|Message|The message of my post| +|Files|`attachment.txt` (that is the actual file)| +|Files|`attachment2.txt` (that is the actual file)| +|...|| + +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Get Post By Id + +||| +|---|---| +|Description|Get an existing Post from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Post?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|None| +|Body|None| +|Returns|JSON; The result Post object| +||| + +Sample response: +```json +{ + "postId": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "creatorFirstName": "Test", + "creatorLastName": "Test", + "creatorUsername": "test", + "message": "A sample post", + "timeCreated": "2021-02-02T18:29:31.942772", + "comments": [], + "fileUrls": [] +} +``` + +## Update Post By Id + +||| +|---|---| +|Description|Update the values of an existing post| +|Type|PUT| +|URL structure|`http://localhost:5000/api/Post?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|Multipart Form| +|Returns|JSON; The result Post object, only with the Post Id| +||| + +**Note:** When editing a post's files, they all get replaced, you cannot just add new files. After post is edited, it's "timeCreated" get's updated. + +Sample body: +|Name|Value| +|---|---| +|PostId|1cc9773f-8d9a-4bfd-83ca-2099dc787a39| +|NewMessage|The new message of the post| +|Files|`attachment3.txt` (that is the actual file)| +|Files|`attachment4.txt` (that is the actual file)| +|...| + +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Delete Post By Id + +||| +|---|---| +|Description|Remove an existing Post from the DataBase| +|Type|DELETE| +|URL structure|`http://localhost:5000/api/Post?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|None| +||| + +*** + +# /api/Comment + +## Add comment + +||| +|---|---| +|Description|Add a new Comment to an existing Post| +|Type|POST| +|URL structure|`http://localhost:5000/api/Comment?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The result Comment object, only with the Comment Id| +||| + +Sample body: +```json +{ + "postId": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "message": "First comment" +} +``` +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Get Comment By Id + +||| +|---|---| +|Description|Get an existing Comment from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Comment?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|None| +|Body|None| +|Returns|JSON; The result Comment object| +||| + +Sample response: +```json +{ + "commentId": "086d1a23-c977-4cdc-9bdf-dc81992b3a12", + "postId": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "issuerFirstName": "Test", + "issuerLastName": "Test", + "issuerUsername": "test", + "message": "First coment", + "timeCreated": "2021-02-01T13:18:57.434512" +} +``` + +## Update Comment By Id + +||| +|---|---| +|Description|Update the values of an existing comment| +|Type|PUT| +|URL structure|`http://localhost:5000/api/Comment?UserId=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The result Comment object, only with the Comment Id| +||| + +Sample body: +```json +{ + "commentId": "086d1a23-c977-4cdc-9bdf-dc81992b3a12", + "postId": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "newMessage": "string" +} +``` +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Delete Comment By Id + +||| +|---|---| +|Description|Remove an existing Comment from the DataBase| +|Type|DELETE| +|URL structure|`http://localhost:5000/api/Comment?Id=086d1a23-c977-4cdc-9bdf-dc81992b3a12`| +|Authentication|Bearer Token (JWT), [Authorization Type 2](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|None| +||| + +*** + +# /api/Language + +## /GetLanguages + +||| +|---|---| +|Description|Get all available Languages from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Language/GetLanguages`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|JSON; The result Language array object| +||| + +Sample response: +```json +[ + { + "id": "5286821a-1407-4daf-ac3e-49153c2d3f66", + "name": "CSharp" + }, + { + "id": "cea85a74-4820-42ff-b64f-61d7e9bfc696", + "name": "Perl" + }, + { + "id": "6dc1cb1a-1c4f-41af-8b44-86441cb60136", + "name": "Java" + } +] +``` + +## Create Language + +||| +|---|---| +|Description|Add a new Language in the DataBase| +|Type|POST| +|URL structure|`http://localhost:5000/api/Comment`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The result Comment object, only with the Comment Id| +||| + +Sample body: +```json +{ + "name": "Perl" +} +``` +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Get Language By Id + +||| +|---|---| +|Description|Get an existing Language from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Language?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|None| +|Body|None| +|Returns|JSON; The result Language object| +||| + +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "name": "Perl" +} +``` + +## Update Language By Id + +||| +|---|---| +|Description|Update the values of an existing Language| +|Type|PUT| +|URL structure|`http://localhost:5000/api/Language?Id=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|None| +||| + +Sample body: +```json +{ + "name": "string" +} +``` + +## Delete Language By Id + +||| +|---|---| +|Description|Remove an existing Language from the DataBase| +|Type|DELETE| +|URL structure|`http://localhost:5000/api/Language?Id=086d1a23-c977-4cdc-9bdf-dc81992b3a12`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|None| +||| + +*** + +# /api/Technology + +## /GetTechnologies + +||| +|---|---| +|Description|Get all available Technologies from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Language/GetTechnologies`| +|Authentication|Bearer Token (JWT), [Authorization Type 1](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|JSON; The result Technology array object| +||| + +Sample response: +```json +[ + { + "id": "5286821a-1407-4daf-ac3e-49153c2d3f66", + "name": "ASP.NET" + }, + { + "id": "cea85a74-4820-42ff-b64f-61d7e9bfc696", + "name": "Angular" + } +] +``` + +## Create Technology + +||| +|---|---| +|Description|Add a new Technology in the DataBase| +|Type|POST| +|URL structure|`http://localhost:5000/api/Technology`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|JSON; The result Technology object, only with the Technology Id| +||| + +Sample body: +```json +{ + "name": "Angular" +} +``` +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39" +} +``` + +## Get Technology By Id + +||| +|---|---| +|Description|Get an existing Technology from the DataBase| +|Type|GET| +|URL structure|`http://localhost:5000/api/Technology?Id=1cc9773f-8d9a-4bfd-83ca-2099dc787a39`| +|Authentication|None| +|Body|None| +|Returns|JSON; The result Technology object| +||| + +Sample response: +```json +{ + "id": "1cc9773f-8d9a-4bfd-83ca-2099dc787a39", + "name": "Angular" +} +``` + +## Update Technology By Id + +||| +|---|---| +|Description|Update the values of an existing Technology| +|Type|PUT| +|URL structure|`http://localhost:5000/api/Technology?Id=27e203bd-5312-4831-9334-cd3c20e5d672`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|JSON| +|Returns|None| +||| + +Sample body: +```json +{ + "name": "string" +} +``` + +## Delete Technology By Id + +||| +|---|---| +|Description|Remove an existing Technology from the DataBase| +|Type|DELETE| +|URL structure|`http://localhost:5000/api/Technology?Id=086d1a23-c977-4cdc-9bdf-dc81992b3a12`| +|Authentication|Bearer Token (JWT), [Authorization Type 3](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication#token-validation)| +|Body|None| +|Returns|None| +|||
\ No newline at end of file diff --git a/docs/Authentication.md b/docs/Authentication.md new file mode 100644 index 0000000..f9e6525 --- /dev/null +++ b/docs/Authentication.md @@ -0,0 +1,52 @@ +Certain actions with the API require User authentication. In DevHive, all authentication is done with [JSON Web Tokens](https://en.wikipedia.org/wiki/JSON_Web_Token). + +The JWTs must be sent as a [Bearer Token](https://www.oauth.com/oauth2-servers/differences-between-oauth-1-2/bearer-tokens/). + +## Structure of tokens + +The main contents of a User's token are the `UserName`, `ID` and `Roles`. + +Sample token: +``` +eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJJRCI6IjI3ZTIwM2JkLTUzMTItNDgzMS05MzM0LWNkM2MyMGU1ZDY3MiIsIlVzZXJuYW1lIjoidGVzdCIsInJvbGUiOiJVc2VyIiwibmJmIjoxNjEyMzYxOTc1LCJleHAiOjE2MTI5MDgwMDAsImlhdCI6MTYxMjM2MTk3NX0.ZxhDSUsDf9cGig03QpzNgj3dkqbcfAoFXVIfixYGurzhd0l1_IO79UpE_Sb6ZU9hz3IT1XPrlrQ_Kd46L7xcQg +``` +[Decoded](https://jwt.io/): + +- Header +```json +{ + "alg": "HS512", + "typ": "JWT" +} +``` + +- Data +```json +{ + "ID": "27e203bd-5312-4831-9334-cd3c20e5d672", + "Username": "test", + "role": "User", + "nbf": 1612361975, + "exp": 1612908000, + "iat": 1612361975 +} +``` + +- Signature +``` +HMACSHA512( + base64UrlEncode(header) + "." + + base64UrlEncode(payload) +) +``` + +## Token validation + +All token validations are done in the User Service. Depending on the situation, we can differentiate a couple types of authentication: + +||| +|---|---| +|1|Has the role "User" or "Admin"| +|2|Has the role "User" and is the owner/author of the object or has the role "Admin"| +|3|Has the role "Admin"| +|||
\ No newline at end of file diff --git a/docs/File-Structure.md b/docs/File-Structure.md new file mode 100644 index 0000000..4d0341e --- /dev/null +++ b/docs/File-Structure.md @@ -0,0 +1,495 @@ +DevHive has a lot of files and it can be hard to really see the whole structure of everything from a first glance. In this document, all of the important/notable files and folders are represented in a tree structure. + +### Contents: +- [Common](#common) +- [Data](#data) +- [Service](#service) +- [Tests](#tests) +- [Web](#web) +- [Full Overview](#full-overview) + +# Common + +``` +└── DevHive.Common + └── Models + ├── Identity + │ └── TokenModel.cs + └── Misc + ├── IdModel.cs + ├── PasswordModifications.cs + └── Patch.cs +``` + +# Data + +``` +└── DevHive.Data + ├── ConnectionString.json + ├── DevHiveContext.cs + ├── DevHiveContextFactory.cs + ├── Interfaces + | ├── Models + | │ ├── IComment.cs + │ | ├── ILanguage.cs + │ | ├── IModel.cs + │ | ├── IPost.cs + │ | ├── IProfilePicture.cs + │ | ├── IRating.cs + │ | ├── IRole.cs + │ | ├── ITechnology.cs + │ | └── IUser.cs + | └── Repositories + | ├── ICommentRepository.cs + | ├── IFeedRepository.cs + | ├── ILanguageRepository.cs + | ├── IPostRepository.cs + | ├── IRatingRepository.cs + | ├── IRepository.cs + | ├── IRoleRepository.cs + | ├── ITechnologyRepository.cs + | └── IUserRepository.cs + ├── Migrations + ├── Models + │ ├── Comment.cs + │ ├── Language.cs + │ ├── Post.cs + │ ├── ProfilePicture.cs + │ ├── Rating.cs + │ ├── Role.cs + │ ├── Technology.cs + │ └── User.cs + ├── RelationModels + │ ├── RatedPost.cs + │ ├── UserFriend.cs + │ └── UserRate.cs + └── Repositories + ├── BaseRepository.cs + ├── CommentRepository.cs + ├── FeedRepository.cs + ├── LanguageRepository.cs + ├── PostRepository.cs + ├── RatingRepository.cs + ├── RoleRepository.cs + ├── TechnologyRepository.cs + └── UserRepository.cs +``` + +# Service + +``` +└── DevHive.Services + ├── Configurations + │ └── Mapping + | ├── CommentMappings.cs + | ├── FeedMappings.cs + | ├── LanguageMappings.cs + | ├── PostMappings.cs + | ├── RatingMappings.cs + | ├── RoleMapings.cs + | ├── TechnologyMappings.cs + | └── UserMappings.cs + ├── Interfaces + │ ├── ICloudService.cs + │ ├── ICommentService.cs + │ ├── IFeedService.cs + │ ├── ILanguageService.cs + │ ├── IPostService.cs + │ ├── IRateService.cs + │ ├── IRoleService.cs + │ ├── ITechnologyService.cs + │ └── IUserService.cs + ├── Models + | ├── Cloud + | │ └── CloudinaryService.cs + | ├── Comment + | │ ├── CreateCommentServiceModel.cs + | │ ├── ReadCommentServiceModel.cs + | │ └── UpdateCommentServiceModel.cs + | ├── Feed + | │ ├── GetPageServiceModel.cs + | │ └── ReadPageServiceModel.cs + | ├── Identity + | │ ├── Role + | │ │ ├── CreateRoleServiceModel.cs + | │ │ ├── RoleServiceModel.cs + | │ │ └── UpdateRoleServiceModel.cs + | │ └── User + | │ ├── BaseUserServiceModel.cs + | │ ├── FriendServiceModel.cs + | │ ├── LoginServiceModel.cs + | │ ├── ProfilePictureServiceModel.cs + | │ ├── RegisterServiceModel.cs + | │ ├── UpdateFriendServiceModel.cs + | │ ├── UpdateProfilePictureServiceModel.cs + | │ ├── UpdateUserServiceModel.cs + | │ └── UserServiceModel.cs + | ├── Language + | │ ├── CreateLanguageServiceModel.cs + | │ ├── LanguageServiceModel.cs + | │ ├── ReadLanguageServiceModel.cs + | │ └── UpdateLanguageServiceModel.cs + | ├── Post + | | ├── Rating + | | │ ├── RatePostServiceModel.cs + | | │ └── ReadPostRatingServiceModel.cs + | │ ├── CreatePostServiceModel.cs + | │ ├── ReadPostServiceModel.cs + | │ └── UpdatePostServiceModel.cs + | └── Technology + | ├── CreateTechnologyServiceModel.cs + | ├── ReadTechnologyServiceModel.cs + | ├── TechnologyServiceModel.cs + | └── UpdateTechnologyServiceModel.cs + ├── Options + │ └── JWTOptions.cs + └── Services + ├── CommentService.cs + ├── FeedService.cs + ├── LanguageService.cs + ├── PostService.cs + ├── RateService.cs + ├── RoleService.cs + ├── TechnologyService.cs + └── UserService.cs +``` + +# Tests + +``` +└── DevHive.Tests + ├── DevHive.Data.Tests + │ ├── CommentRepository.Tests.cs + │ ├── FeedRepository.Tests.cs + │ ├── LenguageRepository.Tests.cs + │ ├── PostRepository.Tests.cs + │ ├── RoleRepository.Tests.cs + │ ├── TechnologyRepository.Tests.cs + │ └── UserRepositoryTests.cs + ├── DevHive.Services.Tests + │ ├── FeedService.Tests.cs + │ ├── LanguageService.Tests.cs + │ ├── PostService.Tests.cs + │ ├── RoleService.Tests.cs + │ ├── TechnologyServices.Tests.cs + │ └── UserService.Tests.cs + └── DevHive.Web.Tests + ├── LanguageController.Tests.cs + └── TechnologyController.Tests.cs +``` + +# Web + +``` +└── DevHive.Web + ├── appsettings.json + ├── Attributes + │ ├── GoodPasswordModelValidation.cs + │ └── OnlyLettersModelValidation.cs + ├── Configurations + | ├── Extensions + | │ ├── ConfigureAutoMapper.cs + | │ ├── ConfigureDatabase.cs + | │ ├── ConfigureDependencyInjection.cs + | │ ├── ConfigureExceptionHandlerMiddleware.cs + | │ ├── ConfigureJWT.cs + | │ └── ConfigureSwagger.cs + | └── Mapping + | ├── CommentMappings.cs + | ├── FeedMappings.cs + | ├── LanguageMappings.cs + | ├── PostMappings.cs + | ├── RatingMappings.cs + | ├── RoleMappings.cs + | ├── TechnologyMappings.cs + | └── UserMappings.cs + ├── Controllers + │ ├── CommentController.cs + │ ├── FeedController.cs + │ ├── LanguageController.cs + │ ├── PostController.cs + │ ├── RateController.cs + │ ├── RoleController.cs + │ ├── TechnologyController.cs + │ └── UserController.cs + ├── Middleware + │ └── ExceptionMiddleware.cs + ├── Models + | ├── Comment + | │ ├── CreateCommentWebModel.cs + | │ ├── ReadCommentWebModel.cs + | │ └── UpdateCommentWebModel.cs + | ├── Feed + | │ ├── GetPageWebModel.cs + | │ └── ReadPageWebModel.cs + | ├── Identity + | │ ├── Role + | │ │ ├── CreateRoleWebModel.cs + | │ │ ├── RoleWebModel.cs + | │ │ └── UpdateRoleWebModel.cs + | │ └── User + | │ ├── BaseUserWebModel.cs + | │ ├── LoginWebModel.cs + | │ ├── ProfilePictureWebModel.cs + | │ ├── RegisterWebModel.cs + | │ ├── TokenWebModel.cs + | │ ├── UpdateProfilePictureWebModel.cs + | │ ├── UpdateUserWebModel.cs + | │ ├── UsernameWebModel.cs + | │ └── UserWebModel.cs + | ├── Language + | │ ├── CreateLanguageWebModel.cs + | │ ├── LanguageWebModel.cs + | │ ├── ReadLanguageWebModel.cs + | │ └── UpdateLanguageWebModel.cs + | ├── Post + | │ ├── Rating + | │ │ ├── RatePostWebModel.cs + | │ │ └── ReadPostRatingWebModel.cs + | │ ├── CreatePostWebModel.cs + | │ ├── ReadPostWebModel.cs + | │ └── UpdatePostWebModel.cs + | └── Technology + | ├── CreateTechnologyWebModel.cs + | ├── ReadTechnologyWebModel.cs + | ├── TechnologyWebModel.cs + | └── UpdateTechnologyWebModel.cs + ├── Program.cs + ├── Properties + │ └── launchSettings.json + └── Startup.cs +``` + +# Full overview + +``` +. +├── DevHive.code-workspace +├── DevHive.Common +| └── Models +| ├── Identity +| │ └── TokenModel.cs +| └── Misc +| ├── IdModel.cs +| ├── PasswordModifications.cs +| └── Patch.cs +├── DevHive.Data +│ ├── ConnectionString.json +│ ├── DevHiveContext.cs +│ ├── DevHiveContextFactory.cs +| ├── Interfaces +| | ├── Models +| | │ ├── IComment.cs +| │ | ├── ILanguage.cs +| │ | ├── IModel.cs +| │ | ├── IPost.cs +| │ | ├── IProfilePicture.cs +| │ | ├── IRating.cs +| │ | ├── IRole.cs +| │ | ├── ITechnology.cs +| │ | └── IUser.cs +| | └── Repositories +| | ├── ICommentRepository.cs +| | ├── IFeedRepository.cs +| | ├── ILanguageRepository.cs +| | ├── IPostRepository.cs +| | ├── IRatingRepository.cs +| | ├── IRepository.cs +| | ├── IRoleRepository.cs +| | ├── ITechnologyRepository.cs +| | └── IUserRepository.cs +│ ├── Migrations +│ ├── Models +│ │ ├── Comment.cs +│ │ ├── Language.cs +│ │ ├── Post.cs +│ │ ├── ProfilePicture.cs +│ │ ├── Rating.cs +│ │ ├── Role.cs +│ │ ├── Technology.cs +│ │ └── User.cs +│ ├── RelationModels +│ │ ├── RatedPost.cs +│ │ ├── UserFriend.cs +│ │ └── UserRate.cs +│ └── Repositories +│ ├── BaseRepository.cs +│ ├── CommentRepository.cs +│ ├── FeedRepository.cs +│ ├── LanguageRepository.cs +│ ├── PostRepository.cs +│ ├── RatingRepository.cs +│ ├── RoleRepository.cs +│ ├── TechnologyRepository.cs +│ └── UserRepository.cs +├── DevHive.Services +│ ├── Configurations +│ │ └── Mapping +| | ├── CommentMappings.cs +| | ├── FeedMappings.cs +| | ├── LanguageMappings.cs +| | ├── PostMappings.cs +| | ├── RatingMappings.cs +| | ├── RoleMapings.cs +| | ├── TechnologyMappings.cs +| | └── UserMappings.cs +│ ├── Interfaces +│ │ ├── ICloudService.cs +│ │ ├── ICommentService.cs +│ │ ├── IFeedService.cs +│ │ ├── ILanguageService.cs +│ │ ├── IPostService.cs +│ │ ├── IRateService.cs +│ │ ├── IRoleService.cs +│ │ ├── ITechnologyService.cs +│ │ └── IUserService.cs +│ ├── Models +| | ├── Cloud +| | │ └── CloudinaryService.cs +| | ├── Comment +| | │ ├── CreateCommentServiceModel.cs +| | │ ├── ReadCommentServiceModel.cs +| | │ └── UpdateCommentServiceModel.cs +| | ├── Feed +| | │ ├── GetPageServiceModel.cs +| | │ └── ReadPageServiceModel.cs +| | ├── Identity +| | │ ├── Role +| | │ │ ├── CreateRoleServiceModel.cs +| | │ │ ├── RoleServiceModel.cs +| | │ │ └── UpdateRoleServiceModel.cs +| | │ └── User +| | │ ├── BaseUserServiceModel.cs +| | │ ├── FriendServiceModel.cs +| | │ ├── LoginServiceModel.cs +| | │ ├── ProfilePictureServiceModel.cs +| | │ ├── RegisterServiceModel.cs +| | │ ├── UpdateFriendServiceModel.cs +| | │ ├── UpdateProfilePictureServiceModel.cs +| | │ ├── UpdateUserServiceModel.cs +| | │ └── UserServiceModel.cs +| | ├── Language +| | │ ├── CreateLanguageServiceModel.cs +| | │ ├── LanguageServiceModel.cs +| | │ ├── ReadLanguageServiceModel.cs +| | │ └── UpdateLanguageServiceModel.cs +| | ├── Post +| | | ├── Rating +| | | │ ├── RatePostServiceModel.cs +| | | │ └── ReadPostRatingServiceModel.cs +| | │ ├── CreatePostServiceModel.cs +| | │ ├── ReadPostServiceModel.cs +| | │ └── UpdatePostServiceModel.cs +| | └── Technology +| | ├── CreateTechnologyServiceModel.cs +| | ├── ReadTechnologyServiceModel.cs +| | ├── TechnologyServiceModel.cs +| | └── UpdateTechnologyServiceModel.cs +│ ├── Options +│ │ └── JWTOptions.cs +│ └── Services +│ ├── CommentService.cs +│ ├── FeedService.cs +│ ├── LanguageService.cs +│ ├── PostService.cs +│ ├── RateService.cs +│ ├── RoleService.cs +│ ├── TechnologyService.cs +│ └── UserService.cs +├── DevHive.Tests +│ ├── DevHive.Data.Tests +│ │ ├── CommentRepository.Tests.cs +│ │ ├── FeedRepository.Tests.cs +│ │ ├── LenguageRepository.Tests.cs +│ │ ├── PostRepository.Tests.cs +│ │ ├── RoleRepository.Tests.cs +│ │ ├── TechnologyRepository.Tests.cs +│ │ └── UserRepositoryTests.cs +│ ├── DevHive.Services.Tests +│ │ ├── FeedService.Tests.cs +│ │ ├── LanguageService.Tests.cs +│ │ ├── PostService.Tests.cs +│ │ ├── RoleService.Tests.cs +│ │ ├── TechnologyServices.Tests.cs +│ │ └── UserService.Tests.cs +│ └── DevHive.Web.Tests +│ ├── LanguageController.Tests.cs +│ └── TechnologyController.Tests.cs +└── DevHive.Web + ├── appsettings.json + ├── Attributes + │ ├── GoodPasswordModelValidation.cs + │ └── OnlyLettersModelValidation.cs + ├── Configurations + | ├── Extensions + | │ ├── ConfigureAutoMapper.cs + | │ ├── ConfigureDatabase.cs + | │ ├── ConfigureDependencyInjection.cs + | │ ├── ConfigureExceptionHandlerMiddleware.cs + | │ ├── ConfigureJWT.cs + | │ └── ConfigureSwagger.cs + | └── Mapping + | ├── CommentMappings.cs + | ├── FeedMappings.cs + | ├── LanguageMappings.cs + | ├── PostMappings.cs + | ├── RatingMappings.cs + | ├── RoleMappings.cs + | ├── TechnologyMappings.cs + | └── UserMappings.cs + ├── Controllers + │ ├── CommentController.cs + │ ├── FeedController.cs + │ ├── LanguageController.cs + │ ├── PostController.cs + │ ├── RateController.cs + │ ├── RoleController.cs + │ ├── TechnologyController.cs + │ └── UserController.cs + ├── Middleware + │ └── ExceptionMiddleware.cs + ├── Models + | ├── Comment + | │ ├── CreateCommentWebModel.cs + | │ ├── ReadCommentWebModel.cs + | │ └── UpdateCommentWebModel.cs + | ├── Feed + | │ ├── GetPageWebModel.cs + | │ └── ReadPageWebModel.cs + | ├── Identity + | │ ├── Role + | │ │ ├── CreateRoleWebModel.cs + | │ │ ├── RoleWebModel.cs + | │ │ └── UpdateRoleWebModel.cs + | │ └── User + | │ ├── BaseUserWebModel.cs + | │ ├── LoginWebModel.cs + | │ ├── ProfilePictureWebModel.cs + | │ ├── RegisterWebModel.cs + | │ ├── TokenWebModel.cs + | │ ├── UpdateProfilePictureWebModel.cs + | │ ├── UpdateUserWebModel.cs + | │ ├── UsernameWebModel.cs + | │ └── UserWebModel.cs + | ├── Language + | │ ├── CreateLanguageWebModel.cs + | │ ├── LanguageWebModel.cs + | │ ├── ReadLanguageWebModel.cs + | │ └── UpdateLanguageWebModel.cs + | ├── Post + | │ ├── Rating + | │ │ ├── RatePostWebModel.cs + | │ │ └── ReadPostRatingWebModel.cs + | │ ├── CreatePostWebModel.cs + | │ ├── ReadPostWebModel.cs + | │ └── UpdatePostWebModel.cs + | └── Technology + | ├── CreateTechnologyWebModel.cs + | ├── ReadTechnologyWebModel.cs + | ├── TechnologyWebModel.cs + | └── UpdateTechnologyWebModel.cs + ├── Program.cs + ├── Properties + │ └── launchSettings.json + └── Startup.cs +``` diff --git a/docs/Privacy-Policy.md b/docs/Privacy-Policy.md new file mode 100644 index 0000000..c338763 --- /dev/null +++ b/docs/Privacy-Policy.md @@ -0,0 +1,23 @@ +DevHive **doesn't collect any user data, that you haven't personally submitted** (there is no telemetry), and that won't ever change! + +The only potentially sensitive that that could be stored is your profile (first and last name, email, ..) and your posts (if you've shared anything sensitive), but in both cases you've personally given this information. + +## Data on the server + +All data is stored in the database and isn't shared with anyone. The entity that is hosting an instance of the application could expose data to unknown third parties, but DevHive doesn't do anything of the sorts by itself! + +## Data on your machine + +On your computer, the only thing that is saved is your [authentication token](https://github.com/Team-Kaleidoscope/DevHive/wiki/Authentication) in session storage. This is done so you could stay logged in the website in the current tab, and after closing it, the data gets deleted. + +In the future we could add a cookie to your computer storage, but that will still only hold the token for authentication purposes, so you can reopen your browser and still be logged in. **Tracking and third-party cookies are *never* going to be implemented!** + +## Telemetry by tools + +DevHive itself doesn't collect any type of telemetry, but that isn't the same for the tools it uses. + +The `dotnet` CLI tool is used to run the API, and `dotnet` does [`collect telemetry`](https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry). [The same](https://angular.io/cli/usage-analytics-gathering) can be said for the Angular CLI (`ng`). + +Thankfully in both cases, you can opt out. Ask the administrator(s) of the instance you're using whether they have disabled telemetry. + +**Although**, it's important to mention that **this telemetry might not be collecting your data**, but the data of the server that uses it. Do your own research!
\ No newline at end of file diff --git a/src/Data/DevHive.Data.Models/ProfilePicture.cs b/src/Data/DevHive.Data.Models/ProfilePicture.cs index 4b629c2..5877861 100644 --- a/src/Data/DevHive.Data.Models/ProfilePicture.cs +++ b/src/Data/DevHive.Data.Models/ProfilePicture.cs @@ -1,7 +1,9 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; namespace DevHive.Data.Models { + [Table("ProfilePictures")] public class ProfilePicture { public Guid Id { get; set; } diff --git a/src/Data/DevHive.Data.Models/RelationalModels/RatedPost.cs b/src/Data/DevHive.Data.Models/RelationalModels/RatedPost.cs deleted file mode 100644 index fb63848..0000000 --- a/src/Data/DevHive.Data.Models/RelationalModels/RatedPost.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; -using System.Reflection.Metadata.Ecma335; -using DevHive.Data.Models; -using Microsoft.EntityFrameworkCore; - -namespace DevHive.Data.Models.Relational -{ - [Table("RatedPosts")] - public class RatedPost - { - public Guid UserId { get; set; } - public User User { get; set; } - - public Guid PostId { get; set; } - public Post Post { get; set; } - } -} diff --git a/src/Data/DevHive.Data.Models/RelationalModels/UserRate.cs b/src/Data/DevHive.Data.Models/RelationalModels/UserRate.cs deleted file mode 100644 index 46bd605..0000000 --- a/src/Data/DevHive.Data.Models/RelationalModels/UserRate.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; -using DevHive.Data.Models; - -namespace DevHive.Data.Models.Relational -{ - [Table("UserRates")] - public class UserRate - { - public Guid Id { get; set; } - - public User User { get; set; } - - public bool Liked { get; set; } - - public Post Post { get; set; } - } -} diff --git a/src/Data/DevHive.Data.Models/User.cs b/src/Data/DevHive.Data.Models/User.cs index feae197..f6cd3b9 100644 --- a/src/Data/DevHive.Data.Models/User.cs +++ b/src/Data/DevHive.Data.Models/User.cs @@ -13,7 +13,7 @@ namespace DevHive.Data.Models public string LastName { get; set; } - public ProfilePicture ProfilePicture { get; set; } = new() { PictureURL = "/assets/icons/tabler-icon-user.svg" }; + public ProfilePicture ProfilePicture { get; set; } = new(); public HashSet<Language> Languages { get; set; } = new(); @@ -26,7 +26,5 @@ namespace DevHive.Data.Models public HashSet<User> Friends { get; set; } = new(); public HashSet<Comment> Comments { get; set; } = new(); - - public HashSet<RatedPost> RatedPosts { get; set; } = new(); } } diff --git a/src/Data/DevHive.Data/ConnectionString.json b/src/Data/DevHive.Data/ConnectionString.json index c8300b2..1281a1c 100644 --- a/src/Data/DevHive.Data/ConnectionString.json +++ b/src/Data/DevHive.Data/ConnectionString.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=password;" + "DEV": "Server=localhost;Port=5432;Database=DevHive_API;User Id=postgres;Password=password;" } -}
\ No newline at end of file +} diff --git a/src/Data/DevHive.Data/DevHiveContext.cs b/src/Data/DevHive.Data/DevHiveContext.cs index c3adf2d..f8574a4 100644 --- a/src/Data/DevHive.Data/DevHiveContext.cs +++ b/src/Data/DevHive.Data/DevHiveContext.cs @@ -18,8 +18,6 @@ namespace DevHive.Data public DbSet<Comment> Comments { get; set; } public DbSet<Rating> Rating { get; set; } public DbSet<ProfilePicture> ProfilePicture { get; set; } - public DbSet<RatedPost> RatedPost { get; set; } - public DbSet<UserRate> UserRate { get; set; } protected override void OnModelCreating(ModelBuilder builder) { @@ -93,20 +91,6 @@ namespace DevHive.Data .HasMany(x => x.Ratings) .WithOne(x => x.Post); - /* User Rated Posts */ - builder.Entity<RatedPost>() - .HasKey(x => new { x.UserId, x.PostId }); - - builder.Entity<RatedPost>() - .HasOne(x => x.User) - .WithMany(x => x.RatedPosts); - - builder.Entity<RatedPost>() - .HasOne(x => x.Post); - - builder.Entity<User>() - .HasMany(x => x.RatedPosts); - base.OnModelCreating(builder); } } diff --git a/src/Data/DevHive.Data/Migrations/20210216152915_Inital.Designer.cs b/src/Data/DevHive.Data/Migrations/20210216152915_Inital.Designer.cs deleted file mode 100644 index a85f657..0000000 --- a/src/Data/DevHive.Data/Migrations/20210216152915_Inital.Designer.cs +++ /dev/null @@ -1,667 +0,0 @@ -// <auto-generated /> -using System; -using DevHive.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - [DbContext(typeof(DevHiveContext))] - [Migration("20210216152915_Inital")] - partial class Inital - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.3") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.HasIndex("PostId"); - - b.ToTable("Comments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Language", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Languages"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("PictureURL") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("ProfilePicture"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.Property<int>("Rate") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("PostId") - .IsUnique(); - - b.ToTable("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("FileUrl") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.ToTable("PostAttachments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "PostId"); - - b.HasIndex("PostId"); - - b.ToTable("RatedPosts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("Liked") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("UserRates"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Role", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Technology", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Technologies"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<int>("AccessFailedCount") - .HasColumnType("integer"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<bool>("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("FirstName") - .HasColumnType("text"); - - b.Property<string>("LastName") - .HasColumnType("text"); - - b.Property<bool>("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property<DateTimeOffset?>("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("PasswordHash") - .HasColumnType("text"); - - b.Property<string>("PhoneNumber") - .HasColumnType("text"); - - b.Property<bool>("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("SecurityStamp") - .HasColumnType("text"); - - b.Property<bool>("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("UserId"); - - b.HasIndex("UserName") - .IsUnique(); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.Property<Guid>("LanguagesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("LanguagesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("LanguageUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("ProviderKey") - .HasColumnType("text"); - - b.Property<string>("ProviderDisplayName") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.Property<string>("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.Property<Guid>("RolesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("RolesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("RoleUser"); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.Property<Guid>("TechnologiesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("TechnologiesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("TechnologyUser"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Comments") - .HasForeignKey("CreatorId"); - - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Comments") - .HasForeignKey("PostId"); - - b.Navigation("Creator"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Posts") - .HasForeignKey("CreatorId"); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.HasOne("DevHive.Data.Models.User", "User") - .WithOne("ProfilePicture") - .HasForeignKey("DevHive.Data.Models.ProfilePicture", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithOne("Rating") - .HasForeignKey("DevHive.Data.Models.Rating", "PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Attachments") - .HasForeignKey("PostId"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany("RatedPosts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany("Friends") - .HasForeignKey("UserId"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.HasOne("DevHive.Data.Models.Language", null) - .WithMany() - .HasForeignKey("LanguagesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RolesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.HasOne("DevHive.Data.Models.Technology", null) - .WithMany() - .HasForeignKey("TechnologiesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Navigation("Attachments"); - - b.Navigation("Comments"); - - b.Navigation("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Navigation("Comments"); - - b.Navigation("Friends"); - - b.Navigation("Posts"); - - b.Navigation("ProfilePicture"); - - b.Navigation("RatedPosts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210216152915_Inital.cs b/src/Data/DevHive.Data/Migrations/20210216152915_Inital.cs deleted file mode 100644 index 4c5b982..0000000 --- a/src/Data/DevHive.Data/Migrations/20210216152915_Inital.cs +++ /dev/null @@ -1,587 +0,0 @@ -// <auto-generated /> -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - public partial class Inital : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - FirstName = table.Column<string>(type: "text", nullable: true), - LastName = table.Column<string>(type: "text", nullable: true), - UserId = table.Column<Guid>(type: "uuid", nullable: true), - UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false), - PasswordHash = table.Column<string>(type: "text", nullable: true), - SecurityStamp = table.Column<string>(type: "text", nullable: true), - ConcurrencyStamp = table.Column<string>(type: "text", nullable: true), - PhoneNumber = table.Column<string>(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false), - LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false), - AccessFailedCount = table.Column<int>(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUsers_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Languages", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - Name = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Languages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Technologies", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - Name = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Technologies", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column<Guid>(type: "uuid", nullable: false), - ClaimType = table.Column<string>(type: "text", nullable: true), - ClaimValue = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column<Guid>(type: "uuid", nullable: false), - ClaimType = table.Column<string>(type: "text", nullable: true), - ClaimValue = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column<string>(type: "text", nullable: false), - ProviderKey = table.Column<string>(type: "text", nullable: false), - ProviderDisplayName = table.Column<string>(type: "text", nullable: true), - UserId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column<Guid>(type: "uuid", nullable: false), - RoleId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column<Guid>(type: "uuid", nullable: false), - LoginProvider = table.Column<string>(type: "text", nullable: false), - Name = table.Column<string>(type: "text", nullable: false), - Value = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Posts", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - CreatorId = table.Column<Guid>(type: "uuid", nullable: true), - Message = table.Column<string>(type: "text", nullable: true), - TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Posts", x => x.Id); - table.ForeignKey( - name: "FK_Posts_AspNetUsers_CreatorId", - column: x => x.CreatorId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "ProfilePicture", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - UserId = table.Column<Guid>(type: "uuid", nullable: false), - PictureURL = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ProfilePicture", x => x.Id); - table.ForeignKey( - name: "FK_ProfilePicture_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "RoleUser", - columns: table => new - { - RolesId = table.Column<Guid>(type: "uuid", nullable: false), - UsersId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RoleUser", x => new { x.RolesId, x.UsersId }); - table.ForeignKey( - name: "FK_RoleUser_AspNetRoles_RolesId", - column: x => x.RolesId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_RoleUser_AspNetUsers_UsersId", - column: x => x.UsersId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LanguageUser", - columns: table => new - { - LanguagesId = table.Column<Guid>(type: "uuid", nullable: false), - UsersId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LanguageUser", x => new { x.LanguagesId, x.UsersId }); - table.ForeignKey( - name: "FK_LanguageUser_AspNetUsers_UsersId", - column: x => x.UsersId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LanguageUser_Languages_LanguagesId", - column: x => x.LanguagesId, - principalTable: "Languages", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TechnologyUser", - columns: table => new - { - TechnologiesId = table.Column<Guid>(type: "uuid", nullable: false), - UsersId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TechnologyUser", x => new { x.TechnologiesId, x.UsersId }); - table.ForeignKey( - name: "FK_TechnologyUser_AspNetUsers_UsersId", - column: x => x.UsersId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TechnologyUser_Technologies_TechnologiesId", - column: x => x.TechnologiesId, - principalTable: "Technologies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Comments", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - PostId = table.Column<Guid>(type: "uuid", nullable: true), - CreatorId = table.Column<Guid>(type: "uuid", nullable: true), - Message = table.Column<string>(type: "text", nullable: true), - TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Comments", x => x.Id); - table.ForeignKey( - name: "FK_Comments_AspNetUsers_CreatorId", - column: x => x.CreatorId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Comments_Posts_PostId", - column: x => x.PostId, - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "PostAttachments", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - PostId = table.Column<Guid>(type: "uuid", nullable: true), - FileUrl = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PostAttachments", x => x.Id); - table.ForeignKey( - name: "FK_PostAttachments_Posts_PostId", - column: x => x.PostId, - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "RatedPosts", - columns: table => new - { - UserId = table.Column<Guid>(type: "uuid", nullable: false), - PostId = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RatedPosts", x => new { x.UserId, x.PostId }); - table.ForeignKey( - name: "FK_RatedPosts_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_RatedPosts_Posts_PostId", - column: x => x.PostId, - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Rating", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - PostId = table.Column<Guid>(type: "uuid", nullable: false), - Rate = table.Column<int>(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Rating", x => x.Id); - table.ForeignKey( - name: "FK_Rating_Posts_PostId", - column: x => x.PostId, - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserRates", - columns: table => new - { - Id = table.Column<Guid>(type: "uuid", nullable: false), - UserId = table.Column<Guid>(type: "uuid", nullable: true), - Liked = table.Column<bool>(type: "boolean", nullable: false), - PostId = table.Column<Guid>(type: "uuid", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UserRates", x => x.Id); - table.ForeignKey( - name: "FK_UserRates_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_UserRates_Posts_PostId", - column: x => x.PostId, - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUsers_UserId", - table: "AspNetUsers", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUsers_UserName", - table: "AspNetUsers", - column: "UserName", - unique: true); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Comments_CreatorId", - table: "Comments", - column: "CreatorId"); - - migrationBuilder.CreateIndex( - name: "IX_Comments_PostId", - table: "Comments", - column: "PostId"); - - migrationBuilder.CreateIndex( - name: "IX_LanguageUser_UsersId", - table: "LanguageUser", - column: "UsersId"); - - migrationBuilder.CreateIndex( - name: "IX_PostAttachments_PostId", - table: "PostAttachments", - column: "PostId"); - - migrationBuilder.CreateIndex( - name: "IX_Posts_CreatorId", - table: "Posts", - column: "CreatorId"); - - migrationBuilder.CreateIndex( - name: "IX_ProfilePicture_UserId", - table: "ProfilePicture", - column: "UserId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_RatedPosts_PostId", - table: "RatedPosts", - column: "PostId"); - - migrationBuilder.CreateIndex( - name: "IX_Rating_PostId", - table: "Rating", - column: "PostId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_RoleUser_UsersId", - table: "RoleUser", - column: "UsersId"); - - migrationBuilder.CreateIndex( - name: "IX_TechnologyUser_UsersId", - table: "TechnologyUser", - column: "UsersId"); - - migrationBuilder.CreateIndex( - name: "IX_UserRates_PostId", - table: "UserRates", - column: "PostId"); - - migrationBuilder.CreateIndex( - name: "IX_UserRates_UserId", - table: "UserRates", - column: "UserId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "Comments"); - - migrationBuilder.DropTable( - name: "LanguageUser"); - - migrationBuilder.DropTable( - name: "PostAttachments"); - - migrationBuilder.DropTable( - name: "ProfilePicture"); - - migrationBuilder.DropTable( - name: "RatedPosts"); - - migrationBuilder.DropTable( - name: "Rating"); - - migrationBuilder.DropTable( - name: "RoleUser"); - - migrationBuilder.DropTable( - name: "TechnologyUser"); - - migrationBuilder.DropTable( - name: "UserRates"); - - migrationBuilder.DropTable( - name: "Languages"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "Technologies"); - - migrationBuilder.DropTable( - name: "Posts"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.Designer.cs b/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.Designer.cs deleted file mode 100644 index c0b67a6..0000000 --- a/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.Designer.cs +++ /dev/null @@ -1,678 +0,0 @@ -// <auto-generated /> -using System; -using DevHive.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - [DbContext(typeof(DevHiveContext))] - [Migration("20210225193352_rating_migration")] - partial class rating_migration - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.3") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.HasIndex("PostId"); - - b.ToTable("Comments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Language", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Languages"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<int>("CurrentRating") - .HasColumnType("integer"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("PictureURL") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("ProfilePicture"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("IsLike") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("FileUrl") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.ToTable("PostAttachments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "PostId"); - - b.HasIndex("PostId"); - - b.ToTable("RatedPosts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("Liked") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("UserRates"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Role", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Technology", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Technologies"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<int>("AccessFailedCount") - .HasColumnType("integer"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<bool>("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("FirstName") - .HasColumnType("text"); - - b.Property<string>("LastName") - .HasColumnType("text"); - - b.Property<bool>("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property<DateTimeOffset?>("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("PasswordHash") - .HasColumnType("text"); - - b.Property<string>("PhoneNumber") - .HasColumnType("text"); - - b.Property<bool>("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("SecurityStamp") - .HasColumnType("text"); - - b.Property<bool>("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("UserId"); - - b.HasIndex("UserName") - .IsUnique(); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.Property<Guid>("LanguagesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("LanguagesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("LanguageUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("ProviderKey") - .HasColumnType("text"); - - b.Property<string>("ProviderDisplayName") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.Property<string>("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.Property<Guid>("RolesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("RolesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("RoleUser"); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.Property<Guid>("TechnologiesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("TechnologiesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("TechnologyUser"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Comments") - .HasForeignKey("CreatorId"); - - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Comments") - .HasForeignKey("PostId"); - - b.Navigation("Creator"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Posts") - .HasForeignKey("CreatorId"); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.HasOne("DevHive.Data.Models.User", "User") - .WithOne("ProfilePicture") - .HasForeignKey("DevHive.Data.Models.ProfilePicture", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Ratings") - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Attachments") - .HasForeignKey("PostId"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany("RatedPosts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany("Friends") - .HasForeignKey("UserId"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.HasOne("DevHive.Data.Models.Language", null) - .WithMany() - .HasForeignKey("LanguagesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RolesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.HasOne("DevHive.Data.Models.Technology", null) - .WithMany() - .HasForeignKey("TechnologiesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Navigation("Attachments"); - - b.Navigation("Comments"); - - b.Navigation("Ratings"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Navigation("Comments"); - - b.Navigation("Friends"); - - b.Navigation("Posts"); - - b.Navigation("ProfilePicture"); - - b.Navigation("RatedPosts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.cs b/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.cs deleted file mode 100644 index da81cdc..0000000 --- a/src/Data/DevHive.Data/Migrations/20210225193352_rating_migration.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DevHive.Data.Migrations -{ - public partial class rating_migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Rating_Posts_PostId", - table: "Rating"); - - migrationBuilder.DropIndex( - name: "IX_Rating_PostId", - table: "Rating"); - - migrationBuilder.DropColumn( - name: "Rate", - table: "Rating"); - - migrationBuilder.AlterColumn<Guid>( - name: "PostId", - table: "Rating", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddColumn<bool>( - name: "IsLike", - table: "Rating", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn<Guid>( - name: "UserId", - table: "Rating", - type: "uuid", - nullable: true); - - migrationBuilder.AddColumn<int>( - name: "CurrentRating", - table: "Posts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateIndex( - name: "IX_Rating_PostId", - table: "Rating", - column: "PostId"); - - migrationBuilder.CreateIndex( - name: "IX_Rating_UserId", - table: "Rating", - column: "UserId"); - - migrationBuilder.AddForeignKey( - name: "FK_Rating_AspNetUsers_UserId", - table: "Rating", - column: "UserId", - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Rating_Posts_PostId", - table: "Rating", - column: "PostId", - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Rating_AspNetUsers_UserId", - table: "Rating"); - - migrationBuilder.DropForeignKey( - name: "FK_Rating_Posts_PostId", - table: "Rating"); - - migrationBuilder.DropIndex( - name: "IX_Rating_PostId", - table: "Rating"); - - migrationBuilder.DropIndex( - name: "IX_Rating_UserId", - table: "Rating"); - - migrationBuilder.DropColumn( - name: "IsLike", - table: "Rating"); - - migrationBuilder.DropColumn( - name: "UserId", - table: "Rating"); - - migrationBuilder.DropColumn( - name: "CurrentRating", - table: "Posts"); - - migrationBuilder.AlterColumn<Guid>( - name: "PostId", - table: "Rating", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddColumn<int>( - name: "Rate", - table: "Rating", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateIndex( - name: "IX_Rating_PostId", - table: "Rating", - column: "PostId", - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_Rating_Posts_PostId", - table: "Rating", - column: "PostId", - principalTable: "Posts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.Designer.cs b/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.Designer.cs deleted file mode 100644 index ff5dd1c..0000000 --- a/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.Designer.cs +++ /dev/null @@ -1,675 +0,0 @@ -// <auto-generated /> -using System; -using DevHive.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - [DbContext(typeof(DevHiveContext))] - [Migration("20210303083146_rating_migrations_update")] - partial class rating_migrations_update - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.3") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.HasIndex("PostId"); - - b.ToTable("Comments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Language", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Languages"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("PictureURL") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("ProfilePicture"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("IsLike") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("FileUrl") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.ToTable("PostAttachments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "PostId"); - - b.HasIndex("PostId"); - - b.ToTable("RatedPosts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("Liked") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("UserRates"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Role", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Technology", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Technologies"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<int>("AccessFailedCount") - .HasColumnType("integer"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<bool>("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("FirstName") - .HasColumnType("text"); - - b.Property<string>("LastName") - .HasColumnType("text"); - - b.Property<bool>("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property<DateTimeOffset?>("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("PasswordHash") - .HasColumnType("text"); - - b.Property<string>("PhoneNumber") - .HasColumnType("text"); - - b.Property<bool>("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("SecurityStamp") - .HasColumnType("text"); - - b.Property<bool>("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("UserId"); - - b.HasIndex("UserName") - .IsUnique(); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.Property<Guid>("LanguagesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("LanguagesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("LanguageUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("ProviderKey") - .HasColumnType("text"); - - b.Property<string>("ProviderDisplayName") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.Property<string>("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.Property<Guid>("RolesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("RolesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("RoleUser"); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.Property<Guid>("TechnologiesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("TechnologiesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("TechnologyUser"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Comments") - .HasForeignKey("CreatorId"); - - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Comments") - .HasForeignKey("PostId"); - - b.Navigation("Creator"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Posts") - .HasForeignKey("CreatorId"); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.HasOne("DevHive.Data.Models.User", "User") - .WithOne("ProfilePicture") - .HasForeignKey("DevHive.Data.Models.ProfilePicture", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Ratings") - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Attachments") - .HasForeignKey("PostId"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany("RatedPosts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany("Friends") - .HasForeignKey("UserId"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.HasOne("DevHive.Data.Models.Language", null) - .WithMany() - .HasForeignKey("LanguagesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RolesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.HasOne("DevHive.Data.Models.Technology", null) - .WithMany() - .HasForeignKey("TechnologiesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Navigation("Attachments"); - - b.Navigation("Comments"); - - b.Navigation("Ratings"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Navigation("Comments"); - - b.Navigation("Friends"); - - b.Navigation("Posts"); - - b.Navigation("ProfilePicture"); - - b.Navigation("RatedPosts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.cs b/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.cs deleted file mode 100644 index 073ba50..0000000 --- a/src/Data/DevHive.Data/Migrations/20210303083146_rating_migrations_update.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DevHive.Data.Migrations -{ - public partial class rating_migrations_update : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CurrentRating", - table: "Posts"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<int>( - name: "CurrentRating", - table: "Posts", - type: "integer", - nullable: false, - defaultValue: 0); - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.Designer.cs b/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.Designer.cs deleted file mode 100644 index 189060d..0000000 --- a/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.Designer.cs +++ /dev/null @@ -1,667 +0,0 @@ -// <auto-generated /> -using System; -using DevHive.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - [DbContext(typeof(DevHiveContext))] - [Migration("20210325081526_Profile_Picture_Layer")] - partial class Profile_Picture_Layer - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.3") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.HasIndex("PostId"); - - b.ToTable("Comments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Language", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Languages"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("PictureURL") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("ProfilePicture"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("IsLike") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("FileUrl") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.ToTable("PostAttachments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "PostId"); - - b.HasIndex("PostId"); - - b.ToTable("RatedPosts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("Liked") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("UserRates"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Role", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Technology", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Technologies"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<int>("AccessFailedCount") - .HasColumnType("integer"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<bool>("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("FirstName") - .HasColumnType("text"); - - b.Property<string>("LastName") - .HasColumnType("text"); - - b.Property<bool>("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property<DateTimeOffset?>("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("PasswordHash") - .HasColumnType("text"); - - b.Property<string>("PhoneNumber") - .HasColumnType("text"); - - b.Property<bool>("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property<Guid?>("ProfilePictureId") - .HasColumnType("uuid"); - - b.Property<string>("SecurityStamp") - .HasColumnType("text"); - - b.Property<bool>("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("ProfilePictureId"); - - b.HasIndex("UserId"); - - b.HasIndex("UserName") - .IsUnique(); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.Property<Guid>("LanguagesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("LanguagesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("LanguageUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("ProviderKey") - .HasColumnType("text"); - - b.Property<string>("ProviderDisplayName") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.Property<string>("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.Property<Guid>("RolesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("RolesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("RoleUser"); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.Property<Guid>("TechnologiesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("TechnologiesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("TechnologyUser"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Comments") - .HasForeignKey("CreatorId"); - - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Comments") - .HasForeignKey("PostId"); - - b.Navigation("Creator"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Posts") - .HasForeignKey("CreatorId"); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Ratings") - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Attachments") - .HasForeignKey("PostId"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany("RatedPosts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.HasOne("DevHive.Data.Models.ProfilePicture", "ProfilePicture") - .WithMany() - .HasForeignKey("ProfilePictureId"); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany("Friends") - .HasForeignKey("UserId"); - - b.Navigation("ProfilePicture"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.HasOne("DevHive.Data.Models.Language", null) - .WithMany() - .HasForeignKey("LanguagesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RolesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.HasOne("DevHive.Data.Models.Technology", null) - .WithMany() - .HasForeignKey("TechnologiesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Navigation("Attachments"); - - b.Navigation("Comments"); - - b.Navigation("Ratings"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Navigation("Comments"); - - b.Navigation("Friends"); - - b.Navigation("Posts"); - - b.Navigation("RatedPosts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.cs b/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.cs deleted file mode 100644 index 0ee1fb7..0000000 --- a/src/Data/DevHive.Data/Migrations/20210325081526_Profile_Picture_Layer.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DevHive.Data.Migrations -{ - public partial class Profile_Picture_Layer : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ProfilePicture_AspNetUsers_UserId", - table: "ProfilePicture"); - - migrationBuilder.DropIndex( - name: "IX_ProfilePicture_UserId", - table: "ProfilePicture"); - - migrationBuilder.DropColumn( - name: "UserId", - table: "ProfilePicture"); - - migrationBuilder.AddColumn<Guid>( - name: "ProfilePictureId", - table: "AspNetUsers", - type: "uuid", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUsers_ProfilePictureId", - table: "AspNetUsers", - column: "ProfilePictureId"); - - migrationBuilder.AddForeignKey( - name: "FK_AspNetUsers_ProfilePicture_ProfilePictureId", - table: "AspNetUsers", - column: "ProfilePictureId", - principalTable: "ProfilePicture", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_AspNetUsers_ProfilePicture_ProfilePictureId", - table: "AspNetUsers"); - - migrationBuilder.DropIndex( - name: "IX_AspNetUsers_ProfilePictureId", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "ProfilePictureId", - table: "AspNetUsers"); - - migrationBuilder.AddColumn<Guid>( - name: "UserId", - table: "ProfilePicture", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.CreateIndex( - name: "IX_ProfilePicture_UserId", - table: "ProfilePicture", - column: "UserId", - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_ProfilePicture_AspNetUsers_UserId", - table: "ProfilePicture", - column: "UserId", - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/Data/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs b/src/Data/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs deleted file mode 100644 index 8877fab..0000000 --- a/src/Data/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs +++ /dev/null @@ -1,665 +0,0 @@ -// <auto-generated /> -using System; -using DevHive.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace DevHive.Data.Migrations -{ - [DbContext(typeof(DevHiveContext))] - partial class DevHiveContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.3") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.HasIndex("PostId"); - - b.ToTable("Comments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Language", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Languages"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<Guid?>("CreatorId") - .HasColumnType("uuid"); - - b.Property<string>("Message") - .HasColumnType("text"); - - b.Property<DateTime>("TimeCreated") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("CreatorId"); - - b.ToTable("Posts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.ProfilePicture", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("PictureURL") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("ProfilePicture"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("IsLike") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("Rating"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("FileUrl") - .HasColumnType("text"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.ToTable("PostAttachments"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("PostId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "PostId"); - - b.HasIndex("PostId"); - - b.ToTable("RatedPosts"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<bool>("Liked") - .HasColumnType("boolean"); - - b.Property<Guid?>("PostId") - .HasColumnType("uuid"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("UserRates"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Role", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Technology", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Technologies"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property<int>("AccessFailedCount") - .HasColumnType("integer"); - - b.Property<string>("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property<string>("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<bool>("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property<string>("FirstName") - .HasColumnType("text"); - - b.Property<string>("LastName") - .HasColumnType("text"); - - b.Property<bool>("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property<DateTimeOffset?>("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property<string>("PasswordHash") - .HasColumnType("text"); - - b.Property<string>("PhoneNumber") - .HasColumnType("text"); - - b.Property<bool>("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property<Guid?>("ProfilePictureId") - .HasColumnType("uuid"); - - b.Property<string>("SecurityStamp") - .HasColumnType("text"); - - b.Property<bool>("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("ProfilePictureId"); - - b.HasIndex("UserId"); - - b.HasIndex("UserName") - .IsUnique(); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.Property<Guid>("LanguagesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("LanguagesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("LanguageUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property<string>("ClaimType") - .HasColumnType("text"); - - b.Property<string>("ClaimValue") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("ProviderKey") - .HasColumnType("text"); - - b.Property<string>("ProviderDisplayName") - .HasColumnType("text"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<Guid>("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.Property<Guid>("UserId") - .HasColumnType("uuid"); - - b.Property<string>("LoginProvider") - .HasColumnType("text"); - - b.Property<string>("Name") - .HasColumnType("text"); - - b.Property<string>("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.Property<Guid>("RolesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("RolesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("RoleUser"); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.Property<Guid>("TechnologiesId") - .HasColumnType("uuid"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid"); - - b.HasKey("TechnologiesId", "UsersId"); - - b.HasIndex("UsersId"); - - b.ToTable("TechnologyUser"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Comment", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Comments") - .HasForeignKey("CreatorId"); - - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Comments") - .HasForeignKey("PostId"); - - b.Navigation("Creator"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.HasOne("DevHive.Data.Models.User", "Creator") - .WithMany("Posts") - .HasForeignKey("CreatorId"); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Rating", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Ratings") - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.PostAttachments", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany("Attachments") - .HasForeignKey("PostId"); - - b.Navigation("Post"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.RatedPost", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany("RatedPosts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.Relational.UserRate", b => - { - b.HasOne("DevHive.Data.Models.Post", "Post") - .WithMany() - .HasForeignKey("PostId"); - - b.HasOne("DevHive.Data.Models.User", "User") - .WithMany() - .HasForeignKey("UserId"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.HasOne("DevHive.Data.Models.ProfilePicture", "ProfilePicture") - .WithMany() - .HasForeignKey("ProfilePictureId"); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany("Friends") - .HasForeignKey("UserId"); - - b.Navigation("ProfilePicture"); - }); - - modelBuilder.Entity("LanguageUser", b => - { - b.HasOne("DevHive.Data.Models.Language", null) - .WithMany() - .HasForeignKey("LanguagesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => - { - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RoleUser", b => - { - b.HasOne("DevHive.Data.Models.Role", null) - .WithMany() - .HasForeignKey("RolesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TechnologyUser", b => - { - b.HasOne("DevHive.Data.Models.Technology", null) - .WithMany() - .HasForeignKey("TechnologiesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DevHive.Data.Models.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DevHive.Data.Models.Post", b => - { - b.Navigation("Attachments"); - - b.Navigation("Comments"); - - b.Navigation("Ratings"); - }); - - modelBuilder.Entity("DevHive.Data.Models.User", b => - { - b.Navigation("Comments"); - - b.Navigation("Friends"); - - b.Navigation("Posts"); - - b.Navigation("RatedPosts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Services/DevHive.Services.Models/User/UserServiceModel.cs b/src/Services/DevHive.Services.Models/User/UserServiceModel.cs index 04b618b..ad4e553 100644 --- a/src/Services/DevHive.Services.Models/User/UserServiceModel.cs +++ b/src/Services/DevHive.Services.Models/User/UserServiceModel.cs @@ -8,7 +8,7 @@ namespace DevHive.Services.Models.User { public class UserServiceModel : BaseUserServiceModel { - public string ProfilePictureURL { get; set; } + public string ProfilePictureURL { get; set; } = new("/assets/icons/tabler-icon-user.svg"); public HashSet<RoleServiceModel> Roles { get; set; } = new(); diff --git a/src/Services/DevHive.Services/Services/ProfilePictureService.cs b/src/Services/DevHive.Services/Services/ProfilePictureService.cs index 8a9bb29..7093818 100644 --- a/src/Services/DevHive.Services/Services/ProfilePictureService.cs +++ b/src/Services/DevHive.Services/Services/ProfilePictureService.cs @@ -41,7 +41,7 @@ namespace DevHive.Services.Services await ValidateUserExistsAsync(profilePictureServiceModel.UserId); User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId); - if (!string.IsNullOrEmpty(user.ProfilePicture.PictureURL)) + if (user.ProfilePicture.Id != Guid.Empty) { List<string> file = new() { user.ProfilePicture.PictureURL }; bool removed = await this._cloudinaryService.RemoveFilesFromCloud(file); @@ -81,8 +81,9 @@ namespace DevHive.Services.Services throw new ArgumentException("Unable to upload picture!"); User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId); - user.ProfilePicture = await this._profilePictureRepository.GetByURLAsync(picUrl); + user.ProfilePicture = profilePic; bool userProfilePicAlter = await this._userRepository.EditAsync(user.Id, user); + if (!userProfilePicAlter) throw new ArgumentException("Unable to alter user's profile picture"); diff --git a/src/Services/DevHive.Services/Services/RatingService.cs b/src/Services/DevHive.Services/Services/RatingService.cs index 1f77a6e..9d8f4b0 100644 --- a/src/Services/DevHive.Services/Services/RatingService.cs +++ b/src/Services/DevHive.Services/Services/RatingService.cs @@ -57,8 +57,9 @@ namespace DevHive.Services.Services #region Read public async Task<ReadRatingServiceModel> GetRatingById(Guid ratingId) { - Rating rating = await this._ratingRepository.GetByIdAsync(ratingId) ?? - throw new ArgumentException("The rating does not exist"); + Rating rating = await this._ratingRepository.GetByIdAsync(ratingId); + if (rating is null) + return null; ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating); readRatingServiceModel.UserId = rating.User.Id; @@ -68,8 +69,9 @@ namespace DevHive.Services.Services public async Task<ReadRatingServiceModel> GetRatingByPostAndUser(Guid userId, Guid postId) { - Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId) ?? - throw new ArgumentException("The rating does not exist"); + Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId); + if (rating is null) + return null; ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating); readRatingServiceModel.UserId = rating.User.Id; diff --git a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs index f159b69..e2521bd 100644 --- a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs +++ b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs @@ -2,7 +2,7 @@ using System; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; +using Newtonsoft.Json; namespace DevHive.Web.Middleware { @@ -32,11 +32,14 @@ namespace DevHive.Web.Middleware context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)HttpStatusCode.BadRequest; - return context.Response.WriteAsync(new - { - context.Response.StatusCode, - exception.Message - }.ToString()); + // Made to ressemble the formatting of property validation errors (like [MinLength(3)]) + string message = JsonConvert.SerializeObject(new { + errors = new { + Exception = new String[] { exception.Message } + } + }); + + return context.Response.WriteAsync(message); } } } diff --git a/src/Web/DevHive.Web/appsettings.json b/src/Web/DevHive.Web/appsettings.json index fcf9805..036af82 100644 --- a/src/Web/DevHive.Web/appsettings.json +++ b/src/Web/DevHive.Web/appsettings.json @@ -5,7 +5,7 @@ "audience": "" }, "ConnectionStrings": { - "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;" + "DEV": "Server=localhost;Port=5432;Database=DevHive_API;User Id=postgres;Password=;" }, "Cloud": { "cloudName": "devhive", |
