Add ability to favourite users

This commit is contained in:
jvyden 2021-10-25 21:42:51 -04:00
parent 4248d79d99
commit db0a57b44c
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
7 changed files with 669 additions and 78 deletions

View file

@ -123,6 +123,61 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
[HttpGet("favouriteUsers/{username}")]
public IActionResult GetFavouriteUsers(string username) {
IEnumerable<HeartedProfile> heartedProfiles = new Database().HeartedProfiles
.Include(q => q.User)
.Include(q => q.HeartedUser)
.Include(q => q.HeartedUser.Location)
.Where(q => q.User.Username == username)
.AsEnumerable();
string response = heartedProfiles.Aggregate(string.Empty, (current, q) => current + q.HeartedUser.Serialize());
return this.Ok(LbpSerializer.TaggedStringElement("favouriteUsers", response, "total", 1));
}
[HttpPost("favourite/user/{username}")]
public async Task<IActionResult> AddFavouriteUser(string username) {
User? user = await this.database.UserFromRequest(this.Request);
if(user == null) return this.StatusCode(403, "");
User? heartedUser = await this.database.Users
.FirstOrDefaultAsync(u => u.Username == username);
if(heartedUser == null) return this.NotFound();
HeartedProfile heartedProfile = await this.database.HeartedProfiles
.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
if(heartedProfile != null) return this.Ok();
this.database.HeartedProfiles.Add(new HeartedProfile {
HeartedUserId = heartedUser.UserId,
UserId = user.UserId,
});
await this.database.SaveChangesAsync();
return this.Ok();
}
[HttpPost("unfavourite/user/{username}")]
public async Task<IActionResult> RemoveFavouriteUser(string username) {
User? user = await this.database.UserFromRequest(this.Request);
if(user == null) return this.StatusCode(403, "");
User? heartedUser = await this.database.Users
.FirstOrDefaultAsync(u => u.Username == username);
if(heartedUser == null) return this.NotFound();
HeartedProfile heartedProfile = await this.database.HeartedProfiles
.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
if(heartedProfile != null) this.database.HeartedProfiles.Remove(heartedProfile);
await this.database.SaveChangesAsync();
return this.Ok();
}
#endregion #endregion
} }
} }

View file

@ -16,7 +16,9 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
[HttpGet("eula")] [HttpGet("eula")]
public async Task<IActionResult> Eula() { public async Task<IActionResult> Eula() {
User user = await this.database.UserFromRequest(this.Request); User user = await this.database.UserFromRequest(this.Request);
return user == null ? this.StatusCode(403, "") : this.Ok($"You are logged in as user {user.Username} (id {user.UserId})"); return user == null ? this.StatusCode(403, "") :
this.Ok($"You are now logged in as user {user.Username} (id {user.UserId}).\n" +
"This is a private testing instance. Please do not make anything public for now, and keep in mind security isn't as tight as a full release would.");
} }
[HttpGet("announce")] [HttpGet("announce")]

View file

