aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DevHive.Data/DevHiveContext.cs24
-rw-r--r--src/DevHive.Data/Interfaces/Models/IPost.cs2
-rw-r--r--src/DevHive.Data/Interfaces/Models/IRating.cs14
-rw-r--r--src/DevHive.Data/Interfaces/Models/IUser.cs3
-rw-r--r--src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs15
-rw-r--r--src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs476
-rw-r--r--src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.Designer.cs478
-rw-r--r--src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.cs69
-rw-r--r--src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.Designer.cs510
-rw-r--r--src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.cs121
-rw-r--r--src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.cs78
-rw-r--r--src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.Designer.cs (renamed from src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.Designer.cs)89
-rw-r--r--src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.cs (renamed from src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs)127
-rw-r--r--src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs48
-rw-r--r--src/DevHive.Data/Models/Post.cs3
-rw-r--r--src/DevHive.Data/Models/Rating.cs16
-rw-r--r--src/DevHive.Data/Models/User.cs10
-rw-r--r--src/DevHive.Data/RelationModels/UserFriends.cs1
-rw-r--r--src/DevHive.Data/Repositories/RatingRepository.cs37
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs30
-rw-r--r--src/DevHive.Services/Configurations/Mapping/RatingMappings.cs12
-rw-r--r--src/DevHive.Services/Models/Post/Rating/RatePostServiceModel.cs13
-rw-r--r--src/DevHive.Services/Models/Post/Rating/ReadRatingServiceModel.cs13
-rw-r--r--src/DevHive.Services/Services/FeedService.cs2
-rw-r--r--src/DevHive.Services/Services/RatingService.cs54
-rw-r--r--src/DevHive.Services/Services/UserService.cs79
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs1
-rw-r--r--src/DevHive.Web/Controllers/UserController.cs1
28 files changed, 447 insertions, 1879 deletions
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index e391882..e7c606f 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -15,6 +15,8 @@ namespace DevHive.Data
public DbSet<Language> Languages { get; set; }
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
+ public DbSet<UserFriends> UserFriends { get; set; }
+ public DbSet<Rating> Rating { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -29,9 +31,16 @@ namespace DevHive.Data
.WithMany(x => x.Users);
/* Friends */
- //TODO: Look into the User - User
builder.Entity<UserFriends>()
- .HasKey(uu => new { uu.UserId, uu.FriendId });
+ .HasKey(x => new { x.UserId, x.FriendId });
+
+ // builder.Entity<UserFriends>()
+ // .HasOne(x => x.Friend)
+ // .WithMany(x => x.Friends);
+
+ builder.Entity<User>()
+ .HasMany(x => x.Friends)
+ .WithOne(x => x.User);
/* Languages */
builder.Entity<User>()
@@ -45,9 +54,6 @@ namespace DevHive.Data
.UsingEntity(x => x.ToTable("LanguageUser"));
/* Technologies */
- builder.Entity<Technology>()
- .HasKey(x => x.Id);
-
builder.Entity<User>()
.HasMany(x => x.Technologies)
.WithMany(x => x.Users)
@@ -60,12 +66,16 @@ namespace DevHive.Data
/* Post */
builder.Entity<Post>()
+ .HasOne(x => x.Creator)
+ .WithMany(x => x.Posts);
+
+ builder.Entity<Post>()
.HasMany(x => x.Comments)
.WithOne(x => x.Post);
builder.Entity<Post>()
- .HasOne(x => x.Creator)
- .WithMany(x => x.Posts);
+ .HasOne(x => x.Rating)
+ .WithOne(x => x.Post);
/* Comment */
builder.Entity<Comment>()
diff --git a/src/DevHive.Data/Interfaces/Models/IPost.cs b/src/DevHive.Data/Interfaces/Models/IPost.cs
index 86469a7..65c0fb4 100644
--- a/src/DevHive.Data/Interfaces/Models/IPost.cs
+++ b/src/DevHive.Data/Interfaces/Models/IPost.cs
@@ -14,6 +14,8 @@ namespace DevHive.Data.Interfaces.Models
List<Comment> Comments { get; set; }
+ Rating Rating { get; set; }
+
List<string> FileUrls { get; set; }
}
}
diff --git a/src/DevHive.Data/Interfaces/Models/IRating.cs b/src/DevHive.Data/Interfaces/Models/IRating.cs
new file mode 100644
index 0000000..4604a75
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/Models/IRating.cs
@@ -0,0 +1,14 @@
+using DevHive.Data.Interfaces.Models;
+using DevHive.Data.Models;
+
+namespace DevHive.Data.Interfaces.Models
+{
+ public interface IRating : IModel
+ {
+ Post Post { get; set; }
+
+ int Likes { get; set; }
+
+ int Dislikes { get; set; }
+ }
+}
diff --git a/src/DevHive.Data/Interfaces/Models/IUser.cs b/src/DevHive.Data/Interfaces/Models/IUser.cs
index 08ce385..90923fa 100644
--- a/src/DevHive.Data/Interfaces/Models/IUser.cs
+++ b/src/DevHive.Data/Interfaces/Models/IUser.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using DevHive.Data.Models;
+using DevHive.Data.RelationModels;
namespace DevHive.Data.Interfaces.Models
{
@@ -11,6 +12,6 @@ namespace DevHive.Data.Interfaces.Models
HashSet<Language> Languages { get; set; }
HashSet<Technology> Technologies { get; set; }
HashSet<Role> Roles { get; set; }
- HashSet<User> Friends { get; set; }
+ HashSet<UserFriends> Friends { get; set; }
}
}
diff --git a/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs b/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs
new file mode 100644
index 0000000..de4e3f2
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces.Repositories
+{
+ public interface IRatingRepository : IRepository<Rating>
+ {
+ Task<Rating> GetByPostId(Guid postId);
+ Task<Tuple<int, int>> GetRating(Guid postId);
+
+ Task<bool> HasUserRatedThisPost(Guid userId, Guid postId);
+ }
+}
diff --git a/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs b/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs
deleted file mode 100644
index 0e4b103..0000000
--- a/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs
+++ /dev/null
@@ -1,476 +0,0 @@
-// <auto-generated />
-using System;
-using DevHive.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-namespace DevHive.Data.Migrations
-{
- [DbContext(typeof(DevHiveContext))]
- [Migration("20210123215634_PostAndComment_Implemented")]
- partial class PostAndComment_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("PostId");
-
- b.ToTable("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Language", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<string>("Name")
- .HasColumnType("text");
-
- b.HasKey("Id");
-
- b.ToTable("Languages");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Post", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<Guid>("CreatorId")
- .HasColumnType("uuid");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.ToTable("Posts");
- });
-
- 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<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.Property<string>("UserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedEmail")
- .HasDatabaseName("EmailIndex");
-
- b.HasIndex("NormalizedUserName")
- .IsUnique()
- .HasDatabaseName("UserNameIndex");
-
- b.HasIndex("UserId");
-
- b.HasIndex("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("LanguageUser", b =>
- {
- b.Property<Guid>("LanguagesId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("UsersId")
- .HasColumnType("uuid");
-
- b.HasKey("LanguagesId", "UsersId");
-
- b.HasIndex("UsersId");
-
- b.ToTable("LanguageUser");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
- {
- b.Property<int>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .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.Post", null)
- .WithMany("Comments")
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany("Friends")
- .HasForeignKey("UserId");
- });
-
- modelBuilder.Entity("LanguageUser", b =>
- {
- b.HasOne("DevHive.Data.Models.Language", null)
- .WithMany()
- .HasForeignKey("LanguagesId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UsersId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
- {
- b.HasOne("DevHive.Data.Models.Role", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
- {
- b.HasOne("DevHive.Data.Models.Role", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("RoleUser", b =>
- {
- b.HasOne("DevHive.Data.Models.Role", null)
- .WithMany()
- .HasForeignKey("RolesId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UsersId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("TechnologyUser", b =>
- {
- b.HasOne("DevHive.Data.Models.Technology", null)
- .WithMany()
- .HasForeignKey("TechnologiesId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("UsersId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Post", b =>
- {
- b.Navigation("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.Navigation("Friends");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.Designer.cs b/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.Designer.cs
deleted file mode 100644
index 4fb21a7..0000000
--- a/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.Designer.cs
+++ /dev/null
@@ -1,478 +0,0 @@
-// <auto-generated />
-using System;
-using DevHive.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-namespace DevHive.Data.Migrations
-{
- [DbContext(typeof(DevHiveContext))]
- [Migration("20210127110304_RelationsManuallyConfigured")]
- partial class RelationsManuallyConfigured
- {
- 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("PostId");
-
- b.ToTable("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Language", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<string>("Name")
- .HasColumnType("text");
-
- b.HasKey("Id");
-
- b.ToTable("Languages");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Post", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<Guid>("CreatorId")
- .HasColumnType("uuid");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.ToTable("Posts");
- });
-
- 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("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("UserUser", b =>
- {
- b.Property<Guid>("FriendsId")
- .HasColumnType("uuid");
-
- b.HasIndex("FriendsId");
-
- b.ToTable("UserUser");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Comment", b =>
- {
- b.HasOne("DevHive.Data.Models.Post", null)
- .WithMany("Comments")
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- 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("UserUser", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany()
- .HasForeignKey("FriendsId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Post", b =>
- {
- b.Navigation("Comments");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.cs b/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.cs
deleted file mode 100644
index d52546d..0000000
--- a/src/DevHive.Data/Migrations/20210127110304_RelationsManuallyConfigured.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class RelationsManuallyConfigured : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- table: "AspNetUsers");
-
- migrationBuilder.DropIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "AspNetUsers");
-
- migrationBuilder.CreateTable(
- name: "UserUser",
- columns: table => new
- {
- FriendsId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.ForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendsId",
- column: x => x.FriendsId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_UserUser_FriendsId",
- table: "UserUser",
- column: "FriendsId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "UserUser");
-
- migrationBuilder.AddColumn<Guid>(
- name: "UserId",
- table: "AspNetUsers",
- type: "uuid",
- nullable: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.Designer.cs b/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.Designer.cs
deleted file mode 100644
index de63d70..0000000
--- a/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.Designer.cs
+++ /dev/null
@@ -1,510 +0,0 @@
-// <auto-generated />
-using System;
-using DevHive.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-namespace DevHive.Data.Migrations
-{
- [DbContext(typeof(DevHiveContext))]
- [Migration("20210127213238_RelationsManuallyConfiguredTwo")]
- partial class RelationsManuallyConfiguredTwo
- {
- 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("PostId");
-
- b.ToTable("Comments");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Language", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<string>("Name")
- .HasColumnType("text");
-
- b.HasKey("Id");
-
- b.ToTable("Languages");
- });
-
- modelBuilder.Entity("DevHive.Data.Models.Post", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<Guid>("CreatorId")
- .HasColumnType("uuid");
-
- b.Property<string>("Message")
- .HasColumnType("text");
-
- b.Property<DateTime>("TimeCreated")
- .HasColumnType("timestamp without time zone");
-
- b.HasKey("Id");
-
- b.ToTable("Posts");
- });
-
- 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<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.Property<string>("UserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedEmail")
- .HasDatabaseName("EmailIndex");
-
- b.HasIndex("NormalizedUserName")
- .IsUnique()
- .HasDatabaseName("UserNameIndex");
-
- b.HasIndex("UserId");
-
- b.HasIndex("UserName")
- .IsUnique();
-
- b.ToTable("AspNetUsers");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserUser", b =>
- {
- b.Property<Guid>("UserId")
- .HasColumnType("uuid");
-
- b.Property<Guid>("FriendId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "FriendId");
-
- b.HasIndex("FriendId");
-
- b.ToTable("UserUser");
- });
-
- 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.Post", null)
- .WithMany("Comments")
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany("Friends")
- .HasForeignKey("UserId");
- });
-
- modelBuilder.Entity("DevHive.Data.RelationModels.UserUser", 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("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("Friends");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.cs b/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.cs
deleted file mode 100644
index ad1649c..0000000
--- a/src/DevHive.Data/Migrations/20210127213238_RelationsManuallyConfiguredTwo.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class RelationsManuallyConfiguredTwo : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendsId",
- table: "UserUser");
-
- migrationBuilder.RenameColumn(
- name: "FriendsId",
- table: "UserUser",
- newName: "FriendId");
-
- migrationBuilder.RenameIndex(
- name: "IX_UserUser_FriendsId",
- table: "UserUser",
- newName: "IX_UserUser_FriendId");
-
- migrationBuilder.AddColumn<Guid>(
- name: "UserId",
- table: "UserUser",
- type: "uuid",
- nullable: false,
- defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
-
- migrationBuilder.AddColumn<Guid>(
- name: "UserId",
- table: "AspNetUsers",
- type: "uuid",
- nullable: true);
-
- migrationBuilder.AddPrimaryKey(
- name: "PK_UserUser",
- table: "UserUser",
- columns: new[] { "UserId", "FriendId" });
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendId",
- table: "UserUser",
- column: "FriendId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserUser_AspNetUsers_UserId",
- table: "UserUser",
- column: "UserId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- table: "AspNetUsers");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendId",
- table: "UserUser");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UserUser_AspNetUsers_UserId",
- table: "UserUser");
-
- migrationBuilder.DropPrimaryKey(
- name: "PK_UserUser",
- table: "UserUser");
-
- migrationBuilder.DropIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "UserUser");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "AspNetUsers");
-
- migrationBuilder.RenameColumn(
- name: "FriendId",
- table: "UserUser",
- newName: "FriendsId");
-
- migrationBuilder.RenameIndex(
- name: "IX_UserUser_FriendId",
- table: "UserUser",
- newName: "IX_UserUser_FriendsId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendsId",
- table: "UserUser",
- column: "FriendsId",
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.cs b/src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.cs
deleted file mode 100644
index e891b9f..0000000
--- a/src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace DevHive.Data.Migrations
-{
- public partial class UserFriends_Implement : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "UserUser");
-
- migrationBuilder.CreateTable(
- name: "UserFriends",
- columns: table => new
- {
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- FriendId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_UserFriends", x => new { x.UserId, x.FriendId });
- table.ForeignKey(
- name: "FK_UserFriends_AspNetUsers_FriendId",
- column: x => x.FriendId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_UserFriends_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_UserFriends_FriendId",
- table: "UserFriends",
- column: "FriendId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "UserFriends");
-
- migrationBuilder.CreateTable(
- name: "UserUser",
- columns: table => new
- {
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- FriendId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_UserUser", x => new { x.UserId, x.FriendId });
- table.ForeignKey(
- name: "FK_UserUser_AspNetUsers_FriendId",
- column: x => x.FriendId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_UserUser_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_UserUser_FriendId",
- table: "UserUser",
- column: "FriendId");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.Designer.cs b/src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.Designer.cs
index 84b6453..fc0af18 100644
--- a/src/DevHive.Data/Migrations/20210127222937_UserFriends_Implement.Designer.cs
+++ b/src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.Designer.cs
@@ -1,5 +1,6 @@
// <auto-generated />
using System;
+using System.Collections.Generic;
using DevHive.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -10,8 +11,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
[DbContext(typeof(DevHiveContext))]
- [Migration("20210127222937_UserFriends_Implement")]
- partial class UserFriends_Implement
+ [Migration("20210130171705_User_Friends_Relation")]
+ partial class User_Friends_Relation
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -27,13 +28,13 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("CreatorId")
+ b.Property<Guid?>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Message")
.HasColumnType("text");
- b.Property<Guid>("PostId")
+ b.Property<Guid?>("PostId")
.HasColumnType("uuid");
b.Property<DateTime>("TimeCreated")
@@ -41,6 +42,8 @@ namespace DevHive.Data.Migrations
b.HasKey("Id");
+ b.HasIndex("CreatorId");
+
b.HasIndex("PostId");
b.ToTable("Comments");
@@ -66,20 +69,48 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("CreatorId")
+ 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")
@@ -179,9 +210,6 @@ namespace DevHive.Data.Migrations
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
@@ -195,8 +223,6 @@ namespace DevHive.Data.Migrations
.IsUnique()
.HasDatabaseName("UserNameIndex");
- b.HasIndex("UserId");
-
b.HasIndex("UserName")
.IsUnique();
@@ -366,18 +392,34 @@ namespace DevHive.Data.Migrations
modelBuilder.Entity("DevHive.Data.Models.Comment", b =>
{
- b.HasOne("DevHive.Data.Models.Post", null)
+ b.HasOne("DevHive.Data.Models.User", "Creator")
.WithMany("Comments")
- .HasForeignKey("PostId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
+ .HasForeignKey("CreatorId");
+
+ b.HasOne("DevHive.Data.Models.Post", "Post")
+ .WithMany("Comments")
+ .HasForeignKey("PostId");
+
+ b.Navigation("Creator");
+
+ b.Navigation("Post");
});
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
+ modelBuilder.Entity("DevHive.Data.Models.Post", b =>
{
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany("Friends")
- .HasForeignKey("UserId");
+ 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 =>
@@ -389,7 +431,7 @@ namespace DevHive.Data.Migrations
.IsRequired();
b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
+ .WithMany("Friends")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -500,9 +542,18 @@ namespace DevHive.Data.Migrations
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/20210123215634_PostAndComment_Implemented.cs b/src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.cs
index 4c9f3bd..2c3b75b 100644
--- a/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs
+++ b/src/DevHive.Data/Migrations/20210130171705_User_Friends_Relation.cs
@@ -1,10 +1,11 @@
using System;
+using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
- public partial class PostAndComment_Implemented : Migration
+ public partial class User_Friends_Relation : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@@ -30,7 +31,6 @@ namespace DevHive.Data.Migrations
FirstName = table.Column<string>(type: "text", nullable: true),
LastName = table.Column<string>(type: "text", nullable: true),
ProfilePictureUrl = table.Column<string>(type: "text", nullable: true),
- UserId = table.Column<Guid>(type: "uuid", nullable: true),
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
@@ -49,12 +49,6 @@ namespace DevHive.Data.Migrations
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
- table.ForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@@ -70,17 +64,16 @@ namespace DevHive.Data.Migrations
});
migrationBuilder.CreateTable(
- name: "Posts",
+ name: "Rating",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
- CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
- Message = table.Column<string>(type: "text", nullable: true),
- TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
+ Likes = table.Column<int>(type: "integer", nullable: false),
+ Dislikes = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
- table.PrimaryKey("PK_Posts", x => x.Id);
+ table.PrimaryKey("PK_Rating", x => x.Id);
});
migrationBuilder.CreateTable(
@@ -226,6 +219,30 @@ namespace DevHive.Data.Migrations
});
migrationBuilder.CreateTable(
+ name: "UserFriends",
+ columns: table => new
+ {
+ UserId = table.Column<Guid>(type: "uuid", nullable: false),
+ FriendId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_UserFriends", x => new { x.UserId, x.FriendId });
+ table.ForeignKey(
+ name: "FK_UserFriends_AspNetUsers_FriendId",
+ column: x => x.FriendId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_UserFriends_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
name: "LanguageUser",
columns: table => new
{
@@ -250,22 +267,29 @@ namespace DevHive.Data.Migrations
});
migrationBuilder.CreateTable(
- name: "Comments",
+ name: "Posts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
- PostId = table.Column<Guid>(type: "uuid", nullable: false),
- CreatorId = 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)
+ 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_Comments", x => x.Id);
+ table.PrimaryKey("PK_Posts", x => x.Id);
table.ForeignKey(
- name: "FK_Comments_Posts_PostId",
- column: x => x.PostId,
- principalTable: "Posts",
+ 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);
});
@@ -294,6 +318,33 @@ namespace DevHive.Data.Migrations
onDelete: ReferentialAction.Cascade);
});
+ migrationBuilder.CreateTable(
+ name: "Comments",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ PostId = table.Column<Guid>(type: "uuid", nullable: true),
+ CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
+ Message = table.Column<string>(type: "text", nullable: true),
+ TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Comments", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Comments_AspNetUsers_CreatorId",
+ column: x => x.CreatorId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_Comments_Posts_PostId",
+ column: x => x.PostId,
+ principalTable: "Posts",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
@@ -326,11 +377,6 @@ namespace DevHive.Data.Migrations
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId");
-
- migrationBuilder.CreateIndex(
name: "IX_AspNetUsers_UserName",
table: "AspNetUsers",
column: "UserName",
@@ -343,6 +389,11 @@ namespace DevHive.Data.Migrations
unique: true);
migrationBuilder.CreateIndex(
+ name: "IX_Comments_CreatorId",
+ table: "Comments",
+ column: "CreatorId");
+
+ migrationBuilder.CreateIndex(
name: "IX_Comments_PostId",
table: "Comments",
column: "PostId");
@@ -353,6 +404,17 @@ namespace DevHive.Data.Migrations
column: "UsersId");
migrationBuilder.CreateIndex(
+ name: "IX_Posts_CreatorId",
+ table: "Posts",
+ column: "CreatorId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Posts_RatingId",
+ table: "Posts",
+ column: "RatingId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
name: "IX_RoleUser_UsersId",
table: "RoleUser",
column: "UsersId");
@@ -361,6 +423,11 @@ namespace DevHive.Data.Migrations
name: "IX_TechnologyUser_UsersId",
table: "TechnologyUser",
column: "UsersId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UserFriends_FriendId",
+ table: "UserFriends",
+ column: "FriendId");
}
protected override void Down(MigrationBuilder migrationBuilder)
@@ -393,6 +460,9 @@ namespace DevHive.Data.Migrations
name: "TechnologyUser");
migrationBuilder.DropTable(
+ name: "UserFriends");
+
+ migrationBuilder.DropTable(
name: "Posts");
migrationBuilder.DropTable(
@@ -402,10 +472,13 @@ namespace DevHive.Data.Migrations
name: "AspNetRoles");
migrationBuilder.DropTable(
+ name: "Technologies");
+
+ migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(
- name: "Technologies");
+ name: "Rating");
}
}
}
diff --git a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
index f662af7..064fb26 100644
--- a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
+++ b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
@@ -76,6 +76,9 @@ namespace DevHive.Data.Migrations
b.Property<string>("Message")
.HasColumnType("text");
+ b.Property<Guid>("RatingId")
+ .HasColumnType("uuid");
+
b.Property<DateTime>("TimeCreated")
.HasColumnType("timestamp without time zone");
@@ -83,9 +86,29 @@ namespace DevHive.Data.Migrations
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")
@@ -185,9 +208,6 @@ namespace DevHive.Data.Migrations
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
@@ -201,8 +221,6 @@ namespace DevHive.Data.Migrations
.IsUnique()
.HasDatabaseName("UserNameIndex");
- b.HasIndex("UserId");
-
b.HasIndex("UserName")
.IsUnique();
@@ -391,14 +409,15 @@ namespace DevHive.Data.Migrations
.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");
- });
- modelBuilder.Entity("DevHive.Data.Models.User", b =>
- {
- b.HasOne("DevHive.Data.Models.User", null)
- .WithMany("Friends")
- .HasForeignKey("UserId");
+ b.Navigation("Rating");
});
modelBuilder.Entity("DevHive.Data.RelationModels.UserFriends", b =>
@@ -410,7 +429,7 @@ namespace DevHive.Data.Migrations
.IsRequired();
b.HasOne("DevHive.Data.Models.User", "User")
- .WithMany()
+ .WithMany("Friends")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -521,6 +540,11 @@ namespace DevHive.Data.Migrations
b.Navigation("Comments");
});
+ modelBuilder.Entity("DevHive.Data.Models.Rating", b =>
+ {
+ b.Navigation("Post");
+ });
+
modelBuilder.Entity("DevHive.Data.Models.User", b =>
{
b.Navigation("Comments");
diff --git a/src/DevHive.Data/Models/Post.cs b/src/DevHive.Data/Models/Post.cs
index c513eb4..2d144d3 100644
--- a/src/DevHive.Data/Models/Post.cs
+++ b/src/DevHive.Data/Models/Post.cs
@@ -18,6 +18,9 @@ namespace DevHive.Data.Models
public List<Comment> Comments { get; set; } = new();
+ public Guid RatingId { get; set; }
+ public Rating Rating { get; set; }
+
public List<string> FileUrls { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/Rating.cs b/src/DevHive.Data/Models/Rating.cs
new file mode 100644
index 0000000..8ebde9a
--- /dev/null
+++ b/src/DevHive.Data/Models/Rating.cs
@@ -0,0 +1,16 @@
+using System;
+using DevHive.Data.Interfaces.Models;
+
+namespace DevHive.Data.Models
+{
+ public class Rating : IRating
+ {
+ public Guid Id { get; set; }
+
+ public Post Post { get; set; }
+
+ public int Likes { get; set; }
+
+ public int Dislikes { get; set; }
+ }
+}
diff --git a/src/DevHive.Data/Models/User.cs b/src/DevHive.Data/Models/User.cs
index 8f66b35..da18c2f 100644
--- a/src/DevHive.Data/Models/User.cs
+++ b/src/DevHive.Data/Models/User.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;
using Microsoft.AspNetCore.Identity;
namespace DevHive.Data.Models
@@ -15,20 +16,13 @@ namespace DevHive.Data.Models
public string ProfilePictureUrl { get; set; }
- /// <summary>
- /// Languages that the user uses or is familiar with
- /// </summary>
- // [Unique]
public HashSet<Language> Languages { get; set; } = new();
- /// <summary>
- /// Technologies that the user uses or is familiar with
- /// </summary>
public HashSet<Technology> Technologies { get; set; } = new();
public HashSet<Role> Roles { get; set; } = new();
- public HashSet<User> Friends { get; set; } = new();
+ public HashSet<UserFriends> Friends { get; set; } = new();
public HashSet<Post> Posts { get; set; } = new();
diff --git a/src/DevHive.Data/RelationModels/UserFriends.cs b/src/DevHive.Data/RelationModels/UserFriends.cs
index aad3083..485d6ec 100644
--- a/src/DevHive.Data/RelationModels/UserFriends.cs
+++ b/src/DevHive.Data/RelationModels/UserFriends.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel.DataAnnotations;
using DevHive.Data.Models;
namespace DevHive.Data.RelationModels
diff --git a/src/DevHive.Data/Repositories/RatingRepository.cs b/src/DevHive.Data/Repositories/RatingRepository.cs
new file mode 100644
index 0000000..43fe90d
--- /dev/null
+++ b/src/DevHive.Data/Repositories/RatingRepository.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Interfaces.Repositories;
+using DevHive.Data.Models;
+using Microsoft.EntityFrameworkCore;
+
+namespace DevHive.Data.Repositories
+{
+ public class RatingRepository : BaseRepository<Rating>, IRatingRepository
+ {
+ private readonly DevHiveContext _context;
+
+ public RatingRepository(DevHiveContext context)
+ : base(context)
+ {
+ this._context = context;
+ }
+
+ public async Task<Rating> GetByPostId(Guid postId)
+ {
+ return await this._context.Rating
+ .FirstOrDefaultAsync(x => x.Post.Id == postId);
+ }
+
+ public async Task<Tuple<int, int>> GetRating(Guid postId)
+ {
+ Rating rating = await this.GetByPostId(postId);
+
+ return new Tuple<int, int>(rating.Likes, rating.Dislikes);
+ }
+
+ public async Task<bool> HasUserRatedThisPost(Guid userId, Guid postId)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index 6512c42..6c63244 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
+using AutoMapper.Mappers;
using DevHive.Data.Interfaces.Repositories;
using DevHive.Data.Models;
+using DevHive.Data.RelationModels;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -68,17 +70,21 @@ namespace DevHive.Data.Repositories
foreach (var role in newEntity.Roles)
user.Roles.Add(role);
- foreach (var friend in user.Friends)
- {
- friend.Friends.Remove(user);
- this._context.Entry(friend).State = EntityState.Modified;
- }
- user.Friends.Clear();
- foreach (var friend in newEntity.Friends)
- {
- friend.Friends.Add(user);
- user.Friends.Add(friend);
- }
+ // foreach (var friend in user.Friends)
+ // {
+ // friend.Friends.Remove(user);
+ // this._context.Entry(friend).State = EntityState.Modified;
+ // }
+ // user.Friends.Clear();
+ // foreach (var friend in newEntity.Friends)
+ // {
+ // friend.Friends.Add(user);
+ // user.Friends.Add(friend);
+ // }
+ this._context.UserFriends.RemoveRange(
+ this._context.UserFriends
+ .Where(x => x.FriendId == user.Id &&
+ x.UserId == user.Id));
user.Technologies.Clear();
foreach (var tech in newEntity.Technologies)
@@ -118,7 +124,7 @@ namespace DevHive.Data.Repositories
User friend = await this.GetByIdAsync(friendId);
- return user.Friends.Contains(friend);
+ return user.Friends.Any(x => x.Friend.Id == friendId);
}
public bool DoesUserHaveThisUsername(Guid id, string username)
diff --git a/src/DevHive.Services/Configurations/Mapping/RatingMappings.cs b/src/DevHive.Services/Configurations/Mapping/RatingMappings.cs
new file mode 100644
index 0000000..5da1b0d
--- /dev/null
+++ b/src/DevHive.Services/Configurations/Mapping/RatingMappings.cs
@@ -0,0 +1,12 @@
+using AutoMapper;
+
+namespace DevHive.Services.Configurations.Mapping
+{
+ public class RatingMappings : Profile
+ {
+ public RatingMappings()
+ {
+
+ }
+ }
+}
diff --git a/src/DevHive.Services/Models/Post/Rating/RatePostServiceModel.cs b/src/DevHive.Services/Models/Post/Rating/RatePostServiceModel.cs
new file mode 100644
index 0000000..d4eb7bd
--- /dev/null
+++ b/src/DevHive.Services/Models/Post/Rating/RatePostServiceModel.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace DevHive.Services.Models.Post.Rating
+{
+ public class RatePostServiceModel
+ {
+ public Guid UserId { get; set; }
+
+ public Guid PostId { get; set; }
+
+ public bool Liked { get; set; }
+ }
+}
diff --git a/src/DevHive.Services/Models/Post/Rating/ReadRatingServiceModel.cs b/src/DevHive.Services/Models/Post/Rating/ReadRatingServiceModel.cs
new file mode 100644
index 0000000..b071e74
--- /dev/null
+++ b/src/DevHive.Services/Models/Post/Rating/ReadRatingServiceModel.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace DevHive.Services.Models.Post.Rating
+{
+ public class ReadRatingServiceModel
+ {
+ public Guid PostId { get; set; }
+
+ public int Likes { get; set; }
+
+ public int Dislikes { get; set; }
+ }
+}
diff --git a/src/DevHive.Services/Services/FeedService.cs b/src/DevHive.Services/Services/FeedService.cs
index ceb5ebf..37d653c 100644
--- a/src/DevHive.Services/Services/FeedService.cs
+++ b/src/DevHive.Services/Services/FeedService.cs
@@ -38,7 +38,7 @@ namespace DevHive.Services.Services
if (user == null)
throw new ArgumentException("User doesn't exist!");
- List<User> friendsList = user.Friends.ToList();
+ List<User> friendsList = user.Friends.Select(x => x.Friend).ToList();
if (friendsList.Count == 0)
throw new ArgumentException("User has no friends to get feed from!");
diff --git a/src/DevHive.Services/Services/RatingService.cs b/src/DevHive.Services/Services/RatingService.cs
new file mode 100644
index 0000000..2c5a6b6
--- /dev/null
+++ b/src/DevHive.Services/Services/RatingService.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using AutoMapper;
+using DevHive.Data.Interfaces.Repositories;
+using DevHive.Data.Models;
+using DevHive.Services.Models.Post.Rating;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace DevHive.Services.Services
+{
+ public class RatingService
+ {
+ private readonly IPostRepository _postRepository;
+ private readonly IRatingRepository _ratingRepository;
+ private readonly IMapper _mapper;
+
+ public RatingService(IPostRepository postRepository, IRatingRepository ratingRepository, IMapper mapper)
+ {
+ this._postRepository = postRepository;
+ this._ratingRepository = ratingRepository;
+ this._mapper = mapper;
+ }
+
+ public async Task<ReadRatingServiceModel> RatePost(RatePostServiceModel ratePostServiceModel)
+ {
+ if (!await this._postRepository.DoesPostExist(ratePostServiceModel.PostId))
+ throw new ArgumentNullException("Post does not exist!");
+
+ if (!await this._ratingRepository.HasUserRatedThisPost(ratePostServiceModel.UserId, ratePostServiceModel.PostId))
+ throw new ArgumentException("You can't rate the same post more then one(duh, amigo)");
+
+ Post post = await this._postRepository.GetByIdAsync(ratePostServiceModel.PostId);
+
+ Rating rating = post.Rating;
+ if (ratePostServiceModel.Liked)
+ rating.Likes++;
+ else
+ rating.Dislikes++;
+
+ bool success = await this._ratingRepository.EditAsync(rating.Id, rating);
+ if (!success)
+ throw new InvalidOperationException("Unable to rate the post!");
+
+ Rating newRating = await this._ratingRepository.GetByIdAsync(rating.Id);
+ return this._mapper.Map<ReadRatingServiceModel>(newRating);
+ }
+
+ public async Task<ReadRatingServiceModel> RemoveUserRateFromPost(Guid userId, Guid postId)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index ec74b5f..c2c42e0 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -14,6 +14,7 @@ using DevHive.Services.Interfaces;
using DevHive.Data.Interfaces.Repositories;
using System.Linq;
using DevHive.Common.Models.Misc;
+using DevHive.Data.RelationModels;
namespace DevHive.Services.Services
{
@@ -52,7 +53,7 @@ namespace DevHive.Services.Services
if (user.PasswordHash != PasswordModifications.GeneratePasswordHash(loginModel.Password))
throw new ArgumentException("Incorrect password!");
- return new TokenModel(WriteJWTSecurityToken(user.Id, user.Roles));
+ return new TokenModel(WriteJWTSecurityToken(user.Id, user.UserName, user.Roles));
}
public async Task<TokenModel> RegisterUser(RegisterServiceModel registerModel)
@@ -77,7 +78,7 @@ namespace DevHive.Services.Services
await this._userRepository.AddAsync(user);
- return new TokenModel(WriteJWTSecurityToken(user.Id, user.Roles));
+ return new TokenModel(WriteJWTSecurityToken(user.Id, user.UserName, user.Roles));
}
#endregion
@@ -106,8 +107,6 @@ namespace DevHive.Services.Services
{
await this.ValidateUserOnUpdate(updateUserServiceModel);
- await this.ValidateUserCollections(updateUserServiceModel);
-
User user = await this.PopulateModel(updateUserServiceModel);
bool successful = await this._userRepository.EditAsync(updateUserServiceModel.Id, user);
@@ -189,62 +188,13 @@ namespace DevHive.Services.Services
throw new ArgumentException("Username already exists!");
}
- private async Task ValidateUserCollections(UpdateUserServiceModel updateUserServiceModel)
- {
- //Do NOT allow a user to change his roles, unless he is an Admin
- bool isAdmin = (await this._userRepository.GetByIdAsync(updateUserServiceModel.Id))
- .Roles.Any(r => r.Name == Role.AdminRole);
-
- if (isAdmin)
- {
- // Roles
- foreach (var role in updateUserServiceModel.Roles)
- {
- Role returnedRole = await this._roleRepository.GetByNameAsync(role.Name) ??
- throw new ArgumentException($"Role {role.Name} does not exist!");
- }
- }
- //Preserve original user roles
- else
- {
- HashSet<Role> roles = (await this._userRepository.GetByIdAsync(updateUserServiceModel.Id)).Roles;
-
- foreach (var role in roles)
- {
- Role returnedRole = await this._roleRepository.GetByNameAsync(role.Name) ??
- throw new ArgumentException($"Role {role.Name} does not exist!");
- }
- }
-
- // Friends
- foreach (var friend in updateUserServiceModel.Friends)
- {
- User returnedFriend = await this._userRepository.GetByUsernameAsync(friend.UserName) ??
- throw new ArgumentException($"User {friend.UserName} does not exist!");
- }
-
- // Languages
- foreach (var language in updateUserServiceModel.Languages)
- {
- Language returnedLanguage = await this._languageRepository.GetByNameAsync(language.Name) ??
- throw new ArgumentException($"Language {language.Name} does not exist!");
- }
-
- // Technology
- foreach (var technology in updateUserServiceModel.Technologies)
- {
- Technology returnedTechnology = await this._technologyRepository.GetByNameAsync(technology.Name) ??
- throw new ArgumentException($"Technology {technology.Name} does not exist!");
- }
- }
-
- private string WriteJWTSecurityToken(Guid userId, HashSet<Role> roles)
+ private string WriteJWTSecurityToken(Guid userId, string username, HashSet<Role> roles)
{
byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret);
-
HashSet<Claim> claims = new()
{
new Claim("ID", $"{userId}"),
+ new Claim("Username", username),
};
foreach (var role in roles)
@@ -268,12 +218,12 @@ namespace DevHive.Services.Services
#endregion
#region Misc
- public async Task<Guid> SuperSecretPromotionToAdmin(Guid userId)
+ public async Task<TokenModel> SuperSecretPromotionToAdmin(Guid userId)
{
User user = await this._userRepository.GetByIdAsync(userId) ??
throw new ArgumentException("User does not exist! Can't promote shit in this country...");
- if (!await this._roleRepository.DoesNameExist("Admin"))
+ if (!await this._roleRepository.DoesNameExist(Role.AdminRole))
{
Role adminRole = new()
{
@@ -289,7 +239,9 @@ namespace DevHive.Services.Services
user.Roles.Add(admin);
await this._userRepository.EditAsync(user.Id, user);
- return admin.Id;
+ User newUser = await this._userRepository.GetByIdAsync(userId);
+
+ return new TokenModel(WriteJWTSecurityToken(newUser.Id, newUser.UserName, newUser.Roles);
}
private async Task<User> PopulateModel(UpdateUserServiceModel updateUserServiceModel)
@@ -309,14 +261,21 @@ namespace DevHive.Services.Services
user.Roles = roles;
/* Fetch Friends and replace model's*/
- HashSet<User> friends = new();
+ HashSet<UserFriends> friends = new();
int friendsCount = updateUserServiceModel.Friends.Count;
for (int i = 0; i < friendsCount; i++)
{
User friend = await this._userRepository.GetByUsernameAsync(updateUserServiceModel.Friends.ElementAt(i).UserName) ??
throw new ArgumentException("Invalid friend's username!");
- friends.Add(friend);
+ UserFriends relation = new()
+ {
+ UserId = user.Id,
+ User = user,
+ FriendId = friend.Id,
+ Friend = friend
+ };
+ friends.Add(relation);
}
user.Friends = friends;
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs
index 8ba0d69..22df311 100644
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs
+++ b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs
@@ -18,6 +18,7 @@ namespace DevHive.Web.Configurations.Extensions
services.AddTransient<IPostRepository, PostRepository>();
services.AddTransient<ICommentRepository, CommentRepository>();
services.AddTransient<IFeedRepository, FeedRepository>();
+ services.AddTransient<IRatingRepository, RatingRepository>();
services.AddTransient<ILanguageService, LanguageService>();
services.AddTransient<IRoleService, RoleService>();
diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs
index 332868d..2fe9c2f 100644
--- a/src/DevHive.Web/Controllers/UserController.cs
+++ b/src/DevHive.Web/Controllers/UserController.cs
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using DevHive.Common.Models.Identity;
using DevHive.Services.Interfaces;
+using Microsoft.Extensions.Hosting;
namespace DevHive.Web.Controllers
{