public void SaveOrUpdate(PersonalBest personalBest)
 {
     using (ISession session = CreateSessionFactory().OpenSession())
     {
         session.SaveOrUpdate(personalBest);
         session.Flush();
     }
 }
 public void ShouldHaveIncompleteToStringWithNoTimeUsingStringPresenter()
 {
     var personalBest = new PersonalBest()
     {
         PersonName = "Jim Saunders",
         EventName = "200m Sprint"
     };
     Assert.AreEqual("Incomplete record", _stringPresenter.Present(personalBest));
 }
 public void ShouldHaveIncompleteToStringWithNoPersonNameUsingStringPresenter()
 {
     var personalBest = new PersonalBest()
     {
         EventName = "200m Freestyle",
         TimeTicks = unchecked((int)new TimeSpan(0, 0, 1, 47, 20).Ticks)
     };
     Assert.AreEqual("Incomplete record", _stringPresenter.Present(personalBest));
 }
 public void ShouldHaveEventNameAndTimeInToStringUsingStringPresenter()
 {
     var personalBest = new PersonalBest()
     {
         PersonName = "Henry Lawson",
         EventName = "200m Freestyle",
         TimeTicks = unchecked((int)new TimeSpan(0, 0, 1, 47, 20).Ticks)
     };
     Assert.AreEqual("Henry Lawson - 200m Freestyle: 00:01:47.0200000", _stringPresenter.Present(personalBest));
 }
 public string Present(PersonalBest personalBest)
 {
     return personalBest.AreAllPropertiesSet ? String.Format("{0} - {1}: {2}",
         personalBest.PersonName, personalBest.EventName, personalBest.Time) : "Incomplete record";
 }
Exemple #6
0
        public static string ToUrlEncode(
            PuzzleRound round,
            SolveCalculations calculations,
            PersonalBest currentPb)
        {
            if (round == null)
            {
                return("");
            }

            var builder = new StringBuilder();

            builder.Append(round.Puzzle);
            if (!string.IsNullOrEmpty(round.Name))
            {
                builder.Append("%20");
                builder.Append(round.Name.Replace(" ", "%20"));
            }
            builder.Append("%0a");

            builder.Append("-----%0a");

            foreach (var solve in round.Solves)
            {
                builder.Append(solve.Number);
                builder.Append("%20-%20");
                builder.Append(solve.Result);
                builder.Append("%0a");
            }

            builder.Append("-----%0a");

            var hasCurrentAverage = calculations.CurrentAverage != NA;
            var hasNeededForNewPB = calculations.NeededForNewPB != NA;
            var hasBPA            = calculations.BestPossibleAverage != NA;

            if (hasCurrentAverage)
            {
                builder.Append("Live%20");
                builder.Append(calculations.CurrentAverage);

                if (hasNeededForNewPB || hasBPA)
                {
                    builder.Append(",%20");
                }
            }

            if (hasNeededForNewPB)
            {
                builder.Append("For%20PB%20");
                builder.Append(calculations.NeededForNewPB);

                if (hasBPA)
                {
                    builder.Append(",%20");
                }
            }

            if (hasBPA)
            {
                builder.Append("BPA%20");
                builder.Append(calculations.BestPossibleAverage);
            }

            if (currentPb != null)
            {
                builder.Append("%0a-----%0a");
                builder.Append("PBs:%20Single%20");
                builder.Append(currentPb.Single);
                builder.Append("%20Avg%20");
                builder.Append(currentPb.Average);
            }

            return(builder.ToString());
        }
 /// <summary>
 /// Transforms all relevant values to metric system for DB
 /// </summary>
 private void TransformValuesToMetricSystem(PersonalBest entity, UnitSystem unitSystem)
 {
     entity.Value      = entity.Value.ToMetricSystem(unitSystem);
     entity.Bodyweight = entity.Bodyweight?.ToMetricSystem(unitSystem);
 }
        ///// <summary>
        ///// Gets exercise type for personal best record
        ///// TODO: Handler exists for this however it has overhead of data
        ///// TODO: We need to reuse it but implement something that blocks extra data fetching as it's expensive
        ///// </summary>
        //internal async Task<ExerciseType> GetExerciseType(Guid id, CancellationToken cancellationToken)
        //{

        //    var type = await _context.ExerciseTypes.FirstOrDefaultAsync(x => x.Id == id, cancellationToken);

        //    if (type == null)
        //        throw new NotFoundException(nameof(ExerciseType), $"Exercise type not found for new PB record id: {id}");

        //    return type;
        //}

        /// <summary>
        /// Calculates and sets properties like wilks score or ipf points
        /// </summary>
        private void CalculateStatistics(PersonalBest entity)
        {
            // TODO IMPLEMENT CALCULATORS FOR THIS
        }
Exemple #9
0
 public UpdatePersonalBestRequest(PersonalBest entity)
 {
     Id    = entity.Id;
     Value = entity.Value;
     Date  = entity.DateAchieved;
 }
 public void ShouldHaveIncompleteToStringWithNoPropertiesUsingStringPresenter()
 {
     var personalBest = new PersonalBest();
     Assert.AreEqual("Incomplete record", _stringPresenter.Present(personalBest));
 }