mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 16:28:50 -07:00
minor (comments, etc) changes to PR
This commit is contained in:
parent
6e4d29b7b3
commit
df91fe154f
@ -143,7 +143,7 @@ public class RatingController : Controller
|
|||||||
rank.RatingAverage += (float)((decimal)r.Value / (decimal)rank.Ratings.Count);
|
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
|
RatingRank[] ranks = ctx.RatingRanks
|
||||||
.Where(rr => rr != rank && rr.CategoryID == category) // Only rank by category.
|
.Where(rr => rr != rank && rr.CategoryID == category) // Only rank by category.
|
||||||
.OrderBy(rr => rr.Rank)
|
.OrderBy(rr => rr.Rank)
|
||||||
@ -160,9 +160,11 @@ public class RatingController : Controller
|
|||||||
}
|
}
|
||||||
if (!resortOthers) rank.Rank = ranks.Length+1;
|
if (!resortOthers) rank.Rank = ranks.Length+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rating.Date = DateTime.UtcNow;
|
rating.Date = DateTime.UtcNow;
|
||||||
rank.UpdateDate = rating.Date;
|
rank.UpdateDate = rating.Date;
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
return new RatingInfo() {
|
return new RatingInfo() {
|
||||||
Id = rating.Id,
|
Id = rating.Id,
|
||||||
OwnerUid = viking.Uid,
|
OwnerUid = viking.Uid,
|
||||||
|
@ -7,15 +7,11 @@ public class Rating {
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int VikingId { get; set; }
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public int RankId { get; set; }
|
public int RankId { get; set; }
|
||||||
|
|
||||||
public int Value { get; set; }
|
public int Value { get; set; }
|
||||||
|
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public virtual Viking Viking { get; set; }
|
public virtual Viking Viking { get; set; }
|
||||||
|
|
||||||
public virtual RatingRank Rank { get; set; }
|
public virtual RatingRank Rank { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,11 @@ public class RatingRank {
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int CategoryID { get; set; }
|
public int CategoryID { get; set; }
|
||||||
|
|
||||||
public int? RatedEntityID { get; set; }
|
public int? RatedEntityID { get; set; }
|
||||||
public string? RatedUserID { get; set; }
|
public string? RatedUserID { get; set; }
|
||||||
|
|
||||||
public int Rank { get; set; }
|
public int Rank { get; set; }
|
||||||
|
public float RatingAverage { get; set; } // On a scale of 1-5
|
||||||
/// <summary>On a scale of 1-5</summary>
|
|
||||||
public float RatingAverage { get; set; }
|
|
||||||
|
|
||||||
public DateTime UpdateDate { get; set; }
|
public DateTime UpdateDate { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Rating> Ratings { get; set; } = null!;
|
public virtual ICollection<Rating> Ratings { get; set; } = null!;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user