public bool IsBetterThan(Score currentScore) { return Time.IsBetterThan(currentScore.Time) || Weight > currentScore.Weight || Rounds > currentScore.Rounds || Rounds == currentScore.Rounds && Reps > currentScore.Reps; }
public void RoundComparison() { var score1 = new Score { Rounds = 12 }; var score2 = new Score { Rounds = 1 }; score1.IsBetterThan(score2).ShouldBeTrue(); score2.IsBetterThan(score1).ShouldBeFalse(); }
public void WeightComparison() { var score1 = new Score {Weight = 123M}; var score2 = new Score {Weight = 120M}; score1.IsBetterThan(score2).ShouldBeTrue(); score2.IsBetterThan(score1).ShouldBeFalse(); }
private void AddNewScore(string workoutId, string athleteId, Score newScore) { newScore.AthleteId = athleteId; newScore.WorkoutId = workoutId; session.Store(newScore); flash.Flash(new Message {Text = "Congratulations on the new score"}); }
public void TimeComparisons() { var score1 = new Score {Time = new Time {Minutes = 12, Seconds = 34.5M}}; var score2 = new Score {Time = new Time {Minutes = 1, Seconds = 2.3M}}; var score3 = new Score {Time = new Time {Minutes = 1, Seconds = 2.2M}}; score1.IsBetterThan(score2).ShouldBeFalse(); score2.IsBetterThan(score1).ShouldBeTrue(); score3.IsBetterThan(score2).ShouldBeTrue(); }
public void Update(string workoutId, string athleteId, Score newScore) { var currentScore = FindCurrentScore(workoutId, athleteId); if (currentScore == null) AddNewScore(workoutId, athleteId, newScore); else if (newScore.IsBetterThan(currentScore)) DeleteOldAndAddNewScore(workoutId, athleteId, newScore, currentScore); }
public void RoundAndRepComparison() { var score1 = new Score { Rounds = 12,Reps = 1}; var score2 = new Score { Rounds = 12, Reps = 12}; var score3 = new Score { Rounds = 1, Reps = 55}; score1.IsBetterThan(score2).ShouldBeFalse(); score2.IsBetterThan(score1).ShouldBeTrue(); score3.IsBetterThan(score1).ShouldBeFalse(); score2.IsBetterThan(score3).ShouldBeTrue(); }
private void DeleteOldAndAddNewScore(string workoutId, string athleteId, Score newScore, Score currentScore) { session.Delete(currentScore); AddNewScore(workoutId, athleteId, newScore); }