@ -15,6 +15,7 @@ namespace LBPUnion.ProjectLighthouse {
public DbSet<Slot> Slots { get; set; } public DbSet<Slot> Slots { get; set; }
public DbSet<QueuedLevel> QueuedLevels { get; set; } public DbSet<QueuedLevel> QueuedLevels { get; set; }
public DbSet<HeartedLevel> HeartedLevels { get; set; } public DbSet<HeartedLevel> HeartedLevels { get; set; }
public DbSet<HeartedProfile> HeartedProfiles { get; set; }
public DbSet<Comment> Comments { get; set; } public DbSet<Comment> Comments { get; set; }
public DbSet<Token> Tokens { get; set; } public DbSet<Token> Tokens { get; set; }

View file

@ -0,0 +1,418 @@
// <auto-generated />
using LBPUnion.ProjectLighthouse;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ProjectLighthouse.Migrations
{
[DbContext(typeof(Database))]
[Migration("20211026010814_FavouriteUsers")]
partial class FavouriteUsers
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b =>
{
b.Property<int>("HeartedProfileId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("HeartedUserId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("HeartedProfileId");
b.HasIndex("HeartedUserId");
b.HasIndex("UserId");
b.ToTable("HeartedProfiles");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b =>
{
b.Property<int>("HeartedLevelId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("SlotId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("HeartedLevelId");
b.HasIndex("SlotId");
b.HasIndex("UserId");
b.ToTable("HeartedLevels");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b =>
{
b.Property<int>("QueuedLevelId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("SlotId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("QueuedLevelId");
b.HasIndex("SlotId");
b.HasIndex("UserId");
b.ToTable("QueuedLevels");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b =>
{
b.Property<int>("SlotId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("AuthorLabels")
.HasColumnType("longtext");
b.Property<string>("BackgroundHash")
.HasColumnType("longtext");
b.Property<int>("CreatorId")
.HasColumnType("int");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("IconHash")
.HasColumnType("longtext");
b.Property<bool>("InitiallyLocked")
.HasColumnType("tinyint(1)");
b.Property<bool>("Lbp1Only")
.HasColumnType("tinyint(1)");
b.Property<int>("LocationId")
.HasColumnType("int");
b.Property<int>("MaximumPlayers")
.HasColumnType("int");
b.Property<int>("MinimumPlayers")
.HasColumnType("int");
b.Property<bool>("MoveRequired")
.HasColumnType("tinyint(1)");
b.Property<string>("Name")
.HasColumnType("longtext");
b.Property<string>("ResourceCollection")
.HasColumnType("longtext");
b.Property<string>("RootLevel")
.HasColumnType("longtext");
b.Property<int>("Shareable")
.HasColumnType("int");
b.Property<bool>("SubLevel")
.HasColumnType("tinyint(1)");
b.HasKey("SlotId");
b.HasIndex("CreatorId");
b.HasIndex("LocationId");
b.ToTable("Slots");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b =>
{
b.Property<int>("CommentId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<int>("PosterUserId")
.HasColumnType("int");
b.Property<int>("TargetUserId")
.HasColumnType("int");
b.Property<int>("ThumbsDown")
.HasColumnType("int");
b.Property<int>("ThumbsUp")
.HasColumnType("int");
b.Property<long>("Timestamp")
.HasColumnType("bigint");
b.HasKey("CommentId");
b.HasIndex("PosterUserId");
b.HasIndex("TargetUserId");
b.ToTable("Comments");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastMatch", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<long>("Timestamp")
.HasColumnType("bigint");
b.HasKey("UserId");
b.ToTable("LastMatches");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b =>
{
b.Property<int>("TokenId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("UserToken")
.HasColumnType("longtext");
b.HasKey("TokenId");
b.ToTable("Tokens");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Biography")
.HasColumnType("longtext");
b.Property<string>("BooHash")
.HasColumnType("longtext");
b.Property<int>("CommentCount")
.HasColumnType("int");
b.Property<bool>("CommentsEnabled")
.HasColumnType("tinyint(1)");
b.Property<int>("FavouriteSlotCount")
.HasColumnType("int");
b.Property<int>("FavouriteUserCount")
.HasColumnType("int");
b.Property<int>("Game")
.HasColumnType("int");
b.Property<int>("HeartCount")
.HasColumnType("int");
b.Property<string>("IconHash")
.HasColumnType("longtext");
b.Property<int>("Lists")
.HasColumnType("int");
b.Property<int>("LocationId")
.HasColumnType("int");
b.Property<int>("LolCatFtwCount")
.HasColumnType("int");
b.Property<int>("PhotosByMeCount")
.HasColumnType("int");
b.Property<int>("PhotosWithMeCount")
.HasColumnType("int");
b.Property<string>("Pins")
.HasColumnType("longtext");
b.Property<string>("PlanetHash")
.HasColumnType("longtext");
b.Property<int>("ReviewCount")
.HasColumnType("int");
b.Property<int>("StaffChallengeBronzeCount")
.HasColumnType("int");
b.Property<int>("StaffChallengeGoldCount")
.HasColumnType("int");
b.Property<int>("StaffChallengeSilverCount")
.HasColumnType("int");
b.Property<int>("UsedSlots")
.HasColumnType("int");
b.Property<string>("Username")
.HasColumnType("longtext");
b.Property<string>("YayHash")
.HasColumnType("longtext");
b.HasKey("UserId");
b.HasIndex("LocationId");
b.ToTable("Users");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser")
.WithMany()
.HasForeignKey("HeartedUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("HeartedUser");
b.Navigation("User");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
.WithMany()
.HasForeignKey("SlotId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Slot");
b.Navigation("User");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
.WithMany()
.HasForeignKey("SlotId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Slot");
b.Navigation("User");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Creator")
.WithMany()
.HasForeignKey("CreatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location")
.WithMany()
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Creator");
b.Navigation("Location");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster")
.WithMany()
.HasForeignKey("PosterUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Target")
.WithMany()
.HasForeignKey("TargetUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Poster");
b.Navigation("Target");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location")
.WithMany()
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Location");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,54 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ProjectLighthouse.Migrations
{
public partial class FavouriteUsers : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "HeartedProfiles",
columns: table => new
{
HeartedProfileId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<int>(type: "int", nullable: false),
HeartedUserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HeartedProfiles", x => x.HeartedProfileId);
table.ForeignKey(
name: "FK_HeartedProfiles_Users_HeartedUserId",
column: x => x.HeartedUserId,
principalTable: "Users",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_HeartedProfiles_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_HeartedProfiles_HeartedUserId",
table: "HeartedProfiles",
column: "HeartedUserId");
migrationBuilder.CreateIndex(
name: "IX_HeartedProfiles_UserId",
table: "HeartedProfiles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "HeartedProfiles");
}
}
}

View file

@ -1,10 +1,8 @@
// <auto-generated /> // <auto-generated />
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ProjectLighthouse;
namespace ProjectLighthouse.Migrations namespace ProjectLighthouse.Migrations
{ {
@ -18,40 +16,28 @@ namespace ProjectLighthouse.Migrations
.HasAnnotation("Relational:MaxIdentifierLength", 64) .HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11"); .HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("ProjectLighthouse.Types.Comment", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b =>
{ {
b.Property<int>("CommentId") b.Property<int>("HeartedProfileId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Message") b.Property<int>("HeartedUserId")
.HasColumnType("longtext");
b.Property<int>("PosterUserId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("TargetUserId") b.Property<int>("UserId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ThumbsDown") b.HasKey("HeartedProfileId");
.HasColumnType("int");
b.Property<int>("ThumbsUp") b.HasIndex("HeartedUserId");
.HasColumnType("int");
b.Property<long>("Timestamp") b.HasIndex("UserId");
.HasColumnType("bigint");
b.HasKey("CommentId"); b.ToTable("HeartedProfiles");
b.HasIndex("PosterUserId");
b.HasIndex("TargetUserId");
b.ToTable("Comments");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.HeartedLevel", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b =>
{ {
b.Property<int>("HeartedLevelId") b.Property<int>("HeartedLevelId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -72,38 +58,7 @@ namespace ProjectLighthouse.Migrations
b.ToTable("HeartedLevels"); b.ToTable("HeartedLevels");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.LastMatch", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<long>("Timestamp")
.HasColumnType("bigint");
b.HasKey("UserId");
b.ToTable("LastMatches");
});
modelBuilder.Entity("ProjectLighthouse.Types.Location", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("ProjectLighthouse.Types.QueuedLevel", b =>
{ {
b.Property<int>("QueuedLevelId") b.Property<int>("QueuedLevelId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -124,7 +79,7 @@ namespace ProjectLighthouse.Migrations
b.ToTable("QueuedLevels"); b.ToTable("QueuedLevels");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.Slot", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b =>
{ {
b.Property<int>("SlotId") b.Property<int>("SlotId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -187,7 +142,71 @@ namespace ProjectLighthouse.Migrations
b.ToTable("Slots"); b.ToTable("Slots");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.Token", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b =>
{
b.Property<int>("CommentId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<int>("PosterUserId")
.HasColumnType("int");
b.Property<int>("TargetUserId")
.HasColumnType("int");
b.Property<int>("ThumbsDown")
.HasColumnType("int");
b.Property<int>("ThumbsUp")
.HasColumnType("int");
b.Property<long>("Timestamp")
.HasColumnType("bigint");
b.HasKey("CommentId");
b.HasIndex("PosterUserId");
b.HasIndex("TargetUserId");
b.ToTable("Comments");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastMatch", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<long>("Timestamp")
.HasColumnType("bigint");
b.HasKey("UserId");
b.ToTable("LastMatches");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b =>
{ {
b.Property<int>("TokenId") b.Property<int>("TokenId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -204,7 +223,7 @@ namespace ProjectLighthouse.Migrations
b.ToTable("Tokens"); b.ToTable("Tokens");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.User", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b =>
{ {
b.Property<int>("UserId") b.Property<int>("UserId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -286,34 +305,34 @@ namespace ProjectLighthouse.Migrations
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.Comment", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b =>
{ {
b.HasOne("ProjectLighthouse.Types.User", "Poster") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser")
.WithMany() .WithMany()
.HasForeignKey("PosterUserId") .HasForeignKey("HeartedUserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ProjectLighthouse.Types.User", "Target") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany() .WithMany()
.HasForeignKey("TargetUserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Poster"); b.Navigation("HeartedUser");
b.Navigation("Target"); b.Navigation("User");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.HeartedLevel", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b =>
{ {
b.HasOne("ProjectLighthouse.Types.Slot", "Slot") b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
.WithMany() .WithMany()
.HasForeignKey("SlotId") .HasForeignKey("SlotId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ProjectLighthouse.Types.User", "User") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -324,15 +343,15 @@ namespace ProjectLighthouse.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.QueuedLevel", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b =>
{ {
b.HasOne("ProjectLighthouse.Types.Slot", "Slot") b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
.WithMany() .WithMany()
.HasForeignKey("SlotId") .HasForeignKey("SlotId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ProjectLighthouse.Types.User", "User") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -343,15 +362,15 @@ namespace ProjectLighthouse.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.Slot", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b =>
{ {
b.HasOne("ProjectLighthouse.Types.User", "Creator") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Creator")
.WithMany() .WithMany()
.HasForeignKey("CreatorId") .HasForeignKey("CreatorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ProjectLighthouse.Types.Location", "Location") b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location")
.WithMany() .WithMany()
.HasForeignKey("LocationId") .HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -362,9 +381,28 @@ namespace ProjectLighthouse.Migrations
b.Navigation("Location"); b.Navigation("Location");
}); });
modelBuilder.Entity("ProjectLighthouse.Types.User", b => modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b =>
{ {
b.HasOne("ProjectLighthouse.Types.Location", "Location") b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster")
.WithMany()
.HasForeignKey("PosterUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Target")
.WithMany()
.HasForeignKey("TargetUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Poster");
b.Navigation("Target");
});
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b =>
{
b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location")
.WithMany() .WithMany()
.HasForeignKey("LocationId") .HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)

View file

@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace LBPUnion.ProjectLighthouse.Types {
public class HeartedProfile {
// ReSharper disable once UnusedMember.Global
#if NET6_0_OR_GREATER
[Obsolete($"Use {nameof(HeartedUserId)} instead, this is a key which you should never need to use.")]
#else
[Obsolete("Use HeartedUserId instead, this is a key which you should never need to use.")]
#endif
[Key] public int HeartedProfileId { get; set; }
public int UserId { get; set; }
[ForeignKey(nameof(UserId))] public User User { get; set; }
public int HeartedUserId { get; set; }
[ForeignKey(nameof(HeartedUserId))] public User HeartedUser { get; set; }
}
}