aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-05 19:00:24 +0200
committertranstrike <transtrike@gmail.com>2021-02-05 19:00:24 +0200
commit75eeb4358e746d887677903052ed4bd5ca176f4d (patch)
tree9f9b9eb0103d61f488c08fa4b4b5f308ca9ab35a
parent51e157d1e1dc57ea2ba9c29b355fa7982a29bebe (diff)
parent4eb5ccdfc8ee4ac9795c48c701e565dbe2b641f9 (diff)
downloadDevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar
DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar.gz
DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.zip
Merge branch 'dev' of github.com:Team-Kaleidoscope/DevHive into dev
-rw-r--r--README.md55
-rw-r--r--screenshots/admin-panel.pngbin0 -> 50920 bytes
-rw-r--r--screenshots/another-user-logged-in.pngbin0 -> 115600 bytes
-rw-r--r--screenshots/comment-page.pngbin0 -> 21475 bytes
-rw-r--r--screenshots/creating-post.pngbin0 -> 30921 bytes
-rw-r--r--screenshots/edit.pngbin0 -> 32121 bytes
-rw-r--r--screenshots/feed.pngbin0 -> 36789 bytes
-rw-r--r--screenshots/login.pngbin0 -> 20462 bytes
-rw-r--r--screenshots/post-page-with-comments.pngbin0 -> 53849 bytes
-rw-r--r--screenshots/post-page.pngbin0 -> 37766 bytes
-rw-r--r--screenshots/register.pngbin0 -> 25905 bytes
-rw-r--r--screenshots/your-profile-page.pngbin0 -> 50603 bytes
-rw-r--r--screenshots/your-settings-page.pngbin0 -> 41581 bytes
-rw-r--r--src/DevHive.Angular/src/app/components/feed/feed.component.ts4
-rw-r--r--src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.css0
-rw-r--r--src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.html8
-rw-r--r--src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.ts24
-rw-r--r--src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html4
-rw-r--r--src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts4
-rw-r--r--src/DevHive.Angular/src/app/components/post/post.component.css5
-rw-r--r--src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.css1
-rw-r--r--src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html3
-rw-r--r--src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts7
-rw-r--r--src/DevHive.Angular/src/app/components/profile/profile.component.ts2
-rw-r--r--src/DevHive.Angular/src/app/components/register/register.component.css6
-rw-r--r--src/DevHive.Data/DevHiveContext.cs39
-rw-r--r--src/DevHive.Data/Interfaces/Models/IPost.cs3
-rw-r--r--src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs4
-rw-r--r--src/DevHive.Data/Migrations/20210131114401_Database_Creation.Designer.cs561
-rw-r--r--src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.Designer.cs575
-rw-r--r--src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.cs45
-rw-r--r--src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.Designer.cs597
-rw-r--r--src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.cs77
-rw-r--r--src/DevHive.Data/Migrations/20210201112614_Rating_Rename.Designer.cs597
-rw-r--r--src/DevHive.Data/Migrations/20210201112614_Rating_Rename.cs78
-rw-r--r--src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.Designer.cs597
-rw-r--r--src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.cs97
-rw-r--r--src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.Designer.cs611
-rw-r--r--src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.cs45
-rw-r--r--src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.Designer.cs614
-rw-r--r--src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.cs25
-rw-r--r--src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.Designer.cs601
-rw-r--r--src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.cs137
-rw-r--r--src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.Designer.cs599
-rw-r--r--src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.cs61
-rw-r--r--src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.Designer.cs599
-rw-r--r--src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.cs61
-rw-r--r--src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.Designer.cs603
-rw-r--r--src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.cs17
-rw-r--r--src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.cs17
-rw-r--r--src/DevHive.Data/Migrations/20210203071720_ProfilePicture.cs52
-rw-r--r--src/DevHive.Data/Migrations/20210205140955_rating.Designer.cs (renamed from src/DevHive.Data/Migrations/20210203071720_ProfilePicture.Designer.cs)40
-rw-r--r--src/DevHive.Data/Migrations/20210205140955_rating.cs (renamed from src/DevHive.Data/Migrations/20210131114401_Database_Creation.cs)195
-rw-r--r--src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.Designer.cs (renamed from src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.Designer.cs)110
-rw-r--r--src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.cs51
-rw-r--r--src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs70
-rw-r--r--src/DevHive.Data/Models/Post.cs6
-rw-r--r--src/DevHive.Data/Models/Rating.cs8
-rw-r--r--src/DevHive.Data/Models/User.cs2
-rw-r--r--src/DevHive.Data/RelationModels/PostAttachments.cs16
-rw-r--r--src/DevHive.Data/RelationModels/UserRate.cs4
-rw-r--r--src/DevHive.Data/Repositories/CommentRepository.cs3
-rw-r--r--src/DevHive.Data/Repositories/FeedRepository.cs18
-rw-r--r--src/DevHive.Data/Repositories/LanguageRepository.cs3
-rw-r--r--src/DevHive.Data/Repositories/PostRepository.cs20
-rw-r--r--src/DevHive.Data/Repositories/RatingRepository.cs15
-rw-r--r--src/DevHive.Data/Repositories/TechnologyRepository.cs3
-rw-r--r--src/DevHive.Services/Services/CommentService.cs17
-rw-r--r--src/DevHive.Services/Services/FeedService.cs8
-rw-r--r--src/DevHive.Services/Services/PostService.cs44
-rw-r--r--src/DevHive.Services/Services/UserService.cs37
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/FeedRepository.Tests.cs4
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/PostRepository.Tests.cs31
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs28
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/CommentService.Tests.cs262
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/FeedService.Tests.cs310
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/PostService.Tests.cs261
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs6
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/UserService.Tests.cs21
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/CommentController.Tests.cs256
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs98
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/PostController.Tests.cs248
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/RoleController.Tests.cs201
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs12
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/UserController.Tests.cs257
-rw-r--r--src/DevHive.Web/Configurations/Mapping/FeedMappings.cs2
-rw-r--r--src/DevHive.Web/Controllers/FeedController.cs1
-rw-r--r--src/DevHive.Web/Controllers/PostController.cs4
-rw-r--r--src/DevHive.Web/Models/Feed/ReadPageWebModel.cs2
89 files changed, 2247 insertions, 7862 deletions
diff --git a/README.md b/README.md
index 6fbd5d3..eca6aef 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,24 @@
DevHive is the social network solution for programmers. In it you can make posts to share with your friends, comment and more.
-It's built with ASP.NET Core as a back-end and Angular as a front-end. For more technical information, you can refer to the [Wiki](https://github.com/Team-Kaleidoscope/DevHive/wiki).
+It's built with [`ASP.NET Core`](https://docs.microsoft.com/en-us/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-5.0) as a back-end and [`Angular`](https://angular.io/) as a front-end. For more technical information, you can refer to the [Wiki](https://github.com/Team-Kaleidoscope/DevHive/wiki).
+
+In the Wiki you can also find our [Privacy Policy](https://github.com/Team-Kaleidoscope/DevHive/wiki/Privacy-Policy).
+
+## Contents:
+- [Setting up locally](#setting-up-locally)
+ - [Prerequisites](#prerequisites)
+ - [Getting started with the database](#getting-started-with-the-database)
+ - [Starting up the API](#starting-up-the-api)
+ - [Starting up the Front-end](#starting-up-the-front-end)
+ - [Important notes](#important-notes)
+- [Screenshots](#screenshots)
## Setting up locally
-DevHive can be easily self-hosted on your computer or server. There currently aren't any demo instances, so the only way to see it for yourself it to set it up.
+There currently aren't any demo instances, so the only way to try it out for yourself it to set it up locally, on a computer or server. In this section are explained the steps to do so.
-This tutorial is geared towards Linux-based systems.
+The steps are oriented around Linux-based systems.
### Prerequisites
@@ -16,14 +27,14 @@ There are some things you need to setup before even downloading the app.
Back-end (API) tools:
- [`dotnet 5.0`](https://docs.microsoft.com/en-us/dotnet/core/install/linux) or later
-- [`Entity Framework Core tool 5.0.2`](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) or later
+- [`Entity Framework Core tool 5.0.2`](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) or greater
- if you've already installed `dotnet`, you can just run this command `dotnet tool install dotnet-ef -g`
-- [`postresql 13.1`](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-20-04) or later (older versions might work, but haven't been tested)
+- [`postresql 13.1`](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-20-04) or greater (older versions might work, but haven't been tested)
- Fedora users could also refer to [this](https://computingforgeeks.com/how-to-install-postgresql-12-on-fedora/) guide
- Arch users can refer to the [ArchWiki](https://wiki.archlinux.org/index.php/PostgreSQL)
Front-end tools:
-- [`Angular CLI 11.0`](https://www.tecmint.com/install-angular-cli-on-linux/) or later (older versions might work, but haven't been tested)
+- [`Angular CLI 11.0.6`](https://www.tecmint.com/install-angular-cli-on-linux/) or greater (older versions might work, but haven't been tested)
### Getting started with the database
@@ -38,24 +49,40 @@ After installing all of the tools and setting up the database, you should have a
1. Navigate to the `src/DevHive.Web` folder
2. Edit the `appsettings.json` file, under "ConnectionStrings", type in the values, you setup in `ConnectionString.json` in `DevHive.Data`
- - On the third row there is a "Secret", it's used for encryption of User password, you can change it **but it must be made up of 64 letters and number!**
+ - On the third row there is a "Secret" field, it's used for encryption of User passwords, you can change it **but it must be made up of 64 letters and number!**
- There are also some cloud values that you can change. Currently, the project uses [Cloudinary](https://cloudinary.com/) as a place for uploading files. If you wish, you can setup your own account there, otherwise file uploading won't work.
3. Run `dotnet run` in the `DevHive.Web` folder
- feel free to [run the command in background](https://linuxize.com/post/how-to-run-linux-commands-in-background/) or [create a systemd service](https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6)
-If everything went well, you can now access the API on `http://localhost:5000/api` with something like [Postman](https://www.postman.com/) or the FOSS [Insomnia Designer](https://github.com/Kong/insomnia). Refer to the [API Endpoints](https://github.com/Team-Kaleidoscope/DevHive/wiki/API-Endpoints) page in the Wiki.
+If everything went well, you can now access the API on `http://localhost:5000/api` with something like [Postman](https://www.postman.com/) or the FOSS alternative [Insomnia Designer](https://github.com/Kong/insomnia). On where to send requests, refer to the [API Endpoints](https://github.com/Team-Kaleidoscope/DevHive/wiki/API-Endpoints) page in the Wiki.
### Starting up the Front-end
1. Navigate to `src/DevHive.Angular`
-2. Run `npm install`
-3. Run `ng serve`
+2. Run `npm install` to install all front-end packages
+3. Run `ng serve` to start up the front-end
- as with the API, you can [run the command in background](https://linuxize.com/post/how-to-run-linux-commands-in-background/) or [create a systemd service](https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6)
-If nothing broke, you can now access the front-end from `http://localhost:4200`. Also, don't forget that the API needs to be running *at the same time*, otherwise you won't get beyond the login and register screens!
+If everything went smoothly, you will be able to access the front-end from `http://localhost:4200`. Also, don't forget that the API needs to be running *at the same time*, otherwise you won't get beyond the Login and Register pages!
+
+### Important notes
+
+You can change on what port the API is ran, by changing the `HTTP_PORT` constant in `src/DevHive.Web/Program.cs`. If you do so, you **must** also update the front-end, because by default it will try to send requests to `http://localhost:5000`.
+- Go to `src/DevHive.Angular/src/app` and edit the `app-constants.module.ts` file, on the second row you're gonna see the variable `BASE_API_URL`, change it accoring to your API modifications.
-## Important notes
+You can change on what port the front-end is ran, by issuing the serve command with the `--port` parameter: `ng serve --port 5001`. But, **don't run it with the `--ssl` parameter!** SSL isn't supported yet and you'll have issues trying to use it! If you really need ssl, using a [reverse proxy](https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/) might be a viable alternative.
-You can change on what port the API is ran, by changing the `HTTP_PORT` constant in `src/DevHive.Web/Program.cs`. If you do so, you **must** also update the front-end, because by default it will try to send requests to port 5000. Go to `src/DevHive.Angular/src/app` and edit the `app-constants.module.ts` file, on the second row you're gonna see the variable `BASE_API_URL`, change it accoring to your API modifications.
+## Screenshots
-You can change on what port the Front-end is ran, by issueing the serve command with the `--port` parameter: `ng serve --port 5001`. But, **don't run it with the `--ssl` parameter!** SSL isn't supported yet, so it will throw errors! As an alternative, if you need ssl, is using a [reverse proxy](https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/).
+![](./screenshots/register.png)
+![](./screenshots/login.png)
+![](./screenshots/feed.png)
+![](./screenshots/creating-post.png)
+![](./screenshots/your-profile-page.png)
+![](./screenshots/your-settings-page.png)
+![](./screenshots/edit.png)
+![](./screenshots/post-page.png)
+![](./screenshots/post-page-with-comments.png)
+![](./screenshots/comment-page.png)
+![](./screenshots/another-user-logged-in.png)
+![](./screenshots/admin-panel.png)
diff --git a/screenshots/admin-panel.png b/screenshots/admin-panel.png
new file mode 100644
index 0000000..d8f1b3f
--- /dev/null
+++ b/screenshots/admin-panel.png
Binary files differ
diff --git a/screenshots/another-user-logged-in.png b/screenshots/another-user-logged-in.png
new file mode 100644
index 0000000..67f34e1
--- /dev/null
+++ b/screenshots/another-user-logged-in.png
Binary files differ
diff --git a/screenshots/comment-page.png b/screenshots/comment-page.png
new file mode 100644
index 0000000..f517dc9
--- /dev/null
+++ b/screenshots/comment-page.png
Binary files differ
diff --git a/screenshots/creating-post.png b/screenshots/creating-post.png
new file mode 100644
index 0000000..58081f2
--- /dev/null
+++ b/screenshots/creating-post.png
Binary files differ
diff --git a/screenshots/edit.png b/screenshots/edit.png
new file mode 100644
index 0000000..e448af3
--- /dev/null
+++ b/screenshots/edit.png
Binary files differ
diff --git a/screenshots/feed.png b/screenshots/feed.png
new file mode 100644
index 0000000..a456e2a
--- /dev/null
+++ b/screenshots/feed.png
Binary files differ
diff --git a/screenshots/login.png b/screenshots/login.png
new file mode 100644
index 0000000..378a682
--- /dev/null
+++ b/screenshots/login.png
Binary files differ
diff --git a/screenshots/post-page-with-comments.png b/screenshots/post-page-with-comments.png
new file mode 100644
index 0000000..d464053
--- /dev/null
+++ b/screenshots/post-page-with-comments.png
Binary files differ
diff --git a/screenshots/post-page.png b/screenshots/post-page.png
new file mode 100644
index 0000000..96428ef
--- /dev/null
+++ b/screenshots/post-page.png
Binary files differ
diff --git a/screenshots/register.png b/screenshots/register.png
new file mode 100644
index 0000000..70448b1
--- /dev/null
+++ b/screenshots/register.png
Binary files differ
diff --git a/screenshots/your-profile-page.png b/screenshots/your-profile-page.png
new file mode 100644
index 0000000..3701ea3
--- /dev/null
+++ b/screenshots/your-profile-page.png
Binary files differ
diff --git a/screenshots/your-settings-page.png b/screenshots/your-settings-page.png
new file mode 100644
index 0000000..61e39e6
--- /dev/null
+++ b/screenshots/your-settings-page.png
Binary files differ
diff --git a/src/DevHive.Angular/src/app/components/feed/feed.component.ts b/src/DevHive.Angular/src/app/components/feed/feed.component.ts
index 8e9ffbc..b412b3c 100644
--- a/src/DevHive.Angular/src/app/components/feed/feed.component.ts
+++ b/src/DevHive.Angular/src/app/components/feed/feed.component.ts
@@ -101,10 +101,14 @@ export class FeedComponent implements OnInit {
createPost(): void {
const postMessage = this.createPostFormGroup.get('newPostMessage')?.value;
+ this.dataArrived = false;
this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe(
(result: object) => {
this.goToProfile();
+ },
+ (err: HttpErrorResponse) => {
+ this.dataArrived = true;
}
);
}
diff --git a/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.css b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.css
diff --git a/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.html b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.html
new file mode 100644
index 0000000..7392a21
--- /dev/null
+++ b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.html
@@ -0,0 +1,8 @@
+<div class="kaleidoscope">
+ <ng-container *ngComponentOutlet="component"></ng-container>
+ <app-login *ngIf="logged!"></app-login>
+ <app-register *ngIf="!logged!"></app-register>
+ <!-- <app-feed></app-feed> -->
+ <script>var logged = false;</script>
+ <!-- to be fixed tomorow -->
+</div> \ No newline at end of file
diff --git a/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.ts b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.ts
new file mode 100644
index 0000000..1c5cda1
--- /dev/null
+++ b/src/DevHive.Angular/src/app/components/kaleidoscope/kaleidoscope.component.ts
@@ -0,0 +1,24 @@
+import { Component, OnInit } from '@angular/core';
+import { LoginComponent } from '../login/login.component';
+
+@Component({
+ selector: 'app-kaleidoscope',
+ templateUrl: './kaleidoscope.component.html',
+ styleUrls: ['./kaleidoscope.component.css']
+})
+export class KaleidoscopeComponent implements OnInit {
+
+ public _component: Component;
+
+ constructor(loginComponent: LoginComponent) {
+ this._component = loginComponent as Component;
+ }
+
+ ngOnInit(): void {
+
+ }
+
+ assignComponent(component: Component) {
+ this._component = component;
+ }
+}
diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
index a8ebce7..4d381d1 100644
--- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
+++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
@@ -10,8 +10,8 @@
</div>
<div class="show-full-attachment" *ngIf="showFull" (click)="toggleShowFull()">
- <img class="attachment-img" *ngIf="paramURL.includes('image')" src="{{paramURL}}">
- <a class="attachment-download submit-btn" *ngIf="!paramURL.includes('image')" href="{{paramURL}}">Download attachment</a>
+ <img class="attachment-img" *ngIf="isImage" src="{{paramURL}}">
+ <a class="attachment-download submit-btn" *ngIf="!isImage" href="{{paramURL}}">Download attachment</a>
<div class="close">
</div>
diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
index 6c468b0..1d00def 100644
--- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
+++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
@@ -7,6 +7,7 @@ import { Component, Input, OnInit } from '@angular/core';
})
export class PostAttachmentComponent implements OnInit {
@Input() paramURL: string;
+ public isImage = false;
public showFull = false;
public fileName: string;
public fileType: string;
@@ -15,7 +16,8 @@ export class PostAttachmentComponent implements OnInit {
{ }
ngOnInit(): void {
- this.fileType = this.paramURL.includes('image') ? 'img' : 'raw';
+ this.isImage = this.paramURL.includes('image') && !this.paramURL.endsWith('pdf');
+ this.fileType = this.isImage ? 'img' : 'raw';
this.fileName = this.paramURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment';
}
diff --git a/src/DevHive.Angular/src/app/components/post/post.component.css b/src/DevHive.Angular/src/app/components/post/post.component.css
index 07d931f..1b88c7d 100644
--- a/src/DevHive.Angular/src/app/components/post/post.component.css
+++ b/src/DevHive.Angular/src/app/components/post/post.component.css
@@ -76,6 +76,11 @@ hr {
/* Rating */
+/* Temporary, until ratings are implemented fully */
+.rating {
+ display: none !important;
+}
+
.rating {
display: flex;
flex-direction: column;
diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.css b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.css
index 27d1584..1c07d9f 100644
--- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.css
+++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.css
@@ -42,6 +42,7 @@ hr {
align-items: center;
justify-content: center;
padding: 0 .5em;
+ flex-wrap: wrap;
}
#profile-picture {
diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html
index d87c35c..502697d 100644
--- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html
+++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html
@@ -3,6 +3,7 @@
<div id="content" *ngIf="dataArrived">
<nav id="navigation">
<button class="submit-btn" (click)="goToProfile()">ᐊ Back</button>
+ <button class="submit-btn" (click)="navigateToAdminPanel()" *ngIf="isAdminUser">Panel</button>
<button class="submit-btn" (click)="logout()">Logout</button>
</nav>
<hr>
@@ -11,7 +12,7 @@
<img id="profile-picture" class="round-image" [src]="user.profilePictureURL">
<div id="submit-file">
<div id="upload-file" class="submit-btn">
- <input type="file" formControlName="fileUpload" (change)="onFileUpload($event)">
+ <input type="file" accept="image/*" formControlName="fileUpload" (change)="onFileUpload($event)">
</div>
<button class="submit-btn" type="submit">Update profile picture</button>
</div>
diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
index 463b980..a484665 100644
--- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
+++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
@@ -13,6 +13,7 @@ import { Language } from 'src/models/language';
import { Technology } from 'src/models/technology';
import { TokenService } from 'src/app/services/token.service';
import { Title } from '@angular/platform-browser';
+import { AppConstants } from 'src/app/app-constants.module';
@Component({
selector: 'app-profile-settings',
@@ -24,6 +25,7 @@ export class ProfileSettingsComponent implements OnInit {
@ViewChild(ErrorBarComponent) private _errorBar: ErrorBarComponent;
@ViewChild(SuccessBarComponent) private _successBar: SuccessBarComponent;
private _urlUsername: string;
+ public isAdminUser = false;
public dataArrived = false;
public deleteAccountConfirm = false;
public showLanguages = false;
@@ -51,6 +53,7 @@ export class ProfileSettingsComponent implements OnInit {
this._userService.getUserByUsernameRequest(this._urlUsername).subscribe(
(res: object) => {
Object.assign(this.user, res);
+ this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME);
this.finishUserLoading();
},
(err: HttpErrorResponse) => {
@@ -262,6 +265,10 @@ export class ProfileSettingsComponent implements OnInit {
this._router.navigate([this._router.url.substring(0, this._router.url.length - 9)]);
}
+ navigateToAdminPanel(): void {
+ this._router.navigate(['/admin-panel']);
+ }
+
logout(): void {
this._tokenService.logoutUserFromSessionStorage();
this.goToProfile();
diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.ts b/src/DevHive.Angular/src/app/components/profile/profile.component.ts
index f364c0d..a60250c 100644
--- a/src/DevHive.Angular/src/app/components/profile/profile.component.ts
+++ b/src/DevHive.Angular/src/app/components/profile/profile.component.ts
@@ -53,6 +53,7 @@ export class ProfileComponent implements OnInit {
this._userService.getUserByUsernameRequest(this._urlUsername).subscribe(
(res: object) => {
Object.assign(this.user, res);
+ this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME);
this.loadLanguages();
},
(err: HttpErrorResponse) => {
@@ -117,7 +118,6 @@ export class ProfileComponent implements OnInit {
this.isTheLoggedInUser = true;
}
this.dataArrived = true;
- this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME);
},
(err: HttpErrorResponse) => {
this.logout();
diff --git a/src/DevHive.Angular/src/app/components/register/register.component.css b/src/DevHive.Angular/src/app/components/register/register.component.css
index 653b590..93d8006 100644
--- a/src/DevHive.Angular/src/app/components/register/register.component.css
+++ b/src/DevHive.Angular/src/app/components/register/register.component.css
@@ -8,6 +8,12 @@ form {
width: 100%;
}
+@media screen and (max-height: 630px) {
+ #content {
+ height: fit-content !important;
+ }
+}
+
#content hr {
width: 100%;
border: 1px solid black;
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index b3ebd73..0b81f92 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -14,6 +14,7 @@ namespace DevHive.Data
public DbSet<Technology> Technologies { get; set; }
public DbSet<Language> Languages { get; set; }
public DbSet<Post> Posts { get; set; }
+ public DbSet<PostAttachments> PostAttachments { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<UserFriend> UserFriends { get; set; }
public DbSet<Rating> Rating { get; set; }
@@ -82,6 +83,11 @@ namespace DevHive.Data
.HasMany(x => x.Comments)
.WithOne(x => x.Post);
+ /* Post attachments */
+ builder.Entity<PostAttachments>()
+ .HasOne(x => x.Post)
+ .WithMany(x => x.Attachments);
+
/* Comment */
builder.Entity<Comment>()
.HasOne(x => x.Post)
@@ -95,31 +101,28 @@ namespace DevHive.Data
builder.Entity<Rating>()
.HasKey(x => x.Id);
- // builder.Entity<Rating>()
- // .HasOne(x => x.Post)
- // .WithOne(x => x.Rating)
- // .HasForeignKey<Post>(x => x.RatingId);
-
- // builder.Entity<Post>()
- // .HasOne(x => x.Rating)
- // .WithOne(x => x.Post);
+ builder.Entity<Rating>()
+ .HasOne(x => x.Post)
+ .WithOne(x => x.Rating)
+ .HasForeignKey<Rating>(x => x.PostId);
- // builder.Entity<Rating>()
- // .HasMany(x => x.UsersThatRated);
+ builder.Entity<Post>()
+ .HasOne(x => x.Rating)
+ .WithOne(x => x.Post);
- // /* User Rated Posts */
+ /* 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.User)
+ .WithMany(x => x.RatedPosts);
- // builder.Entity<RatedPost>()
- // .HasOne(x => x.Post);
+ builder.Entity<RatedPost>()
+ .HasOne(x => x.Post);
- // builder.Entity<User>()
- // .HasMany(x => x.RatedPosts);
+ builder.Entity<User>()
+ .HasMany(x => x.RatedPosts);
base.OnModelCreating(builder);
}
diff --git a/src/DevHive.Data/Interfaces/Models/IPost.cs b/src/DevHive.Data/Interfaces/Models/IPost.cs
index 5031a05..712d955 100644
--- a/src/DevHive.Data/Interfaces/Models/IPost.cs
+++ b/src/DevHive.Data/Interfaces/Models/IPost.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using DevHive.Data.Models;
+using DevHive.Data.RelationModels;
namespace DevHive.Data.Interfaces.Models
{
@@ -16,6 +17,6 @@ namespace DevHive.Data.Interfaces.Models
// Rating Rating { get; set; }
- List<string> FileUrls { get; set; }
+ List<PostAttachments> Attachments { get; set; }
}
}
diff --git a/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs b/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs
index 7b99e0e..f77f301 100644
--- a/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs
+++ b/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs
@@ -7,7 +7,7 @@ namespace DevHive.Data.Interfaces.Repositories
{
public interface IRatingRepository : IRepository<Rating>
{
- Task<Rating> GetByPostId(Guid postId);
- Task<int> GetRating(Guid postId);
+ Task<Rating> GetRatingByPostId(Guid postId);
+ Task<bool> UserRatedPost(Guid userId, Guid postId);
}
}
diff --git a/src/DevHive.Data/Migrations/20210131114401_Database_Creation.Designer.cs b/src/DevHive.Data/Migrations/20210131114401_Database_Creation.Designer.cs
deleted file mode 100644
index cbbd435..0000000
--- a/src/DevHive.Data/Migrations/20210131114401_Database_Creation.Designer.cs
+++ /dev/null
@@ -1,561 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210131114401_Database_Creation")]
- partial class Database_Creation
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Comments");
-
- b.Navigation("Friends");
-
- b.Navigation("Posts");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.Designer.cs b/src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.Designer.cs
deleted file mode 100644
index 00e4fbd..0000000
--- a/src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.Designer.cs
+++ /dev/null
@@ -1,575 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201105546_Rating_Implemented")]
- partial class Rating_Implemented
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany("RatedPosts")
- .HasForeignKey("UserId");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
- });
-
- 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/DevHive.Data/Migrations/20210201105546_Rating_Implemented.cs b/src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.cs
deleted file mode 100644
index ae7ef8e..0000000
--- a/src/DevHive.Data/Migrations/20210201105546_Rating_Implemented.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_Implemented : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<Guid>(
- name: "UserId",
- table: "Rating",
- type: "uuid",
- nullable: true);
-
- 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);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Rating_AspNetUsers_UserId",
- table: "Rating");
-
- migrationBuilder.DropIndex(
- name: "IX_Rating_UserId",
- table: "Rating");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "Rating");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.Designer.cs b/src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.Designer.cs
deleted file mode 100644
index 0aea5ce..0000000
--- a/src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.Designer.cs
+++ /dev/null
@@ -1,597 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201110523_Rating_Init_Configuration")]
- partial class Rating_Init_Configuration
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.RatedPosts", 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.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.RatedPosts", 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.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
- });
-
- 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/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.cs b/src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.cs
deleted file mode 100644
index a5a4a72..0000000
--- a/src/DevHive.Data/Migrations/20210201110523_Rating_Init_Configuration.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_Init_Configuration : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Rating_AspNetUsers_UserId",
- table: "Rating");
-
- migrationBuilder.DropIndex(
- name: "IX_Rating_UserId",
- table: "Rating");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "Rating");
-
- 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.CreateIndex(
- name: "IX_RatedPosts_PostId",
- table: "RatedPosts",
- column: "PostId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "RatedPosts");
-
- migrationBuilder.AddColumn<Guid>(
- name: "UserId",
- table: "Rating",
- type: "uuid",
- nullable: true);
-
- 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);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201112614_Rating_Rename.Designer.cs b/src/DevHive.Data/Migrations/20210201112614_Rating_Rename.Designer.cs
deleted file mode 100644
index a64baa1..0000000
--- a/src/DevHive.Data/Migrations/20210201112614_Rating_Rename.Designer.cs
+++ /dev/null
@@ -1,597 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201112614_Rating_Rename")]
- partial class Rating_Rename
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.RatedPost", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("PostId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "PostId");
-
- b.HasIndex("PostId");
-
- b.ToTable("RatedPost");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
- });
-
- 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/DevHive.Data/Migrations/20210201112614_Rating_Rename.cs b/src/DevHive.Data/Migrations/20210201112614_Rating_Rename.cs
deleted file mode 100644
index 1fb4743..0000000
--- a/src/DevHive.Data/Migrations/20210201112614_Rating_Rename.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_Rename : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "RatedPosts");
-
- migrationBuilder.CreateTable(
- name: "RatedPost",
- columns: table => new
- {
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- PostId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_RatedPost", x => new { x.UserId, x.PostId });
- table.ForeignKey(
- name: "FK_RatedPost_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_RatedPost_Posts_PostId",
- column: x => x.PostId,
- principalTable: "Posts",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_RatedPost_PostId",
- table: "RatedPost",
- column: "PostId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "RatedPost");
-
- 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.CreateIndex(
- name: "IX_RatedPosts_PostId",
- table: "RatedPosts",
- column: "PostId");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.Designer.cs b/src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.Designer.cs
deleted file mode 100644
index 82e08a5..0000000
--- a/src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.Designer.cs
+++ /dev/null
@@ -1,597 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201113039_Rating_Rename_2")]
- partial class Rating_Rename_2
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
- });
-
- 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/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.cs b/src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.cs
deleted file mode 100644
index 9dc87cf..0000000
--- a/src/DevHive.Data/Migrations/20210201113039_Rating_Rename_2.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_Rename_2 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_RatedPost_AspNetUsers_UserId",
- table: "RatedPost");
-
- migrationBuilder.DropForeignKey(
- name: "FK_RatedPost_Posts_PostId",
- table: "RatedPost");
-
- migrationBuilder.DropPrimaryKey(
- name: "PK_RatedPost",
- table: "RatedPost");
-
- migrationBuilder.RenameTable(
- name: "RatedPost",
- newName: "RatedPosts");
-
- migrationBuilder.RenameIndex(
- name: "IX_RatedPost_PostId",
- table: "RatedPosts",
- newName: "IX_RatedPosts_PostId");
-
- migrationBuilder.AddPrimaryKey(
- name: "PK_RatedPosts",
- table: "RatedPosts",
- columns: new[] { "UserId", "PostId" });
-
- migrationBuilder.AddForeignKey(
- name: "FK_RatedPosts_AspNetUsers_UserId",
- table: "RatedPosts",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_RatedPosts_Posts_PostId",
- table: "RatedPosts",
- column: "PostId",
- principalTable: "Posts",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_RatedPosts_AspNetUsers_UserId",
- table: "RatedPosts");
-
- migrationBuilder.DropForeignKey(
- name: "FK_RatedPosts_Posts_PostId",
- table: "RatedPosts");
-
- migrationBuilder.DropPrimaryKey(
- name: "PK_RatedPosts",
- table: "RatedPosts");
-
- migrationBuilder.RenameTable(
- name: "RatedPosts",
- newName: "RatedPost");
-
- migrationBuilder.RenameIndex(
- name: "IX_RatedPosts_PostId",
- table: "RatedPost",
- newName: "IX_RatedPost_PostId");
-
- migrationBuilder.AddPrimaryKey(
- name: "PK_RatedPost",
- table: "RatedPost",
- columns: new[] { "UserId", "PostId" });
-
- migrationBuilder.AddForeignKey(
- name: "FK_RatedPost_AspNetUsers_UserId",
- table: "RatedPost",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_RatedPost_Posts_PostId",
- table: "RatedPost",
- column: "PostId",
- principalTable: "Posts",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.Designer.cs b/src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.Designer.cs
deleted file mode 100644
index 849715a..0000000
--- a/src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.Designer.cs
+++ /dev/null
@@ -1,611 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201113809_Rating_Many-To-Many")]
- partial class Rating_ManyToMany
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<Guid?>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("RatingId");
-
- b.HasIndex("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.HasOne("DevHive.Data.Models.Rating", null)
- .WithMany("UsersThatRated")
- .HasForeignKey("RatingId");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
-
- b.Navigation("UsersThatRated");
- });
-
- 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/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.cs b/src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.cs
deleted file mode 100644
index 4ec0bd7..0000000
--- a/src/DevHive.Data/Migrations/20210201113809_Rating_Many-To-Many.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_ManyToMany : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<Guid>(
- name: "RatingId",
- table: "AspNetUsers",
- type: "uuid",
- nullable: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_RatingId",
- table: "AspNetUsers",
- column: "RatingId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_AspNetUsers_Rating_RatingId",
- table: "AspNetUsers",
- column: "RatingId",
- principalTable: "Rating",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_AspNetUsers_Rating_RatingId",
- table: "AspNetUsers");
-
- migrationBuilder.DropIndex(
- name: "IX_AspNetUsers_RatingId",
- table: "AspNetUsers");
-
- migrationBuilder.DropColumn(
- name: "RatingId",
- table: "AspNetUsers");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.Designer.cs b/src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.Designer.cs
deleted file mode 100644
index e31576f..0000000
--- a/src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.Designer.cs
+++ /dev/null
@@ -1,614 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201120913_Rating_Many-To-Many_Configured")]
- partial class Rating_ManyToMany_Configured
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<Guid>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.HasIndex("CreatorId");
-
- b.HasIndex("RatingId")
- .IsUnique();
-
- b.ToTable("Posts");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Dislikes")
- .HasColumnType("integer");
-
- b.Property<int>("Likes")
- .HasColumnType("integer");
-
- b.Property<Guid>("PostId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<Guid?>("RatingId")
- .HasColumnType("uuid");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("RatingId");
-
- b.HasIndex("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.HasOne("DevHive.Data.Models.Rating", "Rating")
- .WithOne("Post")
- .HasForeignKey("DevHive.Data.Models.Post", "RatingId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Creator");
-
- b.Navigation("Rating");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.HasOne("DevHive.Data.Models.Rating", null)
- .WithMany("UsersThatRated")
- .HasForeignKey("RatingId");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
- {
- b.Navigation("Post");
-
- b.Navigation("UsersThatRated");
- });
-
- 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/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.cs b/src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.cs
deleted file mode 100644
index 7800d3a..0000000
--- a/src/DevHive.Data/Migrations/20210201120913_Rating_Many-To-Many_Configured.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_ManyToMany_Configured : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<Guid>(
- name: "PostId",
- table: "Rating",
- type: "uuid",
- nullable: false,
- defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "PostId",
- table: "Rating");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.Designer.cs b/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.Designer.cs
deleted file mode 100644
index 17c80e0..0000000
--- a/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.Designer.cs
+++ /dev/null
@@ -1,601 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210201140246_Rating_Frozen")]
- partial class Rating_Frozen
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- 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.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Rate")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriends", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<bool>("Rate")
- .HasColumnType("boolean");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("UserRates");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.RelationModels.RatedPost", b =>
- {
- b.HasOne("DevHive.Data.Models.Post", "Post")
- .WithMany()
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Post");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("Friends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Comments");
-
- b.Navigation("Friends");
-
- b.Navigation("Posts");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.cs b/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.cs
deleted file mode 100644
index 49b0809..0000000
--- a/src/DevHive.Data/Migrations/20210201140246_Rating_Frozen.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Rating_Frozen : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_AspNetUsers_Rating_RatingId",
- table: "AspNetUsers");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Posts_Rating_RatingId",
- table: "Posts");
-
- migrationBuilder.DropIndex(
- name: "IX_Posts_RatingId",
- table: "Posts");
-
- migrationBuilder.DropIndex(
- name: "IX_AspNetUsers_RatingId",
- table: "AspNetUsers");
-
- migrationBuilder.DropColumn(
- name: "Dislikes",
- table: "Rating");
-
- migrationBuilder.DropColumn(
- name: "PostId",
- table: "Rating");
-
- migrationBuilder.DropColumn(
- name: "RatingId",
- table: "Posts");
-
- migrationBuilder.DropColumn(
- name: "RatingId",
- table: "AspNetUsers");
-
- migrationBuilder.RenameColumn(
- name: "Likes",
- table: "Rating",
- newName: "Rate");
-
- migrationBuilder.CreateTable(
- name: "UserRates",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- UserId = table.Column<Guid>(type: "uuid", nullable: true),
- Rate = table.Column<bool>(type: "boolean", nullable: false)
- },
- 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);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_UserRates_UserId",
- table: "UserRates",
- column: "UserId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "UserRates");
-
- migrationBuilder.RenameColumn(
- name: "Rate",
- table: "Rating",
- newName: "Likes");
-
- migrationBuilder.AddColumn<int>(
- name: "Dislikes",
- table: "Rating",
- type: "integer",
- nullable: false,
- defaultValue: 0);
-
- migrationBuilder.AddColumn<Guid>(
- name: "PostId",
- table: "Rating",
- type: "uuid",
- nullable: false,
- defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
-
- migrationBuilder.AddColumn<Guid>(
- name: "RatingId",
- table: "Posts",
- type: "uuid",
- nullable: false,
- defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
-
- migrationBuilder.AddColumn<Guid>(
- name: "RatingId",
- table: "AspNetUsers",
- type: "uuid",
- nullable: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_Posts_RatingId",
- table: "Posts",
- column: "RatingId",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_RatingId",
- table: "AspNetUsers",
- column: "RatingId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_AspNetUsers_Rating_RatingId",
- table: "AspNetUsers",
- column: "RatingId",
- principalTable: "Rating",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Posts_Rating_RatingId",
- table: "Posts",
- column: "RatingId",
- principalTable: "Rating",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.Designer.cs b/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.Designer.cs
deleted file mode 100644
index 438a73c..0000000
--- a/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.Designer.cs
+++ /dev/null
@@ -1,599 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210202225728_SomeBullshit_Implemented")]
- partial class SomeBullshit_Implemented
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- 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.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Rate")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriend", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<bool>("Rate")
- .HasColumnType("boolean");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("UserRates");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.RelationModels.RatedPost", b =>
- {
- b.HasOne("DevHive.Data.Models.Post", "Post")
- .WithMany()
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Post");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriend", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Comments");
-
- b.Navigation("Posts");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.cs b/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.cs
deleted file mode 100644
index 32c4c70..0000000
--- a/src/DevHive.Data/Migrations/20210202225728_SomeBullshit_Implemented.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class SomeBullshit_Implemented : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends");
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends",
- column: "FriendId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends");
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends",
- column: "FriendId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.Designer.cs b/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.Designer.cs
deleted file mode 100644
index d0fc6df..0000000
--- a/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.Designer.cs
+++ /dev/null
@@ -1,599 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210202234456_Bullshit_Part2")]
- partial class Bullshit_Part2
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- 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.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Rate")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriend", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<bool>("Rate")
- .HasColumnType("boolean");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("UserRates");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.RelationModels.RatedPost", b =>
- {
- b.HasOne("DevHive.Data.Models.Post", "Post")
- .WithMany()
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Post");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriend", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany()
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Comments");
-
- b.Navigation("Posts");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.cs b/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.cs
deleted file mode 100644
index 1388cbc..0000000
--- a/src/DevHive.Data/Migrations/20210202234456_Bullshit_Part2.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Bullshit_Part2 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends");
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends",
- column: "FriendId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends");
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- table: "UserFriends",
- column: "FriendId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- table: "UserFriends",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.Designer.cs b/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.Designer.cs
deleted file mode 100644
index fdcd696..0000000
--- a/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.Designer.cs
+++ /dev/null
@@ -1,603 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-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("20210202235051_Bullshit_Part3")]
- partial class Bullshit_Part3
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .UseIdentityByDefaultColumns()
- .HasAnnotation("Relational:MaxIdentifierLength", 63)
- .HasAnnotation("ProductVersion", "5.0.1");
-
- 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<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
- 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.Rating", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<int>("Rate")
- .HasColumnType("integer");
-
- b.HasKey("Id");
-
- b.ToTable("Rating");
- });
-
- 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>("ProfilePictureUrl")
- .HasColumnType("text");
-
- b.Property<string>("SecurityStamp")
- .HasColumnType("text");
-
- b.Property<bool>("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- 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("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.UserFriend", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserFriends");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<bool>("Rate")
- .HasColumnType("boolean");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("UserRates");
- });
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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")
- .UseIdentityByDefaultColumn();
-
- 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.RelationModels.RatedPost", b =>
- {
- b.HasOne("DevHive.Data.Models.Post", "Post")
- .WithMany()
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Post");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserFriend", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "Friend")
- .WithMany("FriendsOf")
- .HasForeignKey("FriendId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany("MyFriends")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Friend");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserRate", b =>
- {
- b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
- .HasForeignKey("UserId");
-
- b.Navigation("User");
- });
-
- 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("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Comments");
-
- b.Navigation("FriendsOf");
-
- b.Navigation("MyFriends");
-
- b.Navigation("Posts");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.cs b/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.cs
deleted file mode 100644
index 35d0c58..0000000
--- a/src/DevHive.Data/Migrations/20210202235051_Bullshit_Part3.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Bullshit_Part3 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.cs b/src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.cs
deleted file mode 100644
index 0e0a3f4..0000000
--- a/src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class Bullshit_Part4 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210203071720_ProfilePicture.cs b/src/DevHive.Data/Migrations/20210203071720_ProfilePicture.cs
deleted file mode 100644
index 1b0c2c6..0000000
--- a/src/DevHive.Data/Migrations/20210203071720_ProfilePicture.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class ProfilePicture : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "ProfilePictureUrl",
- table: "AspNetUsers");
-
- 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.CreateIndex(
- name: "IX_ProfilePicture_UserId",
- table: "ProfilePicture",
- column: "UserId",
- unique: true);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ProfilePicture");
-
- migrationBuilder.AddColumn<string>(
- name: "ProfilePictureUrl",
- table: "AspNetUsers",
- type: "text",
- nullable: true);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210203071720_ProfilePicture.Designer.cs b/src/DevHive.Data/Migrations/20210205140955_rating.Designer.cs
index b8dbd8e..8d2adc4 100644
--- a/src/DevHive.Data/Migrations/20210203071720_ProfilePicture.Designer.cs
+++ b/src/DevHive.Data/Migrations/20210205140955_rating.Designer.cs
@@ -11,8 +11,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
[DbContext(typeof(DevHiveContext))]
- [Migration("20210203071720_ProfilePicture")]
- partial class ProfilePicture
+ [Migration("20210205140955_rating")]
+ partial class rating
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -114,11 +114,17 @@ namespace DevHive.Data.Migrations
.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");
});
@@ -273,14 +279,19 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<bool>("Rate")
+ 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");
@@ -467,6 +478,17 @@ namespace DevHive.Data.Migrations
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.RelationModels.RatedPost", b =>
{
b.HasOne("DevHive.Data.Models.Post", "Post")
@@ -476,7 +498,7 @@ namespace DevHive.Data.Migrations
.IsRequired();
b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
+ .WithMany("RatedPosts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -507,10 +529,16 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.RelationModels.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");
});
@@ -613,6 +641,8 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.Models.Post", b =>
{
b.Navigation("Comments");
+
+ b.Navigation("Rating");
});
modelBuilder.Entity("DevHive.Data.Models.User", b =>
@@ -626,6 +656,8 @@ namespace DevHive.Data.Migrations
b.Navigation("Posts");
b.Navigation("ProfilePicture");
+
+ b.Navigation("RatedPosts");
});
#pragma warning restore 612, 618
}
diff --git a/src/DevHive.Data/Migrations/20210131114401_Database_Creation.cs b/src/DevHive.Data/Migrations/20210205140955_rating.cs
index 0242046..d507dae 100644
--- a/src/DevHive.Data/Migrations/20210131114401_Database_Creation.cs
+++ b/src/DevHive.Data/Migrations/20210205140955_rating.cs
@@ -5,7 +5,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
- public partial class Database_Creation : Migration
+ public partial class rating : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@@ -30,7 +30,6 @@ namespace DevHive.Data.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
FirstName = table.Column<string>(type: "text", nullable: true),
LastName = table.Column<string>(type: "text", nullable: true),
- ProfilePictureUrl = table.Column<string>(type: "text", 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),
@@ -64,19 +63,6 @@ namespace DevHive.Data.Migrations
});
migrationBuilder.CreateTable(
- name: "Rating",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- Likes = table.Column<int>(type: "integer", nullable: false),
- Dislikes = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Rating", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
name: "Technologies",
columns: table => new
{
@@ -195,6 +181,46 @@ namespace DevHive.Data.Migrations
});
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),
+ FileUrls = table.Column<List<string>>(type: "text[]", nullable: true)
+ },
+ 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
{
@@ -267,34 +293,6 @@ namespace DevHive.Data.Migrations
});
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),
- RatingId = table.Column<Guid>(type: "uuid", nullable: false),
- FileUrls = table.Column<List<string>>(type: "text[]", nullable: true)
- },
- 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);
- table.ForeignKey(
- name: "FK_Posts_Rating_RatingId",
- column: x => x.RatingId,
- principalTable: "Rating",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
name: "TechnologyUser",
columns: table => new
{
@@ -345,6 +343,75 @@ namespace DevHive.Data.Migrations
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",
@@ -409,9 +476,20 @@ namespace DevHive.Data.Migrations
column: "CreatorId");
migrationBuilder.CreateIndex(
- name: "IX_Posts_RatingId",
- table: "Posts",
- column: "RatingId",
+ 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(
@@ -428,6 +506,16 @@ namespace DevHive.Data.Migrations
name: "IX_UserFriends_FriendId",
table: "UserFriends",
column: "FriendId");
+
+ 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)
@@ -454,6 +542,15 @@ namespace DevHive.Data.Migrations
name: "LanguageUser");
migrationBuilder.DropTable(
+ name: "ProfilePicture");
+
+ migrationBuilder.DropTable(
+ name: "RatedPosts");
+
+ migrationBuilder.DropTable(
+ name: "Rating");
+
+ migrationBuilder.DropTable(
name: "RoleUser");
migrationBuilder.DropTable(
@@ -463,7 +560,7 @@ namespace DevHive.Data.Migrations
name: "UserFriends");
migrationBuilder.DropTable(
- name: "Posts");
+ name: "UserRates");
migrationBuilder.DropTable(
name: "Languages");
@@ -475,10 +572,10 @@ namespace DevHive.Data.Migrations
name: "Technologies");
migrationBuilder.DropTable(
- name: "AspNetUsers");
+ name: "Posts");
migrationBuilder.DropTable(
- name: "Rating");
+ name: "AspNetUsers");
}
}
}
diff --git a/src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.Designer.cs b/src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.Designer.cs
index 9f32b96..5d8e13a 100644
--- a/src/DevHive.Data/Migrations/20210202235318_Bullshit_Part4.Designer.cs
+++ b/src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.Designer.cs
@@ -1,6 +1,5 @@
// <auto-generated />
using System;
-using System.Collections.Generic;
using DevHive.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -11,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
[DbContext(typeof(DevHiveContext))]
- [Migration("20210202235318_Bullshit_Part4")]
- partial class Bullshit_Part4
+ [Migration("20210205154810_PostFileAttachments")]
+ partial class PostFileAttachments
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -72,9 +71,6 @@ namespace DevHive.Data.Migrations
b.Property<Guid?>("CreatorId")
.HasColumnType("uuid");
- b.Property<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
b.Property<string>("Message")
.HasColumnType("text");
@@ -88,17 +84,43 @@ namespace DevHive.Data.Migrations
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");
});
@@ -192,9 +214,6 @@ namespace DevHive.Data.Migrations
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
- b.Property<string>("ProfilePictureUrl")
- .HasColumnType("text");
-
b.Property<string>("SecurityStamp")
.HasColumnType("text");
@@ -220,6 +239,25 @@ namespace DevHive.Data.Migrations
b.ToTable("AspNetUsers");
});
+ modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.RatedPost", b =>
{
b.Property<Guid>("UserId")
@@ -256,14 +294,19 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<bool>("Rate")
+ 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");
@@ -439,6 +482,37 @@ namespace DevHive.Data.Migrations
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.RelationModels.PostAttachments", b =>
+ {
+ b.HasOne("DevHive.Data.Models.Post", "Post")
+ .WithMany("Attachments")
+ .HasForeignKey("PostId");
+
+ b.Navigation("Post");
+ });
+
modelBuilder.Entity("DevHive.Data.RelationModels.RatedPost", b =>
{
b.HasOne("DevHive.Data.Models.Post", "Post")
@@ -448,7 +522,7 @@ namespace DevHive.Data.Migrations
.IsRequired();
b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
+ .WithMany("RatedPosts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -479,10 +553,16 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.RelationModels.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");
});
@@ -584,7 +664,11 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.Models.Post", b =>
{
+ b.Navigation("Attachments");
+
b.Navigation("Comments");
+
+ b.Navigation("Rating");
});
modelBuilder.Entity("DevHive.Data.Models.User", b =>
@@ -596,6 +680,10 @@ namespace DevHive.Data.Migrations
b.Navigation("MyFriends");
b.Navigation("Posts");
+
+ b.Navigation("ProfilePicture");
+
+ b.Navigation("RatedPosts");
});
#pragma warning restore 612, 618
}
diff --git a/src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.cs b/src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.cs
new file mode 100644
index 0000000..7b7b933
--- /dev/null
+++ b/src/DevHive.Data/Migrations/20210205154810_PostFileAttachments.cs
@@ -0,0 +1,51 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DevHive.Data.Migrations
+{
+ public partial class PostFileAttachments : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "FileUrls",
+ table: "Posts");
+
+ 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.CreateIndex(
+ name: "IX_PostAttachments_PostId",
+ table: "PostAttachments",
+ column: "PostId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "PostAttachments");
+
+ migrationBuilder.AddColumn<string[]>(
+ name: "FileUrls",
+ table: "Posts",
+ type: "text[]",
+ nullable: true);
+ }
+ }
+}
diff --git a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
index 0450670..6e0a03a 100644
--- a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
+++ b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
@@ -1,6 +1,5 @@
// <auto-generated />
using System;
-using System.Collections.Generic;
using DevHive.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -70,9 +69,6 @@ namespace DevHive.Data.Migrations
b.Property<Guid?>("CreatorId")
.HasColumnType("uuid");
- b.Property<List<string>>("FileUrls")
- .HasColumnType("text[]");
-
b.Property<string>("Message")
.HasColumnType("text");
@@ -112,11 +108,17 @@ namespace DevHive.Data.Migrations
.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");
});
@@ -235,6 +237,25 @@ namespace DevHive.Data.Migrations
b.ToTable("AspNetUsers");
});
+ modelBuilder.Entity("DevHive.Data.RelationModels.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.RelationModels.RatedPost", b =>
{
b.Property<Guid>("UserId")
@@ -271,14 +292,19 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<bool>("Rate")
+ 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");
@@ -465,6 +491,26 @@ namespace DevHive.Data.Migrations
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.RelationModels.PostAttachments", b =>
+ {
+ b.HasOne("DevHive.Data.Models.Post", "Post")
+ .WithMany("Attachments")
+ .HasForeignKey("PostId");
+
+ b.Navigation("Post");
+ });
+
modelBuilder.Entity("DevHive.Data.RelationModels.RatedPost", b =>
{
b.HasOne("DevHive.Data.Models.Post", "Post")
@@ -474,7 +520,7 @@ namespace DevHive.Data.Migrations
.IsRequired();
b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
+ .WithMany("RatedPosts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -505,10 +551,16 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.RelationModels.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");
});
@@ -610,7 +662,11 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.Models.Post", b =>
{
+ b.Navigation("Attachments");
+
b.Navigation("Comments");
+
+ b.Navigation("Rating");
});
modelBuilder.Entity("DevHive.Data.Models.User", b =>
@@ -624,6 +680,8 @@ namespace DevHive.Data.Migrations
b.Navigation("Posts");
b.Navigation("ProfilePicture");
+
+ b.Navigation("RatedPosts");
});
#pragma warning restore 612, 618
}
diff --git a/src/DevHive.Data/Models/Post.cs b/src/DevHive.Data/Models/Post.cs
index 8fb3e91..3f3d8c9 100644
--- a/src/DevHive.Data/Models/Post.cs
+++ b/src/DevHive.Data/Models/Post.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using DevHive.Data.Interfaces.Models;
+using DevHive.Data.RelationModels;
namespace DevHive.Data.Models
{
@@ -18,9 +19,8 @@ namespace DevHive.Data.Models
public List<Comment> Comments { get; set; } = new();
- // public Guid RatingId { get; set; }
- // public Rating Rating { get; set; } = new();
+ public Rating Rating { get; set; } = new();
- public List<string> FileUrls { get; set; } = new();
+ public List<PostAttachments> Attachments { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/Rating.cs b/src/DevHive.Data/Models/Rating.cs
index d07692d..e1bedd2 100644
--- a/src/DevHive.Data/Models/Rating.cs
+++ b/src/DevHive.Data/Models/Rating.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using DevHive.Data.Interfaces.Models;
-using DevHive.Data.RelationModels;
namespace DevHive.Data.Models
{
@@ -9,11 +8,10 @@ namespace DevHive.Data.Models
{
public Guid Id { get; set; }
- // public Guid PostId { get; set; }
- // public Post Post { get; set; }
+ public Guid PostId { get; set; }
+ public Post Post { get; set; }
+
public int Rate { get; set; }
-
- // public HashSet<User> UsersThatRated { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/User.cs b/src/DevHive.Data/Models/User.cs
index d73f989..f666677 100644
--- a/src/DevHive.Data/Models/User.cs
+++ b/src/DevHive.Data/Models/User.cs
@@ -30,6 +30,6 @@ namespace DevHive.Data.Models
public HashSet<Comment> Comments { get; set; } = new();
- // public HashSet<RatedPost> RatedPosts { get; set; } = new();
+ public HashSet<RatedPost> RatedPosts { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/RelationModels/PostAttachments.cs b/src/DevHive.Data/RelationModels/PostAttachments.cs
new file mode 100644
index 0000000..48aa8ff
--- /dev/null
+++ b/src/DevHive.Data/RelationModels/PostAttachments.cs
@@ -0,0 +1,16 @@
+using System;
+using System.ComponentModel.DataAnnotations.Schema;
+using DevHive.Data.Models;
+
+namespace DevHive.Data.RelationModels
+{
+ [Table("PostAttachments")]
+ public class PostAttachments
+ {
+ public Guid Id { get; set; }
+
+ public Post Post { get; set; }
+
+ public string FileUrl { get; set; }
+ }
+}
diff --git a/src/DevHive.Data/RelationModels/UserRate.cs b/src/DevHive.Data/RelationModels/UserRate.cs
index 06e9ab5..696e6f3 100644
--- a/src/DevHive.Data/RelationModels/UserRate.cs
+++ b/src/DevHive.Data/RelationModels/UserRate.cs
@@ -11,6 +11,8 @@ namespace DevHive.Data.RelationModels
public User User { get; set; }
- public bool Rate { get; set; }
+ public bool Liked { get; set; }
+
+ public Post Post { get; set; }
}
}
diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs
index 382c666..bee7624 100644
--- a/src/DevHive.Data/Repositories/CommentRepository.cs
+++ b/src/DevHive.Data/Repositories/CommentRepository.cs
@@ -28,6 +28,9 @@ namespace DevHive.Data.Repositories
.FirstOrDefaultAsync(x => x.Id == id);
}
+ /// <summary>
+ /// This method returns the comment that is made at exactly the given time and by the given creator
+ /// </summary>
public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated)
{
return await this._context.Comments
diff --git a/src/DevHive.Data/Repositories/FeedRepository.cs b/src/DevHive.Data/Repositories/FeedRepository.cs
index 271c3a5..8d3e5e1 100644
--- a/src/DevHive.Data/Repositories/FeedRepository.cs
+++ b/src/DevHive.Data/Repositories/FeedRepository.cs
@@ -18,6 +18,15 @@ namespace DevHive.Data.Repositories
this._context = context;
}
+ /// <summary>
+ /// This returns a given amount of posts of all given friends, created before "firstRequestIssued",
+ /// ordered from latest to oldest (time created).
+ /// PageSize specifies how many posts to get, and pageNumber specifices how many posts to skip (pageNumber * pageSize).
+ ///
+ /// This method is used in the feed page.
+ /// Posts from friends are meant to be gotten in chunks, meaning you get X posts, and then get another amount of posts,
+ /// that are after the first X posts.
+ /// </summary>
public async Task<List<Post>> GetFriendsPosts(List<User> friendsList, DateTime firstRequestIssued, int pageNumber, int pageSize)
{
List<Guid> friendsIds = friendsList.Select(f => f.Id).ToList();
@@ -39,6 +48,15 @@ namespace DevHive.Data.Repositories
return posts;
}
+ /// <summary>
+ /// This returns a given amount of posts, that a user has made, created before "firstRequestIssued",
+ /// ordered from latest to oldest (time created).
+ /// PageSize specifies how many posts to get, and pageNumber specifices how many posts to skip (pageNumber * pageSize).
+ ///
+ /// This method is used in the profile page.
+ /// Posts from friends are meant to be gotten in chunks, meaning you get X posts, and then get another amount of posts,
+ /// that are after the first X posts.
+ /// </summary>
public async Task<List<Post>> GetUsersPosts(User user, DateTime firstRequestIssued, int pageNumber, int pageSize)
{
List<Post> posts = await this._context.Posts
diff --git a/src/DevHive.Data/Repositories/LanguageRepository.cs b/src/DevHive.Data/Repositories/LanguageRepository.cs
index 7f4b946..31d0b86 100644
--- a/src/DevHive.Data/Repositories/LanguageRepository.cs
+++ b/src/DevHive.Data/Repositories/LanguageRepository.cs
@@ -25,6 +25,9 @@ namespace DevHive.Data.Repositories
.FirstOrDefaultAsync(x => x.Name == languageName);
}
+ /// <summary>
+ /// Returns all technologies that exist in the database
+ /// </summary>
public HashSet<Language> GetLanguages()
{
return this._context.Languages.ToHashSet();
diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs
index 0fec435..52c5b4e 100644
--- a/src/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/DevHive.Data/Repositories/PostRepository.cs
@@ -2,14 +2,14 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using DevHive.Data.Interfaces.Models;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
+using DevHive.Data.RelationModels;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class PostRepository : BaseRepository<Post>, IPostRepository
+ public class PostRepository : BaseRepository<Post>, IPostRepository
{
private readonly DevHiveContext _context;
private readonly IUserRepository _userRepository;
@@ -35,10 +35,14 @@ namespace DevHive.Data.Repositories
return await this._context.Posts
.Include(x => x.Comments)
.Include(x => x.Creator)
+ .Include(x => x.Attachments)
// .Include(x => x.Rating)
.FirstOrDefaultAsync(x => x.Id == id);
}
+ /// <summary>
+ /// This method returns the post that is made at exactly the given time and by the given creator
+ /// </summary>
public async Task<Post> GetPostByCreatorAndTimeCreatedAsync(Guid creatorId, DateTime timeCreated)
{
return await this._context.Posts
@@ -48,7 +52,7 @@ namespace DevHive.Data.Repositories
public async Task<List<string>> GetFileUrls(Guid postId)
{
- return (await this.GetByIdAsync(postId)).FileUrls;
+ return (await this.GetByIdAsync(postId)).Attachments.Select(x => x.FileUrl).ToList();
}
#endregion
@@ -63,10 +67,10 @@ namespace DevHive.Data.Repositories
.CurrentValues
.SetValues(newEntity);
- List<string> fileUrls = new();
- foreach(var fileUrl in newEntity.FileUrls)
- fileUrls.Add(fileUrl);
- post.FileUrls = fileUrls;
+ List<PostAttachments> postAttachments = new();
+ foreach(var attachment in newEntity.Attachments)
+ postAttachments.Add(attachment);
+ post.Attachments = postAttachments;
post.Comments.Clear();
foreach(var comment in newEntity.Comments)
@@ -93,7 +97,7 @@ namespace DevHive.Data.Repositories
return await this._context.Posts
.AsNoTracking()
.Where(x => x.Id == postId)
- .Select(x => x.FileUrls)
+ .Select(x => x.Attachments)
.AnyAsync();
}
#endregion
diff --git a/src/DevHive.Data/Repositories/RatingRepository.cs b/src/DevHive.Data/Repositories/RatingRepository.cs
index d676f27..1be8fe8 100644
--- a/src/DevHive.Data/Repositories/RatingRepository.cs
+++ b/src/DevHive.Data/Repositories/RatingRepository.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Threading.Tasks;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
@@ -18,17 +19,17 @@ namespace DevHive.Data.Repositories
this._postRepository = postRepository;
}
- public async Task<Rating> GetByPostId(Guid postId)
+ public async Task<Rating> GetRatingByPostId(Guid postId)
{
- throw new NotImplementedException();
- // return await this._context.Rating
- // .FirstOrDefaultAsync(x => x.Post.Id == postId);
+ return await this._context.Rating
+ .FirstOrDefaultAsync(x => x.Post.Id == postId);
}
- public async Task<int> GetRating(Guid postId)
+ public async Task<bool> UserRatedPost(Guid userId, Guid postId)
{
- throw new NotImplementedException();
- // return (await this.GetByPostId(postId)).Rate;
+ return await this._context.UserRate
+ .Where(x => x.Post.Id == postId)
+ .AnyAsync(x => x.User.Id == userId);
}
}
}
diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs
index 7bb43cc..6f0d10f 100644
--- a/src/DevHive.Data/Repositories/TechnologyRepository.cs
+++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs
@@ -25,6 +25,9 @@ namespace DevHive.Data.Repositories
.FirstOrDefaultAsync(x => x.Name == technologyName);
}
+ /// <summary>
+ /// Returns all technologies that exist in the database
+ /// </summary>
public HashSet<Technology> GetTechnologies()
{
return this._context.Technologies.ToHashSet();
diff --git a/src/DevHive.Services/Services/CommentService.cs b/src/DevHive.Services/Services/CommentService.cs
index e0eb88a..e2b54c4 100644
--- a/src/DevHive.Services/Services/CommentService.cs
+++ b/src/DevHive.Services/Services/CommentService.cs
@@ -12,7 +12,7 @@ using System.Linq;
namespace DevHive.Services.Services
{
- public class CommentService : ICommentService
+ public class CommentService : ICommentService
{
private readonly IUserRepository _userRepository;
private readonly IPostRepository _postRepository;
@@ -103,6 +103,9 @@ namespace DevHive.Services.Services
#endregion
#region Validations
+ /// <summary>
+ /// Checks whether the user Id in the token and the given user Id match
+ /// </summary>
public async Task<bool> ValidateJwtForCreating(Guid userId, string rawTokenData)
{
User user = await this.GetUserForValidation(rawTokenData);
@@ -110,6 +113,11 @@ namespace DevHive.Services.Services
return user.Id == userId;
}
+ /// <summary>
+ /// Checks whether the comment, gotten with the commentId,
+ /// is made by the user in the token
+ /// or if the user in the token is an admin
+ /// </summary>
public async Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData)
{
Comment comment = await this._commentRepository.GetByIdAsync(commentId) ??
@@ -126,6 +134,9 @@ namespace DevHive.Services.Services
return false;
}
+ /// <summary>
+ /// Returns the user, via their Id in the token
+ /// </summary>
private async Task<User> GetUserForValidation(string rawTokenData)
{
JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7));
@@ -139,7 +150,9 @@ namespace DevHive.Services.Services
return user;
}
-
+ /// <summary>
+ /// Returns all values from a given claim type
+ /// </summary>
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> toReturn = new();
diff --git a/src/DevHive.Services/Services/FeedService.cs b/src/DevHive.Services/Services/FeedService.cs
index b9d1922..671df60 100644
--- a/src/DevHive.Services/Services/FeedService.cs
+++ b/src/DevHive.Services/Services/FeedService.cs
@@ -24,6 +24,10 @@ namespace DevHive.Services.Services
this._mapper = mapper;
}
+ /// <summary>
+ /// This method is used in the feed page.
+ /// See the FeedRepository "GetFriendsPosts" menthod for more information on how it works.
+ /// </summary>
public async Task<ReadPageServiceModel> GetPage(GetPageServiceModel model)
{
User user = null;
@@ -53,6 +57,10 @@ namespace DevHive.Services.Services
return readPageServiceModel;
}
+ /// <summary>
+ /// This method is used in the profile pages.
+ /// See the FeedRepository "GetUsersPosts" menthod for more information on how it works.
+ /// </summary>
public async Task<ReadPageServiceModel> GetUserPage(GetPageServiceModel model)
{
User user = null;
diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs
index 6dbb272..fe91f23 100644
--- a/src/DevHive.Services/Services/PostService.cs
+++ b/src/DevHive.Services/Services/PostService.cs
@@ -9,7 +9,7 @@ using System.Security.Claims;
using DevHive.Services.Interfaces;
using DevHive.Data.Interfaces.Repositories;
using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
+using DevHive.Data.RelationModels;
namespace DevHive.Services.Services
{
@@ -39,7 +39,10 @@ namespace DevHive.Services.Services
Post post = this._postMapper.Map<Post>(createPostServiceModel);
if (createPostServiceModel.Files.Count != 0)
- post.FileUrls = await _cloudService.UploadFilesToCloud(createPostServiceModel.Files);
+ {
+ List<string> fileUrls = await _cloudService.UploadFilesToCloud(createPostServiceModel.Files);
+ post.Attachments = this.GetPostAttachmentsFromUrls(post, fileUrls);
+ }
post.Creator = await this._userRepository.GetByIdAsync(createPostServiceModel.CreatorId);
post.TimeCreated = DateTime.Now;
@@ -77,6 +80,7 @@ namespace DevHive.Services.Services
readPostServiceModel.CreatorFirstName = user.FirstName;
readPostServiceModel.CreatorLastName = user.LastName;
readPostServiceModel.CreatorUsername = user.UserName;
+ readPostServiceModel.FileUrls = post.Attachments.Select(x => x.FileUrl).ToList();
return readPostServiceModel;
}
@@ -94,14 +98,15 @@ namespace DevHive.Services.Services
{
if (await this._postRepository.DoesPostHaveFiles(updatePostServiceModel.PostId))
{
- List<string> fileUrls = await this._postRepository.GetFileUrls(updatePostServiceModel.PostId);
- bool success = await _cloudService.RemoveFilesFromCloud(fileUrls);
+ List<string> fileUrlsToRemove = await this._postRepository.GetFileUrls(updatePostServiceModel.PostId);
+ bool success = await _cloudService.RemoveFilesFromCloud(fileUrlsToRemove);
if (!success)
throw new InvalidCastException("Could not delete files from the post!");
}
- post.FileUrls = await _cloudService.UploadFilesToCloud(updatePostServiceModel.Files) ??
+ List<string> fileUrls = await _cloudService.UploadFilesToCloud(updatePostServiceModel.Files) ??
throw new ArgumentNullException("Unable to upload images to cloud");
+ post.Attachments = this.GetPostAttachmentsFromUrls(post, fileUrls);
}
post.Creator = await this._userRepository.GetByIdAsync(updatePostServiceModel.CreatorId);
@@ -138,6 +143,9 @@ namespace DevHive.Services.Services
#endregion
#region Validations
+ /// <summary>
+ /// Checks whether the user Id in the token and the given user Id match
+ /// </summary>
public async Task<bool> ValidateJwtForCreating(Guid userId, string rawTokenData)
{
User user = await this.GetUserForValidation(rawTokenData);
@@ -145,6 +153,11 @@ namespace DevHive.Services.Services
return user.Id == userId;
}
+ /// <summary>
+ /// Checks whether the post, gotten with the postId,
+ /// is made by the user in the token
+ /// or if the user in the token is an admin
+ /// </summary>
public async Task<bool> ValidateJwtForPost(Guid postId, string rawTokenData)
{
Post post = await this._postRepository.GetByIdAsync(postId) ??
@@ -161,6 +174,11 @@ namespace DevHive.Services.Services
return false;
}
+ /// <summary>
+ /// Checks whether the comment, gotten with the commentId,
+ /// is made by the user in the token
+ /// or if the user in the token is an admin
+ /// </summary>
public async Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData)
{
Comment comment = await this._commentRepository.GetByIdAsync(commentId) ??
@@ -177,6 +195,9 @@ namespace DevHive.Services.Services
return false;
}
+ /// <summary>
+ /// Returns the user, via their Id in the token
+ /// </summary>
private async Task<User> GetUserForValidation(string rawTokenData)
{
JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7));
@@ -190,6 +211,9 @@ namespace DevHive.Services.Services
return user;
}
+ /// <summary>
+ /// Returns all values from a given claim type
+ /// </summary>
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> toReturn = new();
@@ -201,5 +225,15 @@ namespace DevHive.Services.Services
return toReturn;
}
#endregion
+
+ #region Misc
+ private List<PostAttachments> GetPostAttachmentsFromUrls(Post post, List<string> fileUrls)
+ {
+ List<PostAttachments> postAttachments = new List<PostAttachments>();
+ foreach (string url in fileUrls)
+ postAttachments.Add(new PostAttachments { Post = post, FileUrl = url });
+ return postAttachments;
+ }
+ #endregion
}
}
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index b3a4987..9cc4a8e 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -47,6 +47,10 @@ namespace DevHive.Services.Services
}
#region Authentication
+ /// <summary>
+ /// Adds a new user to the database with the values from the given model.
+ /// Returns a JSON Web Token (that can be used for authorization)
+ /// </summary>
public async Task<TokenModel> LoginUser(LoginServiceModel loginModel)
{
if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName))
@@ -60,6 +64,9 @@ namespace DevHive.Services.Services
return new TokenModel(WriteJWTSecurityToken(user.Id, user.UserName, user.Roles));
}
+ /// <summary>
+ /// Returns a new JSON Web Token (that can be used for authorization) for the given user
+ /// </summary>
public async Task<TokenModel> RegisterUser(RegisterServiceModel registerModel)
{
if (await this._userRepository.DoesUsernameExistAsync(registerModel.UserName))
@@ -70,7 +77,7 @@ namespace DevHive.Services.Services
User user = this._userMapper.Map<User>(registerModel);
user.PasswordHash = PasswordModifications.GeneratePasswordHash(registerModel.Password);
- user.ProfilePicture = new ProfilePicture() { PictureURL = String.Empty };
+ user.ProfilePicture = new ProfilePicture() { PictureURL = "/assets/images/feed/profile-pic.png" };
// Make sure the default role exists
//TODO: Move when project starts
@@ -125,6 +132,9 @@ namespace DevHive.Services.Services
return this._userMapper.Map<UserServiceModel>(newUser);
}
+ /// <summary>
+ /// Uploads the given picture and assigns it's link to the user in the database
+ /// </summary>
public async Task<ProfilePictureServiceModel> UpdateProfilePicture(UpdateProfilePictureServiceModel updateProfilePictureServiceModel)
{
User user = await this._userRepository.GetByIdAsync(updateProfilePictureServiceModel.UserId);
@@ -162,6 +172,11 @@ namespace DevHive.Services.Services
#endregion
#region Validations
+ /// <summary>
+ /// Checks whether the given user, gotten by the "id" property,
+ /// is the same user as the one in the token (uness the user in the token has the admin role)
+ /// and the roles in the token are the same as those in the user, gotten by the id in the token
+ /// </summary>
public async Task<bool> ValidJWT(Guid id, string rawTokenData)
{
// There is authorization name in the beginning, i.e. "Bearer eyJh..."
@@ -176,9 +191,6 @@ namespace DevHive.Services.Services
/* Check if user is trying to do something to himself, unless he's an admin */
/* Check roles */
- if (jwtRoleNames.Contains(Role.AdminRole))
- return true;
-
if (!jwtRoleNames.Contains(Role.AdminRole))
if (user.Id != id)
return false;
@@ -197,6 +209,9 @@ namespace DevHive.Services.Services
return true;
}
+ /// <summary>
+ /// Returns all values from a given claim type
+ /// </summary>
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> toReturn = new();
@@ -208,6 +223,11 @@ namespace DevHive.Services.Services
return toReturn;
}
+ /// <summary>
+ /// Checks whether the user in the model exists
+ /// and whether the username in the model is already taken.
+ /// If the check fails (is false), it throws an exception, otherwise nothing happens
+ /// </summary>
private async Task ValidateUserOnUpdate(UpdateUserServiceModel updateUserServiceModel)
{
if (!await this._userRepository.DoesUserExistAsync(updateUserServiceModel.Id))
@@ -218,6 +238,10 @@ namespace DevHive.Services.Services
throw new ArgumentException("Username already exists!");
}
+ /// <summary>
+ /// Return a new JSON Web Token, containing the user id, username and roles.
+ /// Tokens have an expiration time of 7 days.
+ /// </summary>
private string WriteJWTSecurityToken(Guid userId, string username, HashSet<Role> roles)
{
byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret);
@@ -274,6 +298,11 @@ namespace DevHive.Services.Services
return new TokenModel(WriteJWTSecurityToken(newUser.Id, newUser.UserName, newUser.Roles));
}
+ /// <summary>
+ /// Returns the user with the Id in the model, adding to him the roles, languages and technologies, specified by the parameter model.
+ /// This practically maps HashSet<UpdateRoleServiceModel> to HashSet<Role> (and the equvalent HashSets for Languages and Technologies)
+ /// and assigns the latter to the returned user.
+ /// </summary>
private async Task<User> PopulateModel(UpdateUserServiceModel updateUserServiceModel)
{
User user = this._userMapper.Map<User>(updateUserServiceModel);
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/FeedRepository.Tests.cs b/src/DevHive.Tests/DevHive.Data.Tests/FeedRepository.Tests.cs
index 62d6455..f134bf3 100644
--- a/src/DevHive.Tests/DevHive.Data.Tests/FeedRepository.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Data.Tests/FeedRepository.Tests.cs
@@ -43,6 +43,7 @@ namespace DevHive.Data.Tests
friendsList.Add(dummyUser);
DateTime dateTime = new DateTime(3000, 05, 09, 9, 15, 0);
+ Console.WriteLine(dateTime.ToFileTime());
Post dummyPost = this.CreateDummyPost(dummyUser);
Post anotherDummnyPost = this.CreateDummyPost(dummyUser);
@@ -104,7 +105,8 @@ namespace DevHive.Data.Tests
{
Id = id,
Message = POST_MESSAGE,
- Creator = poster
+ Creator = poster,
+ TimeCreated = new DateTime(2000, 05, 09, 9, 15, 0)
};
this.Context.Posts.Add(post);
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/PostRepository.Tests.cs b/src/DevHive.Tests/DevHive.Data.Tests/PostRepository.Tests.cs
index 7d80f1f..6dacf0b 100644
--- a/src/DevHive.Tests/DevHive.Data.Tests/PostRepository.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Data.Tests/PostRepository.Tests.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
+using DevHive.Data.RelationModels;
using DevHive.Data.Repositories;
using Microsoft.EntityFrameworkCore;
using Moq;
@@ -11,7 +11,7 @@ using NUnit.Framework;
namespace DevHive.Data.Tests
{
- [TestFixture]
+ [TestFixture]
public class PostRepositoryTests
{
private const string POST_MESSAGE = "Post test message";
@@ -44,18 +44,18 @@ namespace DevHive.Data.Tests
#endregion
#region AddNewPostToCreator
- [Test]
- public async Task AddNewPostToCreator_ReturnsTrue_WhenNewPostIsAddedToCreator()
- {
- Post post = await this.AddEntity();
- User user = new User { Id = Guid.NewGuid() };
-
- this.UserRepository.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
-
- bool result = await this.PostRepository.AddNewPostToCreator(user.Id, post);
-
- Assert.IsTrue(result, "AddNewPostToCreator does not return true when Post Is Added To Creator successfully");
- }
+ // [Test]
+ // public async Task AddNewPostToCreator_ReturnsTrue_WhenNewPostIsAddedToCreator()
+ // {
+ // Post post = await this.AddEntity();
+ // User user = new User { Id = Guid.NewGuid() };
+ //
+ // this.UserRepository.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
+ //
+ // bool result = await this.PostRepository.AddNewPostToCreator(user.Id, post);
+ //
+ // Assert.IsTrue(result, "AddNewPostToCreator does not return true when Post Is Added To Creator successfully");
+ // }
#endregion
#region GetByIdAsync
@@ -124,13 +124,14 @@ namespace DevHive.Data.Tests
private async Task<Post> AddEntity(string name = POST_MESSAGE)
{
User creator = new User { Id = Guid.NewGuid() };
+ await this.Context.Users.AddAsync(creator);
Post post = new Post
{
Message = POST_MESSAGE,
Id = Guid.NewGuid(),
Creator = creator,
TimeCreated = DateTime.Now,
- FileUrls = new List<string>(),
+ Attachments = new List<PostAttachments> { new PostAttachments { FileUrl = "kur" }, new PostAttachments { FileUrl = "za" }, new PostAttachments { FileUrl = "tva" } },
Comments = new List<Comment>()
};
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
index aaa189a..9267053 100644
--- a/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
+++ b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
@@ -218,20 +218,20 @@ namespace DevHive.Data.Tests
// Assert.IsTrue(result, "DoesUserHaveThisFriendAsync does not return true when user has the given friend");
//}
- [Test]
- public async Task DoesUserHaveThisFriendAsync_ReturnsFalse_WhenUserDoesNotHaveTheGivenFriend()
- {
- User dummyUser = this.CreateDummyUser();
- User anotherDummyUser = this.CreateAnotherDummyUser();
-
- this._context.Users.Add(dummyUser);
- this._context.Users.Add(anotherDummyUser);
- await this._context.SaveChangesAsync();
-
- bool result = await this._userRepository.DoesUserHaveThisFriendAsync(dummyUser.Id, anotherDummyUser.Id);
-
- Assert.IsFalse(result, "DoesUserHaveThisFriendAsync does not return false when user des not have the given friend");
- }
+ // [Test]
+ // public async Task DoesUserHaveThisFriendAsync_ReturnsFalse_WhenUserDoesNotHaveTheGivenFriend()
+ // {
+ // User dummyUser = this.CreateDummyUser();
+ // User anotherDummyUser = this.CreateAnotherDummyUser();
+ //
+ // this._context.Users.Add(dummyUser);
+ // this._context.Users.Add(anotherDummyUser);
+ // await this._context.SaveChangesAsync();
+ //
+ // bool result = await this._userRepository.DoesUserHaveThisFriendAsync(dummyUser.Id, anotherDummyUser.Id);
+ //
+ // Assert.IsFalse(result, "DoesUserHaveThisFriendAsync does not return false when user des not have the given friend");
+ // }
#endregion
#region DoesUserHaveThisUsername
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/CommentService.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/CommentService.Tests.cs
new file mode 100644
index 0000000..ac022ea
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Services.Tests/CommentService.Tests.cs
@@ -0,0 +1,262 @@
+using System;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Data.Interfaces.Repositories;
+using DevHive.Data.Models;
+using DevHive.Services.Models.Comment;
+using DevHive.Services.Services;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Services.Tests
+{
+ [TestFixture]
+ public class CommentServiceTests
+ {
+ private const string MESSAGE = "Gosho Trapov";
+ private Mock<IUserRepository> UserRepositoryMock { get; set; }
+ private Mock<IPostRepository> PostRepositoryMock { get; set; }
+ private Mock<ICommentRepository> CommentRepositoryMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private CommentService CommentService { get; set; }
+
+ #region Setup
+ [SetUp]
+ public void Setup()
+ {
+ this.UserRepositoryMock = new Mock<IUserRepository>();
+ this.PostRepositoryMock = new Mock<IPostRepository>();
+ this.CommentRepositoryMock = new Mock<ICommentRepository>();
+ this.MapperMock = new Mock<IMapper>();
+ this.CommentService = new CommentService(this.UserRepositoryMock.Object, this.PostRepositoryMock.Object, this.CommentRepositoryMock.Object, this.MapperMock.Object);
+ }
+ #endregion
+
+ #region AddComment
+ [Test]
+ public async Task AddComment_ReturnsNonEmptyGuid_WhenEntityIsAddedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ User creator = new User { Id = Guid.NewGuid() };
+ CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+ Comment comment = new Comment
+ {
+ Message = MESSAGE,
+ Id = id,
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Comment>())).Returns(Task.FromResult(true));
+ this.CommentRepositoryMock.Setup(p => p.GetCommentByIssuerAndTimeCreatedAsync(It.IsAny<Guid>(), It.IsAny<DateTime>())).Returns(Task.FromResult(comment));
+ this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(creator));
+ this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<CreateCommentServiceModel>())).Returns(comment);
+
+ Guid result = await this.CommentService.AddComment(createCommentServiceModel);
+
+ Assert.AreEqual(id, result);
+ }
+
+ [Test]
+ public async Task AddComment_ReturnsEmptyGuid_WhenEntityIsNotAddedSuccessfully()
+ {
+ CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+ Comment comment = new Comment
+ {
+ Message = MESSAGE,
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Comment>())).Returns(Task.FromResult(false));
+ this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<CreateCommentServiceModel>())).Returns(comment);
+
+ Guid result = await this.CommentService.AddComment(createCommentServiceModel);
+
+ Assert.IsTrue(result == Guid.Empty);
+ }
+
+ [Test]
+ public void AddComment_ThrowsException_WhenPostDoesNotExist()
+ {
+ const string EXCEPTION_MESSAGE = "Post does not exist!";
+
+ CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+
+ Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.CommentService.AddComment(createCommentServiceModel), "AddComment does not throw excpeion when the post does not exist");
+
+ Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Incorecct exception message");
+ }
+ #endregion
+
+ #region GetCommentById
+ [Test]
+ public async Task GetCommentById_ReturnsTheComment_WhenItExists()
+ {
+ Guid creatorId = new Guid();
+ User creator = new User { Id = creatorId };
+ Comment comment = new Comment
+ {
+ Message = MESSAGE,
+ Creator = creator
+ };
+ ReadCommentServiceModel commentServiceModel = new ReadCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+ User user = new User
+ {
+ Id = creatorId,
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
+ this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
+ this.MapperMock.Setup(p => p.Map<ReadCommentServiceModel>(It.IsAny<Comment>())).Returns(commentServiceModel);
+
+ ReadCommentServiceModel result = await this.CommentService.GetCommentById(new Guid());
+
+ Assert.AreEqual(MESSAGE, result.Message);
+ }
+
+ [Test]
+ public void GetCommentById_ThorwsException_WhenTheUserDoesNotExist()
+ {
+ const string EXCEPTION_MESSAGE = "The user does not exist";
+ Guid creatorId = new Guid();
+ User creator = new User { Id = creatorId };
+ Comment comment = new Comment
+ {
+ Message = MESSAGE,
+ Creator = creator
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
+
+ Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.CommentService.GetCommentById(new Guid()), "GetCommentById does not throw exception when the user does not exist");
+
+ Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message);
+ }
+
+ [Test]
+ public void GetCommentById_ThrowsException_WhenCommentDoesNotExist()
+ {
+ string exceptionMessage = "The comment does not exist";
+ Guid creatorId = new Guid();
+ User user = new User
+ {
+ Id = creatorId,
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult<Comment>(null));
+ this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
+
+ Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.CommentService.GetCommentById(new Guid()));
+
+ Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
+ }
+ #endregion
+
+ #region UpdateComment
+ [Test]
+ public async Task UpdateComment_ReturnsTheIdOfTheComment_WhenUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ Comment comment = new Comment
+ {
+ Id = id,
+ Message = MESSAGE
+ };
+ UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
+ {
+ CommentId = id,
+ NewMessage = MESSAGE
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.CommentRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Guid>(), It.IsAny<Comment>())).Returns(Task.FromResult(true));
+ this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
+ this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<UpdateCommentServiceModel>())).Returns(comment);
+
+ Guid result = await this.CommentService.UpdateComment(updateCommentServiceModel);
+
+ Assert.AreEqual(updateCommentServiceModel.CommentId, result);
+ }
+
+ [Test]
+ public async Task UpdateComment_ReturnsEmptyId_WhenTheCommentIsNotUpdatedSuccessfully()
+ {
+ Comment comment = new Comment
+ {
+ Message = MESSAGE
+ };
+ UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
+ {
+ CommentId = Guid.NewGuid(),
+ NewMessage = MESSAGE
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.CommentRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Guid>(), It.IsAny<Comment>())).Returns(Task.FromResult(false));
+ this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<UpdateCommentServiceModel>())).Returns(comment);
+
+ Guid result = await this.CommentService.UpdateComment(updateCommentServiceModel);
+
+ Assert.AreEqual(Guid.Empty, result);
+ }
+
+ [Test]
+ public void UpdateComment_ThrowsArgumentException_WhenCommentDoesNotExist()
+ {
+ string exceptionMessage = "Comment does not exist!";
+ UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
+ {
+ };
+
+ this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.CommentService.UpdateComment(updateCommentServiceModel));
+
+ Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
+ }
+ #endregion
+
+ #region DeleteComment
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public async Task DeleteComment_ShouldReturnIfDeletionIsSuccessfull_WhenCommentExists(bool shouldPass)
+ {
+ Guid id = new Guid();
+ Comment comment = new Comment();
+
+ this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
+ this.CommentRepositoryMock.Setup(p => p.DeleteAsync(It.IsAny<Comment>())).Returns(Task.FromResult(shouldPass));
+
+ bool result = await this.CommentService.DeleteComment(id);
+
+ Assert.AreEqual(shouldPass, result);
+ }
+
+ [Test]
+ public void DeleteComment_ThrowsException_WhenCommentDoesNotExist()
+ {
+ string exceptionMessage = "Comment does not exist!";
+ Guid id = new Guid();
+
+ this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.CommentService.DeleteComment(id));
+
+ Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/FeedService.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/FeedService.Tests.cs
index 36cb838..e4020c5 100644
--- a/src/DevHive.Tests/DevHive.Services.Tests/FeedService.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Services.Tests/FeedService.Tests.cs
@@ -1,155 +1,155 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Data.Interfaces.Repositories;
-using DevHive.Data.Models;
-using DevHive.Services.Models;
-using DevHive.Services.Models.Post.Post;
-using DevHive.Services.Services;
-using Moq;
-using NUnit.Framework;
-
-namespace DevHive.Services.Tests
-{
- [TestFixture]
- public class FeedServiceTests
- {
- private Mock<IFeedRepository> FeedRepositoryMock { get; set; }
- private Mock<IUserRepository> UserRepositoryMock { get; set; }
- private Mock<IMapper> MapperMock { get; set; }
- private FeedService FeedService { get; set; }
-
- #region SetUps
- [SetUp]
- public void Setup()
- {
- this.FeedRepositoryMock = new Mock<IFeedRepository>();
- this.UserRepositoryMock = new Mock<IUserRepository>();
- this.MapperMock = new Mock<IMapper>();
- this.FeedService = new FeedService(this.FeedRepositoryMock.Object, this.UserRepositoryMock.Object, this.MapperMock.Object);
- }
- #endregion
-
- #region GetPage
- [Test]
- public async Task GetPage_ReturnsReadPageServiceModel_WhenSuitablePostsExist()
- {
- GetPageServiceModel getPageServiceModel = new GetPageServiceModel
- {
- UserId = Guid.NewGuid()
- };
-
- User dummyUser = CreateDummyUser();
- User anotherDummyUser = CreateAnotherDummyUser();
- HashSet<User> friends = new HashSet<User>();
- friends.Add(anotherDummyUser);
- dummyUser.Friends = friends;
-
- List<Post> posts = new List<Post>
- {
- new Post{ Message = "Message"}
- };
-
- ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
- {
- PostId = Guid.NewGuid(),
- Message = "Message"
- };
- List<ReadPostServiceModel> readPostServiceModels = new List<ReadPostServiceModel>();
- readPostServiceModels.Add(readPostServiceModel);
- ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel
- {
- Posts = readPostServiceModels
- };
-
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
- this.FeedRepositoryMock.Setup(p => p.GetFriendsPosts(It.IsAny<List<User>>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())).Returns(Task.FromResult(posts));
- this.MapperMock.Setup(p => p.Map<ReadPostServiceModel>(It.IsAny<Post>())).Returns(readPostServiceModel);
-
- ReadPageServiceModel result = await this.FeedService.GetPage(getPageServiceModel);
-
- Assert.GreaterOrEqual(1, result.Posts.Count, "GetPage does not correctly return the posts");
- }
-
- [Test]
- public void GetPage_ThrowsException_WhenNoSuitablePostsExist()
- {
- const string EXCEPTION_MESSAGE = "No friends of user have posted anything yet!";
- GetPageServiceModel getPageServiceModel = new GetPageServiceModel
- {
- UserId = Guid.NewGuid()
- };
-
- User dummyUser = CreateDummyUser();
- User anotherDummyUser = CreateAnotherDummyUser();
- HashSet<User> friends = new HashSet<User>();
- friends.Add(anotherDummyUser);
- dummyUser.Friends = friends;
-
- ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
- {
- PostId = Guid.NewGuid(),
- Message = "Message"
- };
- List<ReadPostServiceModel> readPostServiceModels = new List<ReadPostServiceModel>();
- readPostServiceModels.Add(readPostServiceModel);
- ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel
- {
- Posts = readPostServiceModels
- };
-
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
- this.FeedRepositoryMock.Setup(p => p.GetFriendsPosts(It.IsAny<List<User>>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())).Returns(Task.FromResult(new List<Post>()));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.FeedService.GetPage(getPageServiceModel));
-
- Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Wrong exception message");
- }
-
- [Test]
- public void GetPage_ThrowsException_WhenUserHasNoFriendsToGetPostsFrom()
- {
- const string EXCEPTION_MESSAGE = "User has no friends to get feed from!";
- GetPageServiceModel getPageServiceModel = new GetPageServiceModel
- {
- UserId = Guid.NewGuid()
- };
-
- User dummyUser = CreateDummyUser();
-
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.FeedService.GetPage(getPageServiceModel));
-
- Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Wrong exception message");
- }
- #endregion
-
- #region HelperMethods
- private User CreateDummyUser()
- {
- return new()
- {
- Id = Guid.NewGuid(),
- UserName = "dummyUser",
- FirstName = "Spas",
- LastName = "Spasov",
- Email = "abv@abv.bg",
- };
- }
-
- private User CreateAnotherDummyUser()
- {
- return new()
- {
- Id = Guid.NewGuid(),
- UserName = "anotherDummyUser",
- FirstName = "Alex",
- LastName = "Spiridonov",
- Email = "a_spiridonov@abv.bg",
- };
- }
- #endregion
- }
-}
+//using System;
+//using System.Collections.Generic;
+//using System.Threading.Tasks;
+//using AutoMapper;
+//using DevHive.Data.Interfaces.Repositories;
+//using DevHive.Data.Models;
+//using DevHive.Services.Models;
+//using DevHive.Services.Models.Post;
+//using DevHive.Services.Services;
+//using Moq;
+//using NUnit.Framework;
+
+//namespace DevHive.Services.Tests
+//{
+// [TestFixture]
+// public class FeedServiceTests
+// {
+// private Mock<IFeedRepository> FeedRepositoryMock { get; set; }
+// private Mock<IUserRepository> UserRepositoryMock { get; set; }
+// private Mock<IMapper> MapperMock { get; set; }
+// private FeedService FeedService { get; set; }
+
+// #region SetUps
+// [SetUp]
+// public void Setup()
+// {
+// this.FeedRepositoryMock = new Mock<IFeedRepository>();
+// this.UserRepositoryMock = new Mock<IUserRepository>();
+// this.MapperMock = new Mock<IMapper>();
+// this.FeedService = new FeedService(this.FeedRepositoryMock.Object, this.UserRepositoryMock.Object, this.MapperMock.Object);
+// }
+// #endregion
+
+// #region GetPage
+// [Test]
+// public async Task GetPage_ReturnsReadPageServiceModel_WhenSuitablePostsExist()
+// {
+// GetPageServiceModel getPageServiceModel = new GetPageServiceModel
+// {
+// UserId = Guid.NewGuid()
+// };
+
+// User dummyUser = CreateDummyUser();
+// User anotherDummyUser = CreateAnotherDummyUser();
+// HashSet<User> friends = new HashSet<User>();
+// friends.Add(anotherDummyUser);
+// dummyUser.Friends = friends;
+
+// List<Post> posts = new List<Post>
+// {
+// new Post{ Message = "Message"}
+// };
+
+// ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
+// {
+// PostId = Guid.NewGuid(),
+// Message = "Message"
+// };
+// List<ReadPostServiceModel> readPostServiceModels = new List<ReadPostServiceModel>();
+// readPostServiceModels.Add(readPostServiceModel);
+// ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel
+// {
+// Posts = readPostServiceModels
+// };
+
+// this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
+// this.FeedRepositoryMock.Setup(p => p.GetFriendsPosts(It.IsAny<List<User>>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())).Returns(Task.FromResult(posts));
+// this.MapperMock.Setup(p => p.Map<ReadPostServiceModel>(It.IsAny<Post>())).Returns(readPostServiceModel);
+
+// ReadPageServiceModel result = await this.FeedService.GetPage(getPageServiceModel);
+
+// Assert.GreaterOrEqual(1, result.Posts.Count, "GetPage does not correctly return the posts");
+// }
+
+// [Test]
+// public void GetPage_ThrowsException_WhenNoSuitablePostsExist()
+// {
+// const string EXCEPTION_MESSAGE = "No friends of user have posted anything yet!";
+// GetPageServiceModel getPageServiceModel = new GetPageServiceModel
+// {
+// UserId = Guid.NewGuid()
+// };
+
+// User dummyUser = CreateDummyUser();
+// User anotherDummyUser = CreateAnotherDummyUser();
+// HashSet<User> friends = new HashSet<User>();
+// friends.Add(anotherDummyUser);
+// dummyUser.Friends = friends;
+
+// ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
+// {
+// PostId = Guid.NewGuid(),
+// Message = "Message"
+// };
+// List<ReadPostServiceModel> readPostServiceModels = new List<ReadPostServiceModel>();
+// readPostServiceModels.Add(readPostServiceModel);
+// ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel
+// {
+// Posts = readPostServiceModels
+// };
+
+// this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
+// this.FeedRepositoryMock.Setup(p => p.GetFriendsPosts(It.IsAny<List<User>>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())).Returns(Task.FromResult(new List<Post>()));
+
+// Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.FeedService.GetPage(getPageServiceModel));
+
+// Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Wrong exception message");
+// }
+
+// [Test]
+// public void GetPage_ThrowsException_WhenUserHasNoFriendsToGetPostsFrom()
+// {
+// const string EXCEPTION_MESSAGE = "User has no friends to get feed from!";
+// GetPageServiceModel getPageServiceModel = new GetPageServiceModel
+// {
+// UserId = Guid.NewGuid()
+// };
+
+// User dummyUser = CreateDummyUser();
+
+// this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(dummyUser));
+
+// Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.FeedService.GetPage(getPageServiceModel));
+
+// Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Wrong exception message");
+// }
+// #endregion
+
+// #region HelperMethods
+// private User CreateDummyUser()
+// {
+// return new()
+// {
+// Id = Guid.NewGuid(),
+// UserName = "dummyUser",
+// FirstName = "Spas",
+// LastName = "Spasov",
+// Email = "abv@abv.bg",
+// };
+// }
+
+// private User CreateAnotherDummyUser()
+// {
+// return new()
+// {
+// Id = Guid.NewGuid(),
+// UserName = "anotherDummyUser",
+// FirstName = "Alex",
+// LastName = "Spiridonov",
+// Email = "a_spiridonov@abv.bg",
+// };
+// }
+// #endregion
+// }
+//}
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/PostService.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/PostService.Tests.cs
index b47c8bc..900608c 100644
--- a/src/DevHive.Tests/DevHive.Services.Tests/PostService.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Services.Tests/PostService.Tests.cs
@@ -1,11 +1,13 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
-using DevHive.Services.Models.Post.Comment;
-using DevHive.Services.Models.Post.Post;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models.Post;
using DevHive.Services.Services;
+using Microsoft.AspNetCore.Http;
using Moq;
using NUnit.Framework;
@@ -15,9 +17,10 @@ namespace DevHive.Services.Tests
public class PostServiceTests
{
private const string MESSAGE = "Gosho Trapov";
+ private Mock<ICloudService> CloudServiceMock { get; set; }
private Mock<IPostRepository> PostRepositoryMock { get; set; }
- private Mock<IUserRepository> UserRepositoryMock { get; set; }
private Mock<ICommentRepository> CommentRepositoryMock { get; set; }
+ private Mock<IUserRepository> UserRepositoryMock { get; set; }
private Mock<IMapper> MapperMock { get; set; }
private PostService PostService { get; set; }
@@ -26,247 +29,14 @@ namespace DevHive.Services.Tests
public void Setup()
{
this.PostRepositoryMock = new Mock<IPostRepository>();
+ this.CloudServiceMock = new Mock<ICloudService>();
this.UserRepositoryMock = new Mock<IUserRepository>();
this.CommentRepositoryMock = new Mock<ICommentRepository>();
this.MapperMock = new Mock<IMapper>();
- this.PostService = new PostService(this.UserRepositoryMock.Object, this.PostRepositoryMock.Object, this.CommentRepositoryMock.Object, this.MapperMock.Object);
+ this.PostService = new PostService(this.CloudServiceMock.Object, this.UserRepositoryMock.Object, this.PostRepositoryMock.Object, this.CommentRepositoryMock.Object, this.MapperMock.Object);
}
#endregion
- #region Comment
- #region AddComment
- [Test]
- public async Task AddComment_ReturnsNonEmptyGuid_WhenEntityIsAddedSuccessfully()
- {
- Guid id = Guid.NewGuid();
- User creator = new User { Id = Guid.NewGuid() };
- CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
- {
- Message = MESSAGE
- };
- Comment comment = new Comment
- {
- Message = MESSAGE,
- Id = id,
- };
-
- this.CommentRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Comment>())).Returns(Task.FromResult(true));
- this.CommentRepositoryMock.Setup(p => p.GetCommentByIssuerAndTimeCreatedAsync(It.IsAny<Guid>(), It.IsAny<DateTime>())).Returns(Task.FromResult(comment));
- this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(creator));
- this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<CreateCommentServiceModel>())).Returns(comment);
-
- Guid result = await this.PostService.AddComment(createCommentServiceModel);
-
- Assert.AreEqual(id, result);
- }
-
- [Test]
- public async Task AddComment_ReturnsEmptyGuid_WhenEntityIsNotAddedSuccessfully()
- {
- CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
- {
- Message = MESSAGE
- };
- Comment comment = new Comment
- {
- Message = MESSAGE,
- };
-
- this.CommentRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Comment>())).Returns(Task.FromResult(false));
- this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<CreateCommentServiceModel>())).Returns(comment);
-
- Guid result = await this.PostService.AddComment(createCommentServiceModel);
-
- Assert.IsTrue(result == Guid.Empty);
- }
-
- [Test]
- public void AddComment_ThrowsException_WhenPostDoesNotExist()
- {
- const string EXCEPTION_MESSAGE = "Post does not exist!";
-
- CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
- {
- Message = MESSAGE
- };
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.AddComment(createCommentServiceModel), "AddComment does not throw excpeion when the post does not exist");
-
- Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message, "Incorecct exception message");
- }
- #endregion
-
- #region GetCommentById
- [Test]
- public async Task GetCommentById_ReturnsTheComment_WhenItExists()
- {
- Guid creatorId = new Guid();
- User creator = new User { Id = creatorId };
- Comment comment = new Comment
- {
- Message = MESSAGE,
- Creator = creator
- };
- ReadCommentServiceModel commentServiceModel = new ReadCommentServiceModel
- {
- Message = MESSAGE
- };
- User user = new User
- {
- Id = creatorId,
- };
-
- this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
- this.MapperMock.Setup(p => p.Map<ReadCommentServiceModel>(It.IsAny<Comment>())).Returns(commentServiceModel);
-
- ReadCommentServiceModel result = await this.PostService.GetCommentById(new Guid());
-
- Assert.AreEqual(MESSAGE, result.Message);
- }
-
- [Test]
- public void GetCommentById_ThorwsException_WhenTheUserDoesNotExist()
- {
- const string EXCEPTION_MESSAGE = "The user does not exist";
- Guid creatorId = new Guid();
- User creator = new User { Id = creatorId };
- Comment comment = new Comment
- {
- Message = MESSAGE,
- Creator = creator
- };
-
- this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.GetCommentById(new Guid()), "GetCommentById does not throw exception when the user does not exist");
-
- Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message);
- }
-
- [Test]
- public void GetCommentById_ThrowsException_WhenCommentDoesNotExist()
- {
- string exceptionMessage = "The comment does not exist";
- Guid creatorId = new Guid();
- User user = new User
- {
- Id = creatorId,
- };
-
- this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult<Comment>(null));
- this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.GetCommentById(new Guid()));
-
- Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
- }
- #endregion
-
- #region UpdateComment
- [Test]
- public async Task UpdateComment_ReturnsTheIdOfTheComment_WhenUpdatedSuccessfully()
- {
- Guid id = Guid.NewGuid();
- Comment comment = new Comment
- {
- Id = id,
- Message = MESSAGE
- };
- UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
- {
- CommentId = id,
- NewMessage = MESSAGE
- };
-
- this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.CommentRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Guid>(), It.IsAny<Comment>())).Returns(Task.FromResult(true));
- this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
- this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<UpdateCommentServiceModel>())).Returns(comment);
-
- Guid result = await this.PostService.UpdateComment(updateCommentServiceModel);
-
- Assert.AreEqual(updateCommentServiceModel.CommentId, result);
- }
-
- [Test]
- public async Task UpdateComment_ReturnsEmptyId_WhenTheCommentIsNotUpdatedSuccessfully()
- {
- Comment comment = new Comment
- {
- Message = MESSAGE
- };
- UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
- {
- CommentId = Guid.NewGuid(),
- NewMessage = MESSAGE
- };
-
- this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.CommentRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Guid>(), It.IsAny<Comment>())).Returns(Task.FromResult(false));
- this.MapperMock.Setup(p => p.Map<Comment>(It.IsAny<UpdateCommentServiceModel>())).Returns(comment);
-
- Guid result = await this.PostService.UpdateComment(updateCommentServiceModel);
-
- Assert.AreEqual(Guid.Empty, result);
- }
-
- [Test]
- public void UpdateComment_ThrowsArgumentException_WhenCommentDoesNotExist()
- {
- string exceptionMessage = "Comment does not exist!";
- UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
- {
- };
-
- this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(false));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.UpdateComment(updateCommentServiceModel));
-
- Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
- }
- #endregion
-
- #region DeleteComment
- [Test]
- [TestCase(true)]
- [TestCase(false)]
- public async Task DeleteComment_ShouldReturnIfDeletionIsSuccessfull_WhenCommentExists(bool shouldPass)
- {
- Guid id = new Guid();
- Comment comment = new Comment();
-
- this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.CommentRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(comment));
- this.CommentRepositoryMock.Setup(p => p.DeleteAsync(It.IsAny<Comment>())).Returns(Task.FromResult(shouldPass));
-
- bool result = await this.PostService.DeleteComment(id);
-
- Assert.AreEqual(shouldPass, result);
- }
-
- [Test]
- public void DeleteComment_ThrowsException_WhenCommentDoesNotExist()
- {
- string exceptionMessage = "Comment does not exist!";
- Guid id = new Guid();
-
- this.CommentRepositoryMock.Setup(p => p.DoesCommentExist(It.IsAny<Guid>())).Returns(Task.FromResult(false));
-
- Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.DeleteComment(id));
-
- Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
- }
- #endregion
-
- #region ValidateJwtForComment
- //TO DO: Implement
- #endregion
- #endregion
-
- #region Posts
#region CreatePost
[Test]
public async Task CreatePost_ReturnsIdOfThePost_WhenItIsSuccessfullyCreated()
@@ -275,11 +45,12 @@ namespace DevHive.Services.Tests
User creator = new User { Id = Guid.NewGuid() };
CreatePostServiceModel createPostServiceModel = new CreatePostServiceModel
{
+ Files = new List<IFormFile>()
};
Post post = new Post
{
Message = MESSAGE,
- Id = postId
+ Id = postId,
};
this.PostRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Post>())).Returns(Task.FromResult(true));
@@ -298,6 +69,7 @@ namespace DevHive.Services.Tests
{
CreatePostServiceModel createPostServiceModel = new CreatePostServiceModel
{
+ Files = new List<IFormFile>()
};
Post post = new Post
{
@@ -411,7 +183,8 @@ namespace DevHive.Services.Tests
UpdatePostServiceModel updatePostServiceModel = new UpdatePostServiceModel
{
PostId = id,
- NewMessage = MESSAGE
+ NewMessage = MESSAGE,
+ Files = new List<IFormFile>()
};
this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
@@ -434,7 +207,8 @@ namespace DevHive.Services.Tests
UpdatePostServiceModel updatePostServiceModel = new UpdatePostServiceModel
{
PostId = Guid.NewGuid(),
- NewMessage = MESSAGE
+ NewMessage = MESSAGE,
+ Files = new List<IFormFile>()
};
this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny<Guid>())).Returns(Task.FromResult(true));
@@ -493,10 +267,5 @@ namespace DevHive.Services.Tests
Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
}
#endregion
-
- #region ValidateJwtForPost
- //TO DO: Implement
- #endregion
- #endregion
}
}
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs
index 7573632..e671adb 100644
--- a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs
@@ -110,15 +110,15 @@ namespace DevHive.Services.Tests
{
Name = name
};
- CreateTechnologyServiceModel createTechnologyServiceModel = new()
+ ReadTechnologyServiceModel readTechnologyServiceModel = new()
{
Name = name
};
this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(technology));
- this.MapperMock.Setup(p => p.Map<CreateTechnologyServiceModel>(It.IsAny<Technology>())).Returns(createTechnologyServiceModel);
+ this.MapperMock.Setup(p => p.Map<ReadTechnologyServiceModel>(It.IsAny<Technology>())).Returns(readTechnologyServiceModel);
- CreateTechnologyServiceModel result = await this.TechnologyService.GetTechnologyById(id);
+ ReadTechnologyServiceModel result = await this.TechnologyService.GetTechnologyById(id);
Assert.AreEqual(name, result.Name);
}
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/UserService.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/UserService.Tests.cs
index 1abc0f1..61eb449 100644
--- a/src/DevHive.Tests/DevHive.Services.Tests/UserService.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Services.Tests/UserService.Tests.cs
@@ -9,6 +9,7 @@ using DevHive.Common.Models.Identity;
using DevHive.Common.Models.Misc;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
+using DevHive.Services.Interfaces;
using DevHive.Services.Models.Identity.User;
using DevHive.Services.Options;
using DevHive.Services.Services;
@@ -21,6 +22,7 @@ namespace DevHive.Services.Tests
[TestFixture]
public class UserServiceTests
{
+ private Mock<ICloudService> CloudServiceMock { get; set; }
private Mock<IUserRepository> UserRepositoryMock { get; set; }
private Mock<IRoleRepository> RoleRepositoryMock { get; set; }
private Mock<ILanguageRepository> LanguageRepositoryMock { get; set; }
@@ -35,11 +37,12 @@ namespace DevHive.Services.Tests
{
this.UserRepositoryMock = new Mock<IUserRepository>();
this.RoleRepositoryMock = new Mock<IRoleRepository>();
+ this.CloudServiceMock = new Mock<ICloudService>();
this.LanguageRepositoryMock = new Mock<ILanguageRepository>();
this.TechnologyRepositoryMock = new Mock<ITechnologyRepository>();
this.JWTOptions = new JWTOptions("gXfQlU6qpDleFWyimscjYcT3tgFsQg3yoFjcvSLxG56n1Vu2yptdIUq254wlJWjm");
this.MapperMock = new Mock<IMapper>();
- this.UserService = new UserService(this.UserRepositoryMock.Object, this.LanguageRepositoryMock.Object, this.RoleRepositoryMock.Object, this.TechnologyRepositoryMock.Object, this.MapperMock.Object, JWTOptions);
+ this.UserService = new UserService(this.UserRepositoryMock.Object, this.LanguageRepositoryMock.Object, this.RoleRepositoryMock.Object, this.TechnologyRepositoryMock.Object, this.MapperMock.Object, JWTOptions, this.CloudServiceMock.Object);
}
#endregion
@@ -48,6 +51,7 @@ namespace DevHive.Services.Tests
public async Task LoginUser_ReturnsTokenModel_WhenLoggingUserIn()
{
string somePassword = "GoshoTrapovImaGolemChep";
+ const string name = "GoshoTrapov";
string hashedPassword = PasswordModifications.GeneratePasswordHash(somePassword);
LoginServiceModel loginServiceModel = new LoginServiceModel
{
@@ -56,13 +60,14 @@ namespace DevHive.Services.Tests
User user = new User
{
Id = Guid.NewGuid(),
- PasswordHash = hashedPassword
+ PasswordHash = hashedPassword,
+ UserName = name
};
this.UserRepositoryMock.Setup(p => p.DoesUsernameExistAsync(It.IsAny<string>())).Returns(Task.FromResult(true));
this.UserRepositoryMock.Setup(p => p.GetByUsernameAsync(It.IsAny<string>())).Returns(Task.FromResult(user));
- string JWTSecurityToken = this.WriteJWTSecurityToken(user.Id, user.Roles);
+ string JWTSecurityToken = this.WriteJWTSecurityToken(user.Id, user.UserName, user.Roles);
TokenModel tokenModel = await this.UserService.LoginUser(loginServiceModel);
@@ -113,13 +118,15 @@ namespace DevHive.Services.Tests
public async Task RegisterUser_ReturnsTokenModel_WhenUserIsSuccessfull()
{
string somePassword = "GoshoTrapovImaGolemChep";
+ const string name = "GoshoTrapov";
RegisterServiceModel registerServiceModel = new RegisterServiceModel
{
Password = somePassword
};
User user = new User
{
- Id = Guid.NewGuid()
+ Id = Guid.NewGuid(),
+ UserName = name
};
Role role = new Role { Name = Role.DefaultRole };
HashSet<Role> roles = new HashSet<Role> { role };
@@ -131,7 +138,7 @@ namespace DevHive.Services.Tests
this.MapperMock.Setup(p => p.Map<User>(It.IsAny<RegisterServiceModel>())).Returns(user);
this.UserRepositoryMock.Setup(p => p.AddAsync(It.IsAny<User>())).Verifiable();
- string JWTSecurityToken = this.WriteJWTSecurityToken(user.Id, roles);
+ string JWTSecurityToken = this.WriteJWTSecurityToken(user.Id, user.UserName, roles);
TokenModel tokenModel = await this.UserService.RegisterUser(registerServiceModel);
@@ -353,13 +360,13 @@ namespace DevHive.Services.Tests
#endregion
#region HelperMethods
- private string WriteJWTSecurityToken(Guid userId, HashSet<Role> roles)
+ private string WriteJWTSecurityToken(Guid userId, string username, HashSet<Role> roles)
{
byte[] signingKey = Encoding.ASCII.GetBytes(this.JWTOptions.Secret);
-
HashSet<Claim> claims = new()
{
new Claim("ID", $"{userId}"),
+ new Claim("Username", username),
};
foreach (var role in roles)
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/CommentController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/CommentController.Tests.cs
new file mode 100644
index 0000000..3a03f1a
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Web.Tests/CommentController.Tests.cs
@@ -0,0 +1,256 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models.Comment;
+using DevHive.Web.Controllers;
+using DevHive.Web.Models.Comment;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Web.Tests
+{
+ [TestFixture]
+ public class CommentControllerTests
+ {
+ const string MESSAGE = "Gosho Trapov";
+ private Mock<ICommentService> CommentServiceMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private CommentController CommentController { get; set; }
+
+ #region Setup
+ [SetUp]
+ public void SetUp()
+ {
+ this.CommentServiceMock = new Mock<ICommentService>();
+ this.MapperMock = new Mock<IMapper>();
+ this.CommentController = new CommentController(this.CommentServiceMock.Object, this.MapperMock.Object);
+ }
+ #endregion
+
+ #region Add
+ [Test]
+ public void AddComment_ReturnsOkObjectResult_WhenCommentIsSuccessfullyCreated()
+ {
+ Guid id = Guid.NewGuid();
+ CreateCommentWebModel createCommentWebModel = new CreateCommentWebModel
+ {
+ Message = MESSAGE
+ };
+ CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+
+ this.MapperMock.Setup(p => p.Map<CreateCommentServiceModel>(It.IsAny<CreateCommentWebModel>())).Returns(createCommentServiceModel);
+ this.CommentServiceMock.Setup(p => p.AddComment(It.IsAny<CreateCommentServiceModel>())).Returns(Task.FromResult(id));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.CommentController.AddComment(Guid.NewGuid(), createCommentWebModel, null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ var splitted = (result as OkObjectResult).Value
+ .ToString()
+ .Split('{', '}', '=', ' ')
+ .Where(x => !string.IsNullOrEmpty(x))
+ .ToArray();
+
+ Guid resultId = Guid.Parse(splitted[1]);
+
+ Assert.AreEqual(id, resultId);
+ }
+
+ [Test]
+ public void AddComment_ReturnsBadRequestObjectResult_WhenCommentIsNotCreatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ CreateCommentWebModel createCommentWebModel = new CreateCommentWebModel
+ {
+ Message = MESSAGE
+ };
+ CreateCommentServiceModel createCommentServiceModel = new CreateCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+ string errorMessage = $"Could not create comment!";
+
+
+ this.MapperMock.Setup(p => p.Map<CreateCommentServiceModel>(It.IsAny<CreateCommentWebModel>())).Returns(createCommentServiceModel);
+ this.CommentServiceMock.Setup(p => p.AddComment(It.IsAny<CreateCommentServiceModel>())).Returns(Task.FromResult(Guid.Empty));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.CommentController.AddComment(Guid.NewGuid(), createCommentWebModel, null).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequsetObjectResult = result as BadRequestObjectResult;
+ string resultMessage = badRequsetObjectResult.Value.ToString();
+
+ Assert.AreEqual(errorMessage, resultMessage);
+ }
+
+ [Test]
+ public void AddComment_ReturnsUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ Guid id = Guid.NewGuid();
+ CreateCommentWebModel createCommentWebModel = new CreateCommentWebModel
+ {
+ Message = MESSAGE
+ };
+
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.CommentController.AddComment(Guid.NewGuid(), createCommentWebModel, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+
+ #region Read
+ [Test]
+ public void GetById_ReturnsTheComment_WhenItExists()
+ {
+ Guid id = Guid.NewGuid();
+
+ ReadCommentServiceModel readCommentServiceModel = new ReadCommentServiceModel
+ {
+ Message = MESSAGE
+ };
+ ReadCommentWebModel readCommentWebModel = new ReadCommentWebModel
+ {
+ Message = MESSAGE
+ };
+
+ this.CommentServiceMock.Setup(p => p.GetCommentById(It.IsAny<Guid>())).Returns(Task.FromResult(readCommentServiceModel));
+ this.MapperMock.Setup(p => p.Map<ReadCommentWebModel>(It.IsAny<ReadCommentServiceModel>())).Returns(readCommentWebModel);
+
+ IActionResult result = this.CommentController.GetCommentById(id).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ ReadCommentWebModel resultModel = okObjectResult.Value as Models.Comment.ReadCommentWebModel;
+
+ Assert.AreEqual(MESSAGE, resultModel.Message);
+ }
+ #endregion
+
+ #region Update
+ [Test]
+ public void Update_ShouldReturnOkResult_WhenCommentIsUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ UpdateCommentWebModel updateCommentWebModel = new UpdateCommentWebModel
+ {
+ NewMessage = MESSAGE
+ };
+ UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.CommentServiceMock.Setup(p => p.UpdateComment(It.IsAny<UpdateCommentServiceModel>())).Returns(Task.FromResult(id));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UpdateCommentServiceModel>(It.IsAny<UpdateCommentWebModel>())).Returns(updateCommentServiceModel);
+
+ IActionResult result = this.CommentController.UpdateComment(Guid.Empty, updateCommentWebModel, null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ object resultModel = okObjectResult.Value;
+ string[] resultAsString = resultModel.ToString().Split(' ').ToArray();
+
+ Assert.AreEqual(id.ToString(), resultAsString[3]);
+ }
+
+ [Test]
+ public void Update_ShouldReturnBadObjectResult_WhenCommentIsNotUpdatedSuccessfully()
+ {
+ string message = "Unable to update comment!";
+ UpdateCommentWebModel updateCommentWebModel = new UpdateCommentWebModel
+ {
+ NewMessage = MESSAGE
+ };
+ UpdateCommentServiceModel updateCommentServiceModel = new UpdateCommentServiceModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.CommentServiceMock.Setup(p => p.UpdateComment(It.IsAny<UpdateCommentServiceModel>())).Returns(Task.FromResult(Guid.Empty));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UpdateCommentServiceModel>(It.IsAny<UpdateCommentWebModel>())).Returns(updateCommentServiceModel);
+
+ IActionResult result = this.CommentController.UpdateComment(Guid.Empty, updateCommentWebModel, null).Result;
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+
+ [Test]
+ public void Update_ShouldReturnUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ UpdateCommentWebModel updateCommentWebModel = new UpdateCommentWebModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.CommentController.UpdateComment(Guid.Empty, updateCommentWebModel, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+
+ #region Delete
+ [Test]
+ public void Delete_ReturnsOkResult_WhenCommentIsDeletedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+
+ this.CommentServiceMock.Setup(p => p.DeleteComment(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.CommentController.DeleteComment(id, null).Result;
+
+ Assert.IsInstanceOf<OkResult>(result);
+ }
+
+ [Test]
+ public void DeletComment_ReturnsBadRequestObjectResult_WhenCommentIsNotDeletedSuccessfully()
+ {
+ string message = "Could not delete Comment";
+ Guid id = Guid.NewGuid();
+
+ this.CommentServiceMock.Setup(p => p.DeleteComment(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.CommentController.DeleteComment(id, null).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+
+ [Test]
+ public void DeletComment_ReturnsUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ this.CommentServiceMock.Setup(p => p.ValidateJwtForComment(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.CommentController.DeleteComment(Guid.Empty, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
new file mode 100644
index 0000000..01f67e5
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models;
+using DevHive.Web.Controllers;
+using DevHive.Web.Models.Comment;
+using DevHive.Web.Models.Feed;
+using DevHive.Web.Models.Post;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Web.Tests
+{
+ [TestFixture]
+ public class FeedControllerTests
+ {
+ private Mock<IFeedService> FeedServiceMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private FeedController FeedController { get; set; }
+
+ #region SetUp
+ [SetUp]
+ public void SetUp()
+ {
+ this.FeedServiceMock = new Mock<IFeedService>();
+ this.MapperMock = new Mock<IMapper>();
+ this.FeedController = new FeedController(this.FeedServiceMock.Object, this.MapperMock.Object);
+ }
+ #endregion
+
+ #region GetPosts
+ [Test]
+ public async Task GetPosts_ReturnsOkObjectResultWithCorrectReadPageWebModel_WhenPostsExist()
+ {
+ GetPageWebModel getPageWebModel = new GetPageWebModel { };
+ GetPageServiceModel getPageServiceModel = new GetPageServiceModel { };
+ ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel { };
+ ReadPageWebModel readPageWebModel = new ReadPageWebModel
+ {
+ Posts = new List<ReadPostWebModel>
+ {
+ new ReadPostWebModel(),
+ new ReadPostWebModel(),
+ new ReadPostWebModel()
+ }
+ };
+
+ this.FeedServiceMock.Setup(p => p.GetPage(It.IsAny<GetPageServiceModel>())).Returns(Task.FromResult(readPageServiceModel));
+ this.MapperMock.Setup(p => p.Map<GetPageServiceModel>(It.IsAny<GetPageWebModel>())).Returns(getPageServiceModel);
+ this.MapperMock.Setup(p => p.Map<ReadPageWebModel>(It.IsAny<ReadPageServiceModel>())).Returns(readPageWebModel);
+
+ IActionResult result = await this.FeedController.GetPosts(Guid.Empty, getPageWebModel);
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ ReadPageWebModel resultModel = okObjectResult.Value as Models.Comment.ReadPageWebModel;
+
+ Assert.AreEqual(3, resultModel.Posts.Count);
+ }
+ #endregion
+
+ #region GetUserPosts
+ [Test]
+ public async Task GetUserPosts_GetsPostsOfUser_WhenTheyExist()
+ {
+ GetPageWebModel getPageWebModel = new GetPageWebModel { };
+ GetPageServiceModel getPageServiceModel = new GetPageServiceModel { };
+ ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel { };
+ ReadPageWebModel readPageWebModel = new ReadPageWebModel
+ {
+ Posts = new List<ReadPostWebModel>
+ {
+ new ReadPostWebModel(),
+ new ReadPostWebModel(),
+ new ReadPostWebModel()
+ }
+ };
+
+ this.FeedServiceMock.Setup(p => p.GetUserPage(It.IsAny<GetPageServiceModel>())).Returns(Task.FromResult(readPageServiceModel));
+ this.MapperMock.Setup(p => p.Map<GetPageServiceModel>(It.IsAny<GetPageWebModel>())).Returns(getPageServiceModel);
+ this.MapperMock.Setup(p => p.Map<ReadPageWebModel>(It.IsAny<ReadPageServiceModel>())).Returns(readPageWebModel);
+
+ IActionResult result = await this.FeedController.GetUserPosts(null, getPageWebModel);
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ ReadPageWebModel resultModel = okObjectResult.Value as Models.Comment.ReadPageWebModel;
+
+ Assert.AreEqual(3, resultModel.Posts.Count);
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/PostController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/PostController.Tests.cs
new file mode 100644
index 0000000..3a4e45e
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Web.Tests/PostController.Tests.cs
@@ -0,0 +1,248 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models.Post;
+using DevHive.Web.Controllers;
+using DevHive.Web.Models.Post;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Web.Tests
+{
+ [TestFixture]
+ public class PostControllerTests
+ {
+ const string MESSAGE = "Gosho Trapov";
+ private Mock<IPostService> PostServiceMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private PostController PostController { get; set; }
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.PostServiceMock = new Mock<IPostService>();
+ this.MapperMock = new Mock<IMapper>();
+ this.PostController = new PostController(this.PostServiceMock.Object, this.MapperMock.Object);
+ }
+
+ #region Create
+ [Test]
+ public void CreatePost_ReturnsOkObjectResult_WhenPostIsSuccessfullyCreated()
+ {
+ CreatePostWebModel createPostWebModel = new CreatePostWebModel
+ {
+ Message = MESSAGE
+ };
+ CreatePostServiceModel createPostServiceModel = new CreatePostServiceModel
+ {
+ Message = MESSAGE
+ };
+ Guid id = Guid.NewGuid();
+
+ this.MapperMock.Setup(p => p.Map<CreatePostServiceModel>(It.IsAny<CreatePostWebModel>())).Returns(createPostServiceModel);
+ this.PostServiceMock.Setup(p => p.CreatePost(It.IsAny<CreatePostServiceModel>())).Returns(Task.FromResult(id));
+ this.PostServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Create(Guid.Empty, createPostWebModel, null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ var splitted = (result as OkObjectResult).Value
+ .ToString()
+ .Split('{', '}', '=', ' ')
+ .Where(x => !string.IsNullOrEmpty(x))
+ .ToArray();
+
+ Guid resultId = Guid.Parse(splitted[1]);
+
+ Assert.AreEqual(id, resultId);
+ }
+
+ [Test]
+ public void CreatePost_ReturnsBadRequestObjectResult_WhenPostIsNotCreatedSuccessfully()
+ {
+ CreatePostWebModel createTechnologyWebModel = new CreatePostWebModel
+ {
+ Message = MESSAGE
+ };
+ CreatePostServiceModel createTechnologyServiceModel = new CreatePostServiceModel
+ {
+ Message = MESSAGE
+ };
+ Guid id = Guid.Empty;
+ string errorMessage = $"Could not create post!";
+
+ this.MapperMock.Setup(p => p.Map<CreatePostServiceModel>(It.IsAny<CreatePostWebModel>())).Returns(createTechnologyServiceModel);
+ this.PostServiceMock.Setup(p => p.CreatePost(It.IsAny<CreatePostServiceModel>())).Returns(Task.FromResult(id));
+ this.PostServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Create(Guid.Empty, createTechnologyWebModel, null).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequsetObjectResult = result as BadRequestObjectResult;
+ string resultMessage = badRequsetObjectResult.Value.ToString();
+
+ Assert.AreEqual(errorMessage, resultMessage);
+ }
+
+ [Test]
+ public void CreatePost_ReturnsUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ Guid id = Guid.NewGuid();
+ CreatePostWebModel createPostWebModel = new CreatePostWebModel
+ {
+ Message = MESSAGE
+ };
+
+ this.PostServiceMock.Setup(p => p.ValidateJwtForCreating(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.PostController.Create(Guid.NewGuid(), createPostWebModel, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+
+ #region Read
+ [Test]
+ public void GetById_ReturnsThePost_WhenItExists()
+ {
+ Guid id = Guid.NewGuid();
+
+ ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
+ {
+ Message = MESSAGE
+ };
+ ReadPostWebModel readPostWebModel = new ReadPostWebModel
+ {
+ Message = MESSAGE
+ };
+
+ this.PostServiceMock.Setup(p => p.GetPostById(It.IsAny<Guid>())).Returns(Task.FromResult(readPostServiceModel));
+ this.MapperMock.Setup(p => p.Map<ReadPostWebModel>(It.IsAny<ReadPostServiceModel>())).Returns(readPostWebModel);
+
+ IActionResult result = this.PostController.GetById(id).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ ReadPostWebModel resultModel = okObjectResult.Value as Models.Post.ReadPostWebModel;
+
+ Assert.AreEqual(MESSAGE, resultModel.Message);
+ }
+ #endregion
+
+ #region Update
+ [Test]
+ public void Update_ShouldReturnOkResult_WhenPostIsUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ UpdatePostWebModel updatePostWebModel = new UpdatePostWebModel
+ {
+ NewMessage = MESSAGE
+ };
+ UpdatePostServiceModel updatePostServiceModel = new UpdatePostServiceModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.PostServiceMock.Setup(p => p.UpdatePost(It.IsAny<UpdatePostServiceModel>())).Returns(Task.FromResult(id));
+ this.MapperMock.Setup(p => p.Map<UpdatePostServiceModel>(It.IsAny<UpdatePostWebModel>())).Returns(updatePostServiceModel);
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Update(id, updatePostWebModel, null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+ }
+
+ [Test]
+ public void Update_ShouldReturnBadObjectResult_WhenPostIsNotUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ string message = "Could not update post!";
+ UpdatePostWebModel updatePostWebModel = new UpdatePostWebModel
+ {
+ NewMessage = MESSAGE
+ };
+ UpdatePostServiceModel updatePostServiceModel = new UpdatePostServiceModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.PostServiceMock.Setup(p => p.UpdatePost(It.IsAny<UpdatePostServiceModel>())).Returns(Task.FromResult(Guid.Empty));
+ this.MapperMock.Setup(p => p.Map<UpdatePostServiceModel>(It.IsAny<UpdatePostWebModel>())).Returns(updatePostServiceModel);
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Update(id, updatePostWebModel, null).Result;
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+
+ [Test]
+ public void Update_ShouldReturnUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ UpdatePostWebModel updatePostWebModel = new UpdatePostWebModel
+ {
+ NewMessage = MESSAGE
+ };
+
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.PostController.Update(Guid.Empty, updatePostWebModel, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+
+ #region Delete
+ [Test]
+ public void Delete_ReturnsOkResult_WhenPostIsDeletedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+
+ this.PostServiceMock.Setup(p => p.DeletePost(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Delete(id, null).Result;
+
+ Assert.IsInstanceOf<OkResult>(result);
+ }
+
+ [Test]
+ public void Delete_ReturnsBadRequestObjectResult_WhenPostIsNotDeletedSuccessfully()
+ {
+ string message = "Could not delete Post";
+ Guid id = Guid.NewGuid();
+
+ this.PostServiceMock.Setup(p => p.DeletePost(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.PostController.Delete(id, null).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+
+ [Test]
+ public void DeletePost_ReturnsUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ this.PostServiceMock.Setup(p => p.ValidateJwtForPost(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.PostController.Delete(Guid.Empty, null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/RoleController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/RoleController.Tests.cs
new file mode 100644
index 0000000..067b4e4
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Web.Tests/RoleController.Tests.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models.Identity.Role;
+using DevHive.Web.Controllers;
+using DevHive.Web.Models.Identity.Role;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Web.Tests
+{
+ [TestFixture]
+ public class RoleControllerTests
+ {
+ const string NAME = "Gosho Trapov";
+ private Mock<IRoleService> RoleServiceMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private RoleController RoleController { get; set; }
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.RoleServiceMock = new Mock<IRoleService>();
+ this.MapperMock = new Mock<IMapper>();
+ this.RoleController = new RoleController(this.RoleServiceMock.Object, this.MapperMock.Object);
+ }
+
+ #region Create
+ [Test]
+ public void CreateRole_ReturnsOkObjectResult_WhenRoleIsSuccessfullyCreated()
+ {
+ CreateRoleWebModel createRoleWebModel = new CreateRoleWebModel
+ {
+ Name = NAME
+ };
+ CreateRoleServiceModel createRoleServiceModel = new CreateRoleServiceModel
+ {
+ Name = NAME
+ };
+ Guid id = Guid.NewGuid();
+
+ this.MapperMock.Setup(p => p.Map<CreateRoleServiceModel>(It.IsAny<CreateRoleWebModel>())).Returns(createRoleServiceModel);
+ this.RoleServiceMock.Setup(p => p.CreateRole(It.IsAny<CreateRoleServiceModel>())).Returns(Task.FromResult(id));
+
+ IActionResult result = this.RoleController.Create(createRoleWebModel).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ var splitted = (result as OkObjectResult).Value
+ .ToString()
+ .Split('{', '}', '=', ' ')
+ .Where(x => !string.IsNullOrEmpty(x))
+ .ToArray();
+
+ Guid resultId = Guid.Parse(splitted[1]);
+
+ Assert.AreEqual(id, resultId);
+ }
+
+ [Test]
+ public void CreateRole_ReturnsBadRequestObjectResult_WhenRoleIsNotCreatedSuccessfully()
+ {
+ CreateRoleWebModel createTechnologyWebModel = new CreateRoleWebModel
+ {
+ Name = NAME
+ };
+ CreateRoleServiceModel createTechnologyServiceModel = new CreateRoleServiceModel
+ {
+ Name = NAME
+ };
+ Guid id = Guid.Empty;
+ string errorMessage = $"Could not create role {NAME}";
+
+ this.MapperMock.Setup(p => p.Map<CreateRoleServiceModel>(It.IsAny<CreateRoleWebModel>())).Returns(createTechnologyServiceModel);
+ this.RoleServiceMock.Setup(p => p.CreateRole(It.IsAny<CreateRoleServiceModel>())).Returns(Task.FromResult(id));
+
+ IActionResult result = this.RoleController.Create(createTechnologyWebModel).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequsetObjectResult = result as BadRequestObjectResult;
+ string resultMessage = badRequsetObjectResult.Value.ToString();
+
+ Assert.AreEqual(errorMessage, resultMessage);
+ }
+ #endregion
+
+ #region Read
+ [Test]
+ public void GetById_ReturnsTheRole_WhenItExists()
+ {
+ Guid id = Guid.NewGuid();
+
+ RoleServiceModel roleServiceModel = new RoleServiceModel
+ {
+ Name = NAME
+ };
+ RoleWebModel roleWebModel = new RoleWebModel
+ {
+ Name = NAME
+ };
+
+ this.RoleServiceMock.Setup(p => p.GetRoleById(It.IsAny<Guid>())).Returns(Task.FromResult(roleServiceModel));
+ this.MapperMock.Setup(p => p.Map<RoleWebModel>(It.IsAny<RoleServiceModel>())).Returns(roleWebModel);
+
+ IActionResult result = this.RoleController.GetById(id).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ RoleWebModel resultModel = okObjectResult.Value as Models.Identity.Role.RoleWebModel;
+
+ Assert.AreEqual(NAME, resultModel.Name);
+ }
+ #endregion
+
+ #region Update
+ [Test]
+ public void Update_ShouldReturnOkResult_WhenRoleIsUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ UpdateRoleWebModel updateRoleWebModel = new UpdateRoleWebModel
+ {
+ Name = NAME
+ };
+ UpdateRoleServiceModel updateRoleServiceModel = new UpdateRoleServiceModel
+ {
+ Name = NAME
+ };
+
+ this.RoleServiceMock.Setup(p => p.UpdateRole(It.IsAny<UpdateRoleServiceModel>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UpdateRoleServiceModel>(It.IsAny<UpdateRoleWebModel>())).Returns(updateRoleServiceModel);
+
+ IActionResult result = this.RoleController.Update(id, updateRoleWebModel).Result;
+
+ Assert.IsInstanceOf<OkResult>(result);
+ }
+
+ [Test]
+ public void Update_ShouldReturnBadObjectResult_WhenRoleIsNotUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ string message = "Could not update role!";
+ UpdateRoleWebModel updateRoleWebModel = new UpdateRoleWebModel
+ {
+ Name = NAME
+ };
+ UpdateRoleServiceModel updateRoleServiceModel = new UpdateRoleServiceModel
+ {
+ Name = NAME
+ };
+
+ this.RoleServiceMock.Setup(p => p.UpdateRole(It.IsAny<UpdateRoleServiceModel>())).Returns(Task.FromResult(false));
+ this.MapperMock.Setup(p => p.Map<UpdateRoleServiceModel>(It.IsAny<UpdateRoleWebModel>())).Returns(updateRoleServiceModel);
+
+ IActionResult result = this.RoleController.Update(id, updateRoleWebModel).Result;
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+ #endregion
+
+ #region Delete
+ [Test]
+ public void Delete_ReturnsOkResult_WhenRoleIsDeletedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+
+ this.RoleServiceMock.Setup(p => p.DeleteRole(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.RoleController.Delete(id).Result;
+
+ Assert.IsInstanceOf<OkResult>(result);
+ }
+
+ [Test]
+ public void Delet_ReturnsBadRequestObjectResult_WhenRoleIsNotDeletedSuccessfully()
+ {
+ string message = "Could not delete role!";
+ Guid id = Guid.NewGuid();
+
+ this.RoleServiceMock.Setup(p => p.DeleteRole(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.RoleController.Delete(id).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs
index b7d38da..164bcbf 100644
--- a/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs
+++ b/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs
@@ -21,6 +21,7 @@ namespace DevHive.Web.Tests
private Mock<IMapper> MapperMock { get; set; }
private TechnologyController TechnologyController { get; set; }
+ #region SetUp
[SetUp]
public void SetUp()
{
@@ -28,6 +29,7 @@ namespace DevHive.Web.Tests
this.MapperMock = new Mock<IMapper>();
this.TechnologyController = new TechnologyController(this.TechnologyServiceMock.Object, this.MapperMock.Object);
}
+ #endregion
#region Create
[Test]
@@ -95,24 +97,24 @@ namespace DevHive.Web.Tests
{
Guid id = Guid.NewGuid();
- CreateTechnologyServiceModel createTechnologyServiceModel = new CreateTechnologyServiceModel
+ ReadTechnologyWebModel readTechnologyWebModel = new ReadTechnologyWebModel
{
Name = NAME
};
- CreateTechnologyWebModel createTechnologyWebModel = new CreateTechnologyWebModel
+ ReadTechnologyServiceModel readTechnologyServiceModel = new ReadTechnologyServiceModel
{
Name = NAME
};
- this.TechnologyServiceMock.Setup(p => p.GetTechnologyById(It.IsAny<Guid>())).Returns(Task.FromResult(createTechnologyServiceModel));
- this.MapperMock.Setup(p => p.Map<CreateTechnologyWebModel>(It.IsAny<CreateTechnologyServiceModel>())).Returns(createTechnologyWebModel);
+ this.TechnologyServiceMock.Setup(p => p.GetTechnologyById(It.IsAny<Guid>())).Returns(Task.FromResult(readTechnologyServiceModel));
+ this.MapperMock.Setup(p => p.Map<ReadTechnologyWebModel>(It.IsAny<ReadTechnologyServiceModel>())).Returns(readTechnologyWebModel);
IActionResult result = this.TechnologyController.GetById(id).Result;
Assert.IsInstanceOf<OkObjectResult>(result);
OkObjectResult okObjectResult = result as OkObjectResult;
- CreateTechnologyWebModel resultModel = okObjectResult.Value as Models.Technology.CreateTechnologyWebModel;
+ ReadTechnologyWebModel resultModel = okObjectResult.Value as Models.Technology.ReadTechnologyWebModel;
Assert.AreEqual(NAME, resultModel.Name);
}
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/UserController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/UserController.Tests.cs
new file mode 100644
index 0000000..c1431c8
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Web.Tests/UserController.Tests.cs
@@ -0,0 +1,257 @@
+using System;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Common.Models.Identity;
+using DevHive.Services.Interfaces;
+using DevHive.Services.Models.Identity.User;
+using DevHive.Web.Controllers;
+using DevHive.Web.Models.Identity.User;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using NUnit.Framework;
+
+namespace DevHive.Web.Tests
+{
+ [TestFixture]
+ public class UserControllerTests
+ {
+ const string USERNAME = "Gosho Trapov";
+ private Mock<IUserService> UserServiceMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private UserController UserController { get; set; }
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.UserServiceMock = new Mock<IUserService>();
+ this.MapperMock = new Mock<IMapper>();
+ this.UserController = new UserController(this.UserServiceMock.Object, this.MapperMock.Object);
+ }
+
+ #region Create
+ [Test]
+ public void LoginUser_ReturnsOkObjectResult_WhenUserIsSuccessfullyLoggedIn()
+ {
+ Guid id = Guid.NewGuid();
+ LoginWebModel loginWebModel = new LoginWebModel
+ {
+ UserName = USERNAME
+ };
+ LoginServiceModel loginServiceModel = new LoginServiceModel
+ {
+ UserName = USERNAME
+ };
+ string token = "goshotrapov";
+ TokenModel tokenModel = new TokenModel(token);
+ TokenWebModel tokenWebModel = new TokenWebModel(token);
+
+ this.MapperMock.Setup(p => p.Map<LoginServiceModel>(It.IsAny<LoginWebModel>())).Returns(loginServiceModel);
+ this.MapperMock.Setup(p => p.Map<TokenWebModel>(It.IsAny<TokenModel>())).Returns(tokenWebModel);
+ this.UserServiceMock.Setup(p => p.LoginUser(It.IsAny<LoginServiceModel>())).Returns(Task.FromResult(tokenModel));
+
+ IActionResult result = this.UserController.Login(loginWebModel).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ var resultToken = ((result as OkObjectResult).Value as TokenWebModel).Token;
+
+ Assert.AreEqual(token, resultToken);
+ }
+
+ [Test]
+ public void RegisterUser_ReturnsOkObjectResult_WhenUserIsSuccessfullyRegistered()
+ {
+ Guid id = Guid.NewGuid();
+ RegisterWebModel registerWebModel = new RegisterWebModel
+ {
+ UserName = USERNAME
+ };
+ RegisterServiceModel registerServiceModel = new RegisterServiceModel
+ {
+ UserName = USERNAME
+ };
+ string token = "goshotrapov";
+ TokenModel tokenModel = new TokenModel(token);
+ TokenWebModel tokenWebModel = new TokenWebModel(token);
+
+ this.MapperMock.Setup(p => p.Map<RegisterServiceModel>(It.IsAny<RegisterWebModel>())).Returns(registerServiceModel);
+ this.MapperMock.Setup(p => p.Map<TokenWebModel>(It.IsAny<TokenModel>())).Returns(tokenWebModel);
+ this.UserServiceMock.Setup(p => p.RegisterUser(It.IsAny<RegisterServiceModel>())).Returns(Task.FromResult(tokenModel));
+
+ IActionResult result = this.UserController.Register(registerWebModel).Result;
+
+ Assert.IsInstanceOf<CreatedResult>(result);
+
+ CreatedResult createdResult = result as CreatedResult;
+ TokenWebModel resultModel = (createdResult.Value as TokenWebModel);
+
+ Assert.AreEqual(token, resultModel.Token);
+ }
+ #endregion
+
+ #region Read
+ [Test]
+ public void GetById_ReturnsTheUser_WhenItExists()
+ {
+ Guid id = Guid.NewGuid();
+
+ UserServiceModel userServiceModel = new UserServiceModel
+ {
+ UserName = USERNAME
+ };
+ UserWebModel userWebModel = new UserWebModel
+ {
+ UserName = USERNAME
+ };
+
+ this.UserServiceMock.Setup(p => p.GetUserById(It.IsAny<Guid>())).Returns(Task.FromResult(userServiceModel));
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UserWebModel>(It.IsAny<UserServiceModel>())).Returns(userWebModel);
+
+ IActionResult result = this.UserController.GetById(id, null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ UserWebModel resultModel = okObjectResult.Value as Models.Identity.User.UserWebModel;
+
+ Assert.AreEqual(USERNAME, resultModel.UserName);
+ }
+
+ [Test]
+ public void GetById_ReturnsUnauthorizedResult_WhenUserIsNotAuthorized()
+ {
+ Guid id = Guid.NewGuid();
+ UserWebModel userWebModel = new UserWebModel
+ {
+ UserName = USERNAME
+ };
+
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.UserController.GetById(Guid.NewGuid(), null).Result;
+
+ Assert.IsInstanceOf<UnauthorizedResult>(result);
+ }
+
+ [Test]
+ public void GetUser_ReturnsTheUser_WhenItExists()
+ {
+ Guid id = Guid.NewGuid();
+ UserWebModel userWebModel = new UserWebModel
+ {
+ UserName = USERNAME
+ };
+ UserServiceModel userServiceModel = new UserServiceModel
+ {
+ UserName = USERNAME
+ };
+
+ this.UserServiceMock.Setup(p => p.GetUserByUsername(It.IsAny<string>())).Returns(Task.FromResult(userServiceModel));
+ this.MapperMock.Setup(p => p.Map<UserWebModel>(It.IsAny<UserServiceModel>())).Returns(userWebModel);
+
+ IActionResult result = this.UserController.GetUser(null).Result;
+
+ Assert.IsInstanceOf<OkObjectResult>(result);
+
+ OkObjectResult okObjectResult = result as OkObjectResult;
+ UserWebModel resultModel = okObjectResult.Value as Models.Identity.User.UserWebModel;
+
+ Assert.AreEqual(USERNAME, resultModel.UserName);
+ }
+ #endregion
+
+ #region Update
+ [Test]
+ public void Update_ShouldReturnOkResult_WhenUserIsUpdatedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+ UpdateUserWebModel updateUserWebModel = new UpdateUserWebModel
+ {
+ UserName = USERNAME
+ };
+ UpdateUserServiceModel updateUserServiceModel = new UpdateUserServiceModel
+ {
+ UserName = USERNAME
+ };
+ UserServiceModel userServiceModel = new UserServiceModel
+ {
+ UserName = USERNAME
+ };
+
+ this.UserServiceMock.Setup(p => p.UpdateUser(It.IsAny<UpdateUserServiceModel>())).Returns(Task.FromResult(userServiceModel));
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UpdateUserServiceModel>(It.IsAny<UpdateUserWebModel>())).Returns(updateUserServiceModel);
+
+ IActionResult result = this.UserController.Update(id, updateUserWebModel, null).Result;
+
+ Assert.IsInstanceOf<AcceptedResult>(result);
+ }
+
+ [Test]
+ public void UpdateProfilePicture_ShouldReturnOkObjectResult_WhenProfilePictureIsUpdatedSuccessfully()
+ {
+ string profilePictureURL = "goshotrapov";
+ UpdateProfilePictureWebModel updateProfilePictureWebModel = new UpdateProfilePictureWebModel();
+ UpdateProfilePictureServiceModel updateProfilePictureServiceModel = new UpdateProfilePictureServiceModel();
+ ProfilePictureServiceModel profilePictureServiceModel = new ProfilePictureServiceModel
+ {
+ ProfilePictureURL = profilePictureURL
+ };
+ ProfilePictureWebModel profilePictureWebModel = new ProfilePictureWebModel
+ {
+ ProfilePictureURL = profilePictureURL
+ };
+
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.MapperMock.Setup(p => p.Map<UpdateProfilePictureServiceModel>(It.IsAny<UpdateProfilePictureWebModel>())).Returns(updateProfilePictureServiceModel);
+ this.UserServiceMock.Setup(p => p.UpdateProfilePicture(It.IsAny<UpdateProfilePictureServiceModel>())).Returns(Task.FromResult(profilePictureServiceModel));
+ this.MapperMock.Setup(p => p.Map<ProfilePictureWebModel>(It.IsAny<ProfilePictureServiceModel>())).Returns(profilePictureWebModel);
+
+
+ IActionResult result = this.UserController.UpdateProfilePicture(Guid.Empty, updateProfilePictureWebModel, null).Result;
+
+ Assert.IsInstanceOf<AcceptedResult>(result);
+
+ AcceptedResult acceptedResult = result as AcceptedResult;
+ ProfilePictureWebModel resultModel = acceptedResult.Value as Models.Identity.User.ProfilePictureWebModel;
+
+ Assert.AreEqual(profilePictureURL, resultModel.ProfilePictureURL);
+ }
+ #endregion
+
+ #region Delete
+ [Test]
+ public void Delete_ReturnsOkResult_WhenUserIsDeletedSuccessfully()
+ {
+ Guid id = Guid.NewGuid();
+
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.UserServiceMock.Setup(p => p.DeleteUser(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+
+ IActionResult result = this.UserController.Delete(id, null).Result;
+
+ Assert.IsInstanceOf<OkResult>(result);
+ }
+
+ [Test]
+ public void Delete_ReturnsBadRequestObjectResult_WhenUserIsNotDeletedSuccessfully()
+ {
+ string message = "Could not delete User";
+ Guid id = Guid.NewGuid();
+
+ this.UserServiceMock.Setup(p => p.ValidJWT(It.IsAny<Guid>(), It.IsAny<string>())).Returns(Task.FromResult(true));
+ this.UserServiceMock.Setup(p => p.DeleteUser(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ IActionResult result = this.UserController.Delete(id, null).Result;
+
+ Assert.IsInstanceOf<BadRequestObjectResult>(result);
+
+ BadRequestObjectResult badRequestObjectResult = result as BadRequestObjectResult;
+ string resultModel = badRequestObjectResult.Value.ToString();
+
+ Assert.AreEqual(message, resultModel);
+ }
+ #endregion
+ }
+}
diff --git a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs b/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs
index 159582d..0909f6d 100644
--- a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs
+++ b/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs
@@ -1,6 +1,6 @@
using AutoMapper;
using DevHive.Services.Models;
-using DevHive.Web.Controllers;
+using DevHive.Web.Models.Comment;
using DevHive.Web.Models.Feed;
namespace DevHive.Web.Configurations.Mapping
diff --git a/src/DevHive.Web/Controllers/FeedController.cs b/src/DevHive.Web/Controllers/FeedController.cs
index 2f14cf3..abca3e4 100644
--- a/src/DevHive.Web/Controllers/FeedController.cs
+++ b/src/DevHive.Web/Controllers/FeedController.cs
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using AutoMapper;
using DevHive.Services.Interfaces;
using DevHive.Services.Models;
+using DevHive.Web.Models.Comment;
using DevHive.Web.Models.Feed;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
diff --git a/src/DevHive.Web/Controllers/PostController.cs b/src/DevHive.Web/Controllers/PostController.cs
index 0a5cf73..d3fdbf6 100644
--- a/src/DevHive.Web/Controllers/PostController.cs
+++ b/src/DevHive.Web/Controllers/PostController.cs
@@ -68,7 +68,7 @@ namespace DevHive.Web.Controllers
Guid id = await this._postService.UpdatePost(updatePostServiceModel);
return id == Guid.Empty ?
- new BadRequestObjectResult("Unable to update post!") :
+ new BadRequestObjectResult("Could not update post!") :
new OkObjectResult(new { Id = id });
}
#endregion
@@ -82,7 +82,7 @@ namespace DevHive.Web.Controllers
return await this._postService.DeletePost(id) ?
new OkResult() :
- new BadRequestObjectResult("Could not delete Comment");
+ new BadRequestObjectResult("Could not delete Post");
}
#endregion
}
diff --git a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs b/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs
index 839aaa6..f429313 100644
--- a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs
+++ b/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using DevHive.Web.Models.Post;
-namespace DevHive.Web.Controllers
+namespace DevHive.Web.Models.Comment
{
public class ReadPageWebModel
{