From 581ca93e63927309a4dc9723df0287789437ced2 Mon Sep 17 00:00:00 2001 From: Hipposgrumm Date: Tue, 4 Feb 2025 15:08:34 -0700 Subject: [PATCH] Removed unneccesary usings and changed owner to viking. --- src/Controllers/Common/RatingController.cs | 8 ++------ src/Model/DBContext.cs | 6 +++--- src/Model/Rating.cs | 8 +++----- src/Model/RatingRank.cs | 1 - src/Schema/RatingInfo.cs | 3 +-- src/Schema/UserRatingRankInfo.cs | 3 +-- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Controllers/Common/RatingController.cs b/src/Controllers/Common/RatingController.cs index b7bcd1d..10cae4f 100644 --- a/src/Controllers/Common/RatingController.cs +++ b/src/Controllers/Common/RatingController.cs @@ -1,13 +1,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; using sodoff.Attributes; -using sodoff.Configuration; using sodoff.Model; using sodoff.Schema; -using sodoff.Services; using sodoff.Util; -using System.Security.Cryptography; namespace sodoff.Controllers.Common; @@ -123,7 +119,7 @@ public class RatingController : Controller bool newRating = rating == null; if (newRating) { rating = new Rating { - OwnerId = viking.Id, + VikingId = viking.Id, CategoryID = category, RatedEntityID = eID, RatedUserID = uID @@ -213,7 +209,7 @@ public class RatingController : Controller .Where(r => r.CategoryID == categoryID && r.RatedEntityID == ratedEntityID && r.RatedUserID == null) .Select(r => new RatingInfo { Id = r.Id, - OwnerUid = r.Owner.Uid, + OwnerUid = r.Viking.Uid, CategoryID = r.CategoryID, RatedEntityID = r.RatedEntityID, Value = r.Value, diff --git a/src/Model/DBContext.cs b/src/Model/DBContext.cs index 45c5356..1e881e5 100644 --- a/src/Model/DBContext.cs +++ b/src/Model/DBContext.cs @@ -143,7 +143,7 @@ public class DBContext : DbContext { .WithMany(e => e.Vikings); builder.Entity().HasMany(v => v.Ratings) - .WithOne(r => r.Owner); + .WithOne(r => r.Viking); // Dragons builder.Entity().HasOne(d => d.Viking) @@ -267,9 +267,9 @@ public class DBContext : DbContext { .WithMany(e => e.Groups); // Rating - builder.Entity().HasOne(r => r.Owner) + builder.Entity().HasOne(r => r.Viking) .WithMany(v => v.Ratings) - .HasForeignKey(r => r.OwnerId); + .HasForeignKey(r => r.VikingId); builder.Entity().HasOne(r => r.Rank) .WithMany(rr => rr.Ratings) diff --git a/src/Model/Rating.cs b/src/Model/Rating.cs index bcbe2eb..3f1ad59 100644 --- a/src/Model/Rating.cs +++ b/src/Model/Rating.cs @@ -1,5 +1,4 @@ -using sodoff.Schema; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; namespace sodoff.Model; @@ -8,12 +7,11 @@ public class Rating { public int Id { get; set; } /// Viking that controls this data. - public virtual Viking? Owner { get; set; } + public virtual Viking? Viking { get; set; } public virtual RatingRank? Rank { get; set; } - /// VikingId - public int OwnerId { get; set; } + public int VikingId { get; set; } public int RankId { get; set; } // Done this to prevent it from generating an unnecessary pairs table. diff --git a/src/Model/RatingRank.cs b/src/Model/RatingRank.cs index 1e2d12f..04a759e 100644 --- a/src/Model/RatingRank.cs +++ b/src/Model/RatingRank.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using System.Xml.Serialization; namespace sodoff.Model; diff --git a/src/Schema/RatingInfo.cs b/src/Schema/RatingInfo.cs index 42eef8e..df11cf1 100644 --- a/src/Schema/RatingInfo.cs +++ b/src/Schema/RatingInfo.cs @@ -1,5 +1,4 @@ -using sodoff.Model; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace sodoff.Schema; diff --git a/src/Schema/UserRatingRankInfo.cs b/src/Schema/UserRatingRankInfo.cs index 2a94044..dbcd6eb 100644 --- a/src/Schema/UserRatingRankInfo.cs +++ b/src/Schema/UserRatingRankInfo.cs @@ -1,5 +1,4 @@ -using sodoff.Model; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace sodoff.Schema;