mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 05:18:47 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
817fecdc18
14 changed files with 1324 additions and 22 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -15,9 +15,11 @@ riderModule.iml
|
||||||
/.idea/.idea.ProjectLighthouse/.idea/dataSources.local.xml
|
/.idea/.idea.ProjectLighthouse/.idea/dataSources.local.xml
|
||||||
*.sln.DotSettings.user
|
*.sln.DotSettings.user
|
||||||
/ProjectLighthouse/r/*
|
/ProjectLighthouse/r/*
|
||||||
/ProjectLighthouse/logs/*
|
logs
|
||||||
/ProjectLighthouse/ProjectLighthouse.csproj.user
|
/ProjectLighthouse/ProjectLighthouse.csproj.user
|
||||||
.vs/
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
.editorconfig
|
||||||
lighthouse.config.json
|
lighthouse.config.json
|
||||||
gitBranch.txt
|
gitBranch.txt
|
||||||
gitVersion.txt
|
gitVersion.txt
|
||||||
|
|
|
@ -63,10 +63,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
v = await visited.FirstOrDefaultAsync();
|
v = await visited.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == null)
|
if (v == null) return this.NotFound();
|
||||||
{
|
|
||||||
return this.NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (gameVersion)
|
switch (gameVersion)
|
||||||
{
|
{
|
||||||
|
@ -119,10 +116,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
v = await visited.FirstOrDefaultAsync();
|
v = await visited.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == null)
|
if (v == null) return this.NotFound();
|
||||||
{
|
|
||||||
return this.NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
slot.PlaysLBP1++;
|
slot.PlaysLBP1++;
|
||||||
v.PlaysLBP1++;
|
v.PlaysLBP1++;
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Reviews;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -74,5 +81,186 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
return this.Ok();
|
return this.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("postReview/user/{slotId:int}")]
|
||||||
|
public async Task<IActionResult> PostReview(int slotId)
|
||||||
|
{
|
||||||
|
User? user = await this.database.UserFromGameRequest(this.Request);
|
||||||
|
if (user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
Review? review = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == slotId && r.ReviewerId == user.UserId);
|
||||||
|
Review? newReview = await this.GetReviewFromBody();
|
||||||
|
if (newReview == null) return this.BadRequest();
|
||||||
|
if (review == null)
|
||||||
|
{
|
||||||
|
review = new();
|
||||||
|
review.SlotId = slotId;
|
||||||
|
review.ReviewerId = user.UserId;
|
||||||
|
review.DeletedBy = "none";
|
||||||
|
|
||||||
|
}
|
||||||
|
review.LabelCollection = newReview.LabelCollection;
|
||||||
|
review.Text = newReview.Text;
|
||||||
|
review.Deleted = false;
|
||||||
|
review.Timestamp = TimeHelper.UnixTimeMilliseconds();
|
||||||
|
|
||||||
|
// sometimes the game posts a review without also calling dpadrate/user/etc (why??)
|
||||||
|
RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == slotId && r.UserId == user.UserId);
|
||||||
|
if (ratedLevel == null)
|
||||||
|
{
|
||||||
|
ratedLevel = new RatedLevel();
|
||||||
|
ratedLevel.SlotId = slotId;
|
||||||
|
ratedLevel.UserId = user.UserId;
|
||||||
|
ratedLevel.RatingLBP1 = 0;
|
||||||
|
this.database.RatedLevels.Add(ratedLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
ratedLevel.Rating = newReview.Thumb;
|
||||||
|
|
||||||
|
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("reviewsFor/user/{slotId:int}")]
|
||||||
|
public async Task<IActionResult> ReviewsFor(int slotId, [FromQuery] int pageStart = 1, [FromQuery] int pageSize = 10)
|
||||||
|
{
|
||||||
|
(User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request);
|
||||||
|
|
||||||
|
if (userAndToken == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
// ReSharper disable once PossibleInvalidOperationException
|
||||||
|
User user = userAndToken.Value.Item1;
|
||||||
|
GameToken gameToken = userAndToken.Value.Item2;
|
||||||
|
|
||||||
|
GameVersion gameVersion = gameToken.GameVersion;
|
||||||
|
|
||||||
|
Random rand = new();
|
||||||
|
|
||||||
|
IEnumerable<Review> reviews = this.database.Reviews.Where(r => r.SlotId == slotId && r.Slot.GameVersion <= gameVersion)
|
||||||
|
.Include(r => r.Reviewer)
|
||||||
|
.Include(r => r.Slot)
|
||||||
|
.AsEnumerable() // performance? Needed for next line (ThumbsUp is not in DB)
|
||||||
|
.OrderByDescending(r => r.ThumbsUp)
|
||||||
|
.ThenByDescending(_ => rand.Next())
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(pageSize);
|
||||||
|
|
||||||
|
string inner = Enumerable.Aggregate(reviews, string.Empty, (current, review) =>
|
||||||
|
{
|
||||||
|
RatedLevel? ratedLevel = this.database.RatedLevels.FirstOrDefault(r => r.SlotId == slotId && r.UserId == review.ReviewerId);
|
||||||
|
RatedReview? ratedReview = this.database.RatedReviews.FirstOrDefault(r => r.ReviewId == review.ReviewId && r.UserId == user.UserId);
|
||||||
|
|
||||||
|
return current + review.Serialize(ratedLevel, ratedReview);
|
||||||
|
});
|
||||||
|
|
||||||
|
string response = LbpSerializer.TaggedStringElement("reviews", inner, new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"hint_start", pageStart + pageSize
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hint", pageStart // not sure
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return this.Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("reviewsBy/{username}")]
|
||||||
|
public async Task<IActionResult> ReviewsBy(string username, [FromQuery] int pageStart = 1, [FromQuery] int pageSize = 10)
|
||||||
|
{
|
||||||
|
(User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request);
|
||||||
|
|
||||||
|
if (userAndToken == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
// ReSharper disable once PossibleInvalidOperationException
|
||||||
|
User user = userAndToken.Value.Item1;
|
||||||
|
GameToken gameToken = userAndToken.Value.Item2;
|
||||||
|
|
||||||
|
GameVersion gameVersion = gameToken.GameVersion;
|
||||||
|
|
||||||
|
IEnumerable<Review> reviews = this.database.Reviews.Where(r => r.Reviewer.Username == username && r.Slot.GameVersion <= gameVersion)
|
||||||
|
.Include(r => r.Reviewer)
|
||||||
|
.Include(r => r.Slot)
|
||||||
|
.OrderByDescending(r => r.Timestamp)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(pageSize);
|
||||||
|
|
||||||
|
string inner = Enumerable.Aggregate(reviews, string.Empty, (current, review) =>
|
||||||
|
{
|
||||||
|
RatedLevel? ratedLevel = this.database.RatedLevels.FirstOrDefault(r => r.SlotId == review.SlotId && r.UserId == user.UserId);
|
||||||
|
RatedReview? ratedReview = this.database.RatedReviews.FirstOrDefault(r => r.ReviewId == review.ReviewId && r.UserId == user.UserId);
|
||||||
|
return current + review.Serialize(ratedLevel, ratedReview);
|
||||||
|
});
|
||||||
|
|
||||||
|
string response = LbpSerializer.TaggedStringElement("reviews", inner, new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"hint_start", pageStart
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hint", reviews.Last().Timestamp // Seems to be the timestamp of oldest
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("rateReview/user/{slotId:int}/{username}")]
|
||||||
|
public async Task<IActionResult> RateReview(int slotId, string username, [FromQuery] int rating = 0)
|
||||||
|
{
|
||||||
|
User? user = await this.database.UserFromGameRequest(this.Request);
|
||||||
|
if (user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
User? reviewer = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||||
|
if (reviewer == null) return this.StatusCode(400, "");
|
||||||
|
|
||||||
|
Review? review = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == slotId && r.ReviewerId == reviewer.UserId);
|
||||||
|
if (review == null) return this.StatusCode(400, "");
|
||||||
|
|
||||||
|
RatedReview? ratedReview = await this.database.RatedReviews.FirstOrDefaultAsync(r => r.ReviewId == review.ReviewId && r.UserId == user.UserId);
|
||||||
|
if (ratedReview == null)
|
||||||
|
{
|
||||||
|
ratedReview = new RatedReview();
|
||||||
|
ratedReview.ReviewId = review.ReviewId;
|
||||||
|
ratedReview.UserId = user.UserId;
|
||||||
|
ratedReview.Thumb = 0;
|
||||||
|
this.database.RatedReviews.Add(ratedReview);
|
||||||
|
}
|
||||||
|
|
||||||
|
ratedReview.Thumb = Math.Max(Math.Min(1, rating), -1);
|
||||||
|
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("deleteReview/user/{slotId:int}/{username}")]
|
||||||
|
public async Task<IActionResult> DeleteReview(int slotId, string username)
|
||||||
|
{
|
||||||
|
User? reviewer = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||||
|
if (reviewer == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
Review? review = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == slotId && r.ReviewerId == reviewer.UserId);
|
||||||
|
if (review == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
review.Deleted = true;
|
||||||
|
review.DeletedBy = DeletedBy.LevelAuthor;
|
||||||
|
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Review?> GetReviewFromBody()
|
||||||
|
{
|
||||||
|
this.Request.Body.Position = 0;
|
||||||
|
string bodyString = await new StreamReader(this.Request.Body).ReadToEndAsync();
|
||||||
|
|
||||||
|
XmlSerializer serializer = new(typeof(Review));
|
||||||
|
Review? review = (Review?)serializer.Deserialize(new StringReader(bodyString));
|
||||||
|
|
||||||
|
return review;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Reviews;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -86,7 +87,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
|
|
||||||
RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
|
RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
|
||||||
VisitedLevel? visitedLevel = await this.database.VisitedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
|
VisitedLevel? visitedLevel = await this.database.VisitedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
|
||||||
return this.Ok(slot.Serialize(ratedLevel, visitedLevel));
|
Review? yourReview = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == id && r.ReviewerId == user.UserId);
|
||||||
|
return this.Ok(slot.Serialize(ratedLevel, visitedLevel, yourReview));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("slots/lbp2cool")]
|
[HttpGet("slots/lbp2cool")]
|
||||||
|
|
|
@ -29,7 +29,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
public async Task<string?> GetSerializedUser(string username, GameVersion gameVersion = GameVersion.LittleBigPlanet1)
|
public async Task<string?> GetSerializedUser(string username, GameVersion gameVersion = GameVersion.LittleBigPlanet1)
|
||||||
{
|
{
|
||||||
User? user = await this.database.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.Username == username);
|
User? user = await this.database.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.Username == username);
|
||||||
return user?.Serialize(gameVersion);
|
if (user == null) return "";
|
||||||
|
return user.Serialize(gameVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("user/{username}")]
|
[HttpGet("user/{username}")]
|
||||||
|
@ -39,7 +40,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
if (token == null) return this.StatusCode(403, "");
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
string? user = await this.GetSerializedUser(username, token.GameVersion);
|
string? user = await this.GetSerializedUser(username, token.GameVersion);
|
||||||
if (user == null) return this.NotFound();
|
if (string.IsNullOrEmpty(user)) return this.NotFound();
|
||||||
|
|
||||||
return this.Ok(user);
|
return this.Ok(user);
|
||||||
}
|
}
|
||||||
|
@ -51,9 +52,10 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
if (token == null) return this.StatusCode(403, "");
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
List<string?> serializedUsers = new();
|
List<string?> serializedUsers = new();
|
||||||
foreach (string userId in u)
|
foreach (string username in u)
|
||||||
{
|
{
|
||||||
serializedUsers.Add(await this.GetSerializedUser(userId, token.GameVersion));
|
string? serializedUser = await this.GetSerializedUser(username, token.GameVersion);
|
||||||
|
if (serializedUser != "") serializedUsers.Add(serializedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
string serialized = serializedUsers.Aggregate(string.Empty, (current, user) => user == null ? current : current + user);
|
string serialized = serializedUsers.Aggregate(string.Empty, (current, user) => user == null ? current : current + user);
|
||||||
|
|
|
@ -8,6 +8,7 @@ using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Reviews;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ namespace LBPUnion.ProjectLighthouse
|
||||||
public DbSet<LastContact> LastContacts { get; set; }
|
public DbSet<LastContact> LastContacts { get; set; }
|
||||||
public DbSet<VisitedLevel> VisitedLevels { get; set; }
|
public DbSet<VisitedLevel> VisitedLevels { get; set; }
|
||||||
public DbSet<RatedLevel> RatedLevels { get; set; }
|
public DbSet<RatedLevel> RatedLevels { get; set; }
|
||||||
|
public DbSet<Review> Reviews { get; set; }
|
||||||
|
public DbSet<RatedReview> RatedReviews { get; set; }
|
||||||
public DbSet<AuthenticationAttempt> AuthenticationAttempts { get; set; }
|
public DbSet<AuthenticationAttempt> AuthenticationAttempts { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
|
752
ProjectLighthouse/Migrations/20211120025513_LevelReviews.Designer.cs
generated
Normal file
752
ProjectLighthouse/Migrations/20211120025513_LevelReviews.Designer.cs
generated
Normal file
|
@ -0,0 +1,752 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using LBPUnion.ProjectLighthouse;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ProjectLighthouse.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20211120025513_LevelReviews")]
|
||||||
|
partial class LevelReviews
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "6.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
|
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.RatedLevel", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RatedLevelId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("RatingLBP1")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("RatedLevelId");
|
||||||
|
|
||||||
|
b.HasIndex("SlotId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RatedLevels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorLabels")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("BackgroundHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("CreatorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<long>("FirstUploaded")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("GameVersion")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("IconHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<bool>("InitiallyLocked")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<long>("LastUpdated")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<bool>("Lbp1Only")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("LevelType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
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")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP1")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP1Complete")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP1Unique")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP2")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP2Complete")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP2Unique")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP3")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP3Complete")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP3Unique")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBPVita")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBPVitaComplete")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBPVitaUnique")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ResourceCollection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("RootLevel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("Shareable")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<bool>("SubLevel")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<bool>("TeamPick")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.HasKey("SlotId");
|
||||||
|
|
||||||
|
b.HasIndex("CreatorId");
|
||||||
|
|
||||||
|
b.HasIndex("LocationId");
|
||||||
|
|
||||||
|
b.ToTable("Slots");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("VisitedLevelId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP1")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP2")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBP3")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PlaysLBPVita")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("VisitedLevelId");
|
||||||
|
|
||||||
|
b.HasIndex("SlotId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("VisitedLevels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PhotoId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CreatorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("LargeHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("MediumHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("PhotoSubjectCollection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("PlanHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("SmallHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<long>("Timestamp")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("PhotoId");
|
||||||
|
|
||||||
|
b.HasIndex("CreatorId");
|
||||||
|
|
||||||
|
b.ToTable("Photos");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("PhotoSubjectId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Bounds")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("PhotoSubjectId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("PhotoSubjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
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.Reviews.RatedReview", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RatedReviewId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ReviewId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Thumb")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("RatedReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("ReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RatedReviews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReviewId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DeletedBy")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("LabelCollection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ReviewerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<long>("Timestamp")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("ReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("ReviewerId");
|
||||||
|
|
||||||
|
b.HasIndex("SlotId");
|
||||||
|
|
||||||
|
b.ToTable("Reviews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ScoreId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("PlayerIdCollection")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("Points")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ScoreId");
|
||||||
|
|
||||||
|
b.HasIndex("SlotId");
|
||||||
|
|
||||||
|
b.ToTable("Scores");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("TokenId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("GameVersion")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("UserLocation")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
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<int>("Game")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("IconHash")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("LocationId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Pins")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("PlanetHash")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.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.RatedLevel", 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.Levels.VisitedLevel", 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.Photo", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Creator")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CreatorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Creator");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
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.Reviews.RatedReview", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Reviews.Review", "Review")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReviewId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Review");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Reviewer")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReviewerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SlotId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Reviewer");
|
||||||
|
|
||||||
|
b.Navigation("Slot");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SlotId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Slot");
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
ProjectLighthouse/Migrations/20211120025513_LevelReviews.cs
Normal file
105
ProjectLighthouse/Migrations/20211120025513_LevelReviews.cs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ProjectLighthouse.Migrations
|
||||||
|
{
|
||||||
|
public partial class LevelReviews : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Reviews",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
ReviewId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
ReviewerId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SlotId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Timestamp = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
LabelCollection = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Deleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
DeletedBy = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Text = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Reviews", x => x.ReviewId);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Reviews_Slots_SlotId",
|
||||||
|
column: x => x.SlotId,
|
||||||
|
principalTable: "Slots",
|
||||||
|
principalColumn: "SlotId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Reviews_Users_ReviewerId",
|
||||||
|
column: x => x.ReviewerId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RatedReviews",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
RatedReviewId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
UserId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ReviewId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Thumb = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RatedReviews", x => x.RatedReviewId);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RatedReviews_Reviews_ReviewId",
|
||||||
|
column: x => x.ReviewId,
|
||||||
|
principalTable: "Reviews",
|
||||||
|
principalColumn: "ReviewId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RatedReviews_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RatedReviews_ReviewId",
|
||||||
|
table: "RatedReviews",
|
||||||
|
column: "ReviewId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RatedReviews_UserId",
|
||||||
|
table: "RatedReviews",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Reviews_ReviewerId",
|
||||||
|
table: "Reviews",
|
||||||
|
column: "ReviewerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Reviews_SlotId",
|
||||||
|
table: "Reviews",
|
||||||
|
column: "SlotId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RatedReviews");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Reviews");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -439,6 +439,69 @@ namespace ProjectLighthouse.Migrations
|
||||||
b.ToTable("Locations");
|
b.ToTable("Locations");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.RatedReview", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RatedReviewId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ReviewId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Thumb")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("RatedReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("ReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RatedReviews");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ReviewId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DeletedBy")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("LabelCollection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ReviewerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SlotId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<long>("Timestamp")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("ReviewId");
|
||||||
|
|
||||||
|
b.HasIndex("ReviewerId");
|
||||||
|
|
||||||
|
b.HasIndex("SlotId");
|
||||||
|
|
||||||
|
b.ToTable("Reviews");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("ScoreId")
|
b.Property<int>("ScoreId")
|
||||||
|
@ -699,6 +762,44 @@ namespace ProjectLighthouse.Migrations
|
||||||
b.Navigation("Target");
|
b.Navigation("Target");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.RatedReview", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Reviews.Review", "Review")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReviewId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Review");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Reviewer")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReviewerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SlotId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Reviewer");
|
||||||
|
|
||||||
|
b.Navigation("Slot");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
|
b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot")
|
||||||
|
|
9
ProjectLighthouse/Types/DeletedBy.cs
Normal file
9
ProjectLighthouse/Types/DeletedBy.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types
|
||||||
|
{
|
||||||
|
public static class DeletedBy
|
||||||
|
{
|
||||||
|
public static string Moderator { get => "moderator"; }
|
||||||
|
public static string LevelAuthor { get => "level_author"; }
|
||||||
|
// TODO: deletion types for comments (profile etc)
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ using System.Xml.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Reviews;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Types.Levels
|
namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
{
|
{
|
||||||
|
@ -194,13 +195,23 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
[XmlElement("leveltype")]
|
[XmlElement("leveltype")]
|
||||||
public string LevelType { get; set; } = "";
|
public string LevelType { get; set; } = "";
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[XmlElement("reviewCount")]
|
||||||
|
public int ReviewCount {
|
||||||
|
get {
|
||||||
|
using Database database = new();
|
||||||
|
|
||||||
|
return database.Reviews.Count(r => r.SlotId == this.SlotId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string SerializeResources()
|
public string SerializeResources()
|
||||||
{
|
{
|
||||||
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource)) +
|
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource)) +
|
||||||
LbpSerializer.StringElement("sizeOfResources", this.Resources.Sum(FileHelper.ResourceSize));
|
LbpSerializer.StringElement("sizeOfResources", this.Resources.Sum(FileHelper.ResourceSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Serialize(RatedLevel? yourRatingStats = null, VisitedLevel? yourVisitedStats = null)
|
public string Serialize(RatedLevel? yourRatingStats = null, VisitedLevel? yourVisitedStats = null, Review? yourReview = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
string slotData = LbpSerializer.StringElement("name", this.Name) +
|
string slotData = LbpSerializer.StringElement("name", this.Name) +
|
||||||
|
@ -248,8 +259,11 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
LbpSerializer.StringElement("yourLBP1PlayCount", yourVisitedStats?.PlaysLBP1) +
|
LbpSerializer.StringElement("yourLBP1PlayCount", yourVisitedStats?.PlaysLBP1) +
|
||||||
LbpSerializer.StringElement("yourLBP2PlayCount", yourVisitedStats?.PlaysLBP2) +
|
LbpSerializer.StringElement("yourLBP2PlayCount", yourVisitedStats?.PlaysLBP2) +
|
||||||
LbpSerializer.StringElement("yourLBP3PlayCount", yourVisitedStats?.PlaysLBP3) +
|
LbpSerializer.StringElement("yourLBP3PlayCount", yourVisitedStats?.PlaysLBP3) +
|
||||||
LbpSerializer.StringElement
|
LbpSerializer.StringElement("yourLBPVitaPlayCount", yourVisitedStats?.PlaysLBPVita) + // i doubt this is the right name but we'll go with it
|
||||||
("yourLBPVitaPlayCount", yourVisitedStats?.PlaysLBPVita); // i doubt this is the right name but we'll go with it
|
yourReview?.Serialize("yourReview") +
|
||||||
|
LbpSerializer.StringElement("reviewsEnabled", true) +
|
||||||
|
LbpSerializer.StringElement("commentsEnabled", false) +
|
||||||
|
LbpSerializer.StringElement("reviewCount", this.ReviewCount);
|
||||||
|
|
||||||
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
|
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
|
||||||
}
|
}
|
||||||
|
|
24
ProjectLighthouse/Types/Reviews/RatedReview.cs
Normal file
24
ProjectLighthouse/Types/Reviews/RatedReview.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types.Reviews
|
||||||
|
{
|
||||||
|
public class RatedReview
|
||||||
|
{
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
|
[Key]
|
||||||
|
public int RatedReviewId { get; set; }
|
||||||
|
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(UserId))]
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
public int ReviewId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(ReviewId))]
|
||||||
|
public Review Review { get; set; }
|
||||||
|
|
||||||
|
public int Thumb { get; set; }
|
||||||
|
}
|
||||||
|
}
|
101
ProjectLighthouse/Types/Reviews/Review.cs
Normal file
101
ProjectLighthouse/Types/Reviews/Review.cs
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types.Reviews
|
||||||
|
{
|
||||||
|
[XmlRoot("review")]
|
||||||
|
[XmlType("review")]
|
||||||
|
public class Review
|
||||||
|
{
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
|
[Key]
|
||||||
|
public int ReviewId { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public int ReviewerId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(ReviewerId))]
|
||||||
|
public User Reviewer { get; set; }
|
||||||
|
|
||||||
|
[XmlElement("slot_id")]
|
||||||
|
public int SlotId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(SlotId))]
|
||||||
|
public Slot Slot { get; set; }
|
||||||
|
|
||||||
|
[XmlElement("timestamp")]
|
||||||
|
public long Timestamp { get; set; }
|
||||||
|
|
||||||
|
[XmlElement("labels")]
|
||||||
|
public string LabelCollection { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[XmlIgnore]
|
||||||
|
public string[] Labels {
|
||||||
|
get => this.LabelCollection.Split(",");
|
||||||
|
set => this.LabelCollection = string.Join(',', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlElement("deleted")]
|
||||||
|
public Boolean Deleted { get; set; }
|
||||||
|
|
||||||
|
[XmlElement("deleted_by")]
|
||||||
|
public string DeletedBy { get; set; } // enum ? Needs testing e.g. Moderated/Author/Level Author? etc.
|
||||||
|
|
||||||
|
[XmlElement("text")]
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[XmlElement("thumb")]
|
||||||
|
public int Thumb { get; set; } // (unused) -- temp value for getting thumb from review upload body for updating level rating
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[XmlElement("thumbsup")]
|
||||||
|
public int ThumbsUp {
|
||||||
|
get {
|
||||||
|
using Database database = new();
|
||||||
|
|
||||||
|
return database.RatedReviews.Count(r => r.ReviewId == this.ReviewId && r.Thumb == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[NotMapped]
|
||||||
|
[XmlElement("thumbsdown")]
|
||||||
|
public int ThumbsDown {
|
||||||
|
get {
|
||||||
|
using Database database = new();
|
||||||
|
|
||||||
|
return database.RatedReviews.Count(r => r.ReviewId == this.ReviewId && r.Thumb == -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Serialize(RatedLevel? yourLevelRating = null, RatedReview? yourRatingStats = null) {
|
||||||
|
return this.Serialize("review", yourLevelRating, yourRatingStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Serialize(string elementOverride, RatedLevel? yourLevelRating = null, RatedReview? yourRatingStats = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
string reviewData = LbpSerializer.TaggedStringElement("slot_id", this.SlotId, "type", this.Slot.Type) +
|
||||||
|
LbpSerializer.StringElement("reviewer", this.Reviewer.Username) +
|
||||||
|
LbpSerializer.StringElement("thumb", yourLevelRating?.Rating) +
|
||||||
|
LbpSerializer.StringElement("timestamp", this.Timestamp) +
|
||||||
|
LbpSerializer.StringElement("labels", this.LabelCollection) +
|
||||||
|
LbpSerializer.StringElement("deleted", this.Deleted) +
|
||||||
|
LbpSerializer.StringElement("deleted_by", this.DeletedBy) +
|
||||||
|
LbpSerializer.StringElement("text", this.Text) +
|
||||||
|
LbpSerializer.StringElement("thumbsup", this.ThumbsUp) +
|
||||||
|
LbpSerializer.StringElement("thumbsdown", this.ThumbsDown) +
|
||||||
|
LbpSerializer.StringElement("yourthumb", yourRatingStats?.Thumb == null ? 0 : yourRatingStats?.Thumb);
|
||||||
|
|
||||||
|
return LbpSerializer.TaggedStringElement(elementOverride, reviewData, "id", this.SlotId + "." + this.Reviewer.Username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,7 +26,12 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
public string Biography { get; set; }
|
public string Biography { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int Reviews => 0;
|
public int Reviews {
|
||||||
|
get {
|
||||||
|
using Database database = new();
|
||||||
|
return database.Reviews.Count(r => r.ReviewerId == this.UserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int Comments {
|
public int Comments {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue