Removed unneccesary usings and changed owner to viking.

This commit is contained in:
Hipposgrumm 2025-02-04 15:08:34 -07:00
parent 840109ba8d
commit 581ca93e63
6 changed files with 10 additions and 19 deletions

View File

@ -1,13 +1,9 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using sodoff.Attributes; using sodoff.Attributes;
using sodoff.Configuration;
using sodoff.Model; using sodoff.Model;
using sodoff.Schema; using sodoff.Schema;
using sodoff.Services;
using sodoff.Util; using sodoff.Util;
using System.Security.Cryptography;
namespace sodoff.Controllers.Common; namespace sodoff.Controllers.Common;
@ -123,7 +119,7 @@ public class RatingController : Controller
bool newRating = rating == null; bool newRating = rating == null;
if (newRating) { if (newRating) {
rating = new Rating { rating = new Rating {
OwnerId = viking.Id, VikingId = viking.Id,
CategoryID = category, CategoryID = category,
RatedEntityID = eID, RatedEntityID = eID,
RatedUserID = uID RatedUserID = uID
@ -213,7 +209,7 @@ public class RatingController : Controller
.Where(r => r.CategoryID == categoryID && r.RatedEntityID == ratedEntityID && r.RatedUserID == null) .Where(r => r.CategoryID == categoryID && r.RatedEntityID == ratedEntityID && r.RatedUserID == null)
.Select(r => new RatingInfo { .Select(r => new RatingInfo {
Id = r.Id, Id = r.Id,
OwnerUid = r.Owner.Uid, OwnerUid = r.Viking.Uid,
CategoryID = r.CategoryID, CategoryID = r.CategoryID,
RatedEntityID = r.RatedEntityID, RatedEntityID = r.RatedEntityID,
Value = r.Value, Value = r.Value,

View File

@ -143,7 +143,7 @@ public class DBContext : DbContext {
.WithMany(e => e.Vikings); .WithMany(e => e.Vikings);
builder.Entity<Viking>().HasMany(v => v.Ratings) builder.Entity<Viking>().HasMany(v => v.Ratings)
.WithOne(r => r.Owner); .WithOne(r => r.Viking);
// Dragons // Dragons
builder.Entity<Dragon>().HasOne(d => d.Viking) builder.Entity<Dragon>().HasOne(d => d.Viking)
@ -267,9 +267,9 @@ public class DBContext : DbContext {
.WithMany(e => e.Groups); .WithMany(e => e.Groups);
// Rating // Rating
builder.Entity<Rating>().HasOne(r => r.Owner) builder.Entity<Rating>().HasOne(r => r.Viking)
.WithMany(v => v.Ratings) .WithMany(v => v.Ratings)
.HasForeignKey(r => r.OwnerId); .HasForeignKey(r => r.VikingId);
builder.Entity<Rating>().HasOne(r => r.Rank) builder.Entity<Rating>().HasOne(r => r.Rank)
.WithMany(rr => rr.Ratings) .WithMany(rr => rr.Ratings)

View File

@ -1,5 +1,4 @@
using sodoff.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace sodoff.Model; namespace sodoff.Model;
@ -8,12 +7,11 @@ public class Rating {
public int Id { get; set; } public int Id { get; set; }
/// <summary>Viking that controls this data.</summary> /// <summary>Viking that controls this data.</summary>
public virtual Viking? Owner { get; set; } public virtual Viking? Viking { get; set; }
public virtual RatingRank? Rank { get; set; } public virtual RatingRank? Rank { get; set; }
/// <summary>VikingId</summary> public int VikingId { get; set; }
public int OwnerId { get; set; }
public int RankId { get; set; } // Done this to prevent it from generating an unnecessary pairs table. public int RankId { get; set; } // Done this to prevent it from generating an unnecessary pairs table.

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
namespace sodoff.Model; namespace sodoff.Model;

View File

@ -1,5 +1,4 @@
using sodoff.Model; using System.Xml.Serialization;
using System.Xml.Serialization;
namespace sodoff.Schema; namespace sodoff.Schema;

View File

@ -1,5 +1,4 @@
using sodoff.Model; using System.Xml.Serialization;
using System.Xml.Serialization;
namespace sodoff.Schema; namespace sodoff.Schema;