From df91fe154f1ca54a3a54ed4926a8ec645fd0f937 Mon Sep 17 00:00:00 2001 From: Robert Paciorek Date: Sat, 8 Feb 2025 09:01:10 +0000 Subject: [PATCH] minor (comments, etc) changes to PR --- src/Controllers/Common/RatingController.cs | 4 +++- src/Model/Rating.cs | 4 ---- src/Model/RatingRank.cs | 6 +----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Controllers/Common/RatingController.cs b/src/Controllers/Common/RatingController.cs index afbd91f..0411997 100644 --- a/src/Controllers/Common/RatingController.cs +++ b/src/Controllers/Common/RatingController.cs @@ -143,7 +143,7 @@ public class RatingController : Controller rank.RatingAverage += (float)((decimal)r.Value / (decimal)rank.Ratings.Count); } - if (eID != -1 || uID != null) { + if (eID != -1 || uID != null) { // do not sort "single item" (eID == -1 and no uID) category RatingRank[] ranks = ctx.RatingRanks .Where(rr => rr != rank && rr.CategoryID == category) // Only rank by category. .OrderBy(rr => rr.Rank) @@ -160,9 +160,11 @@ public class RatingController : Controller } if (!resortOthers) rank.Rank = ranks.Length+1; } + rating.Date = DateTime.UtcNow; rank.UpdateDate = rating.Date; ctx.SaveChanges(); + return new RatingInfo() { Id = rating.Id, OwnerUid = viking.Uid, diff --git a/src/Model/Rating.cs b/src/Model/Rating.cs index ada0f52..565e736 100644 --- a/src/Model/Rating.cs +++ b/src/Model/Rating.cs @@ -7,15 +7,11 @@ public class Rating { public int Id { get; set; } public int VikingId { get; set; } - public int RankId { get; set; } public int Value { get; set; } - public DateTime Date { get; set; } - public virtual Viking Viking { get; set; } - public virtual RatingRank Rank { get; set; } } diff --git a/src/Model/RatingRank.cs b/src/Model/RatingRank.cs index 13fc5e6..1eebec1 100644 --- a/src/Model/RatingRank.cs +++ b/src/Model/RatingRank.cs @@ -7,15 +7,11 @@ public class RatingRank { public int Id { get; set; } public int CategoryID { get; set; } - public int? RatedEntityID { get; set; } public string? RatedUserID { get; set; } public int Rank { get; set; } - - /// On a scale of 1-5 - public float RatingAverage { get; set; } - + public float RatingAverage { get; set; } // On a scale of 1-5 public DateTime UpdateDate { get; set; } public virtual ICollection Ratings { get; set; } = null!;