Clamp review thumb rating

This commit is contained in:
Slendy 2022-09-05 05:49:20 -05:00
parent eb7cda8997
commit 096a477d0d
No known key found for this signature in database
GPG key ID: 7288D68361B91428

View file

@ -112,7 +112,7 @@ public class ReviewController : ControllerBase
}; };
this.database.Reviews.Add(review); this.database.Reviews.Add(review);
} }
review.Thumb = newReview.Thumb; review.Thumb = Math.Clamp(newReview.Thumb, -1, 1);
review.LabelCollection = LabelHelper.RemoveInvalidLabels(newReview.LabelCollection); review.LabelCollection = LabelHelper.RemoveInvalidLabels(newReview.LabelCollection);
review.Text = newReview.Text; review.Text = newReview.Text;
@ -133,7 +133,7 @@ public class ReviewController : ControllerBase
this.database.RatedLevels.Add(ratedLevel); this.database.RatedLevels.Add(ratedLevel);
} }
ratedLevel.Rating = newReview.Thumb; ratedLevel.Rating = Math.Clamp(newReview.Thumb, -1, 1);
await this.database.SaveChangesAsync(); await this.database.SaveChangesAsync();