private double CalculateAvarageSpeed(TrialRoundPerformance performance) { var startTime = performance.StartedAtTime.GetValueOrDefault(); var finishTime = performance.FinishedAtTime.GetValueOrDefault(); var lenght = performance.LengthInKilometers; var timeSpan = finishTime - startTime; var hours = timeSpan.TotalHours; return(lenght / hours); }
public (string vetGateEntryDeadline, double avarageSpeed) Finish( TrialRoundPerformance performance, string finishedAtValue) { performance.FinishedAtTime = DateTime.Parse(finishedAtValue); var avarageSpeed = CalculateAvarageSpeed(performance); var vetGateEntryDeadline = performance.FinishedAtTime.Value.AddMinutes(performance.VetGateEntryInMinutes); performance.AvarageSpeed = avarageSpeed; performance.VetGateEntryDeadlineTime = vetGateEntryDeadline; this.performancesData.Update(performance); return(vetGateEntryDeadline.ToString("HH:mm"), Math.Round(avarageSpeed, 2)); }
public (bool disqualified, bool passed, string) VetGateAttempt( TrialRoundPerformance performance, VetGateStatus vetGateStatus) { performance.VetGateEntryTime = DateTime.Now; if (performance.VetGateEntryTime > performance.VetGateEntryDeadlineTime) { this.performancesData.Update(performance); return(disqualified : true, passed : false, "Exceeded VetGate entry time"); } if (performance.FirstVetGateEntryStatus == VetGateStatus.NotEntered) { performance.FirstVetGateEntryStatus = vetGateStatus; if (vetGateStatus == VetGateStatus.Failed) { this.performancesData.Update(performance); return(disqualified : false, passed : false, string.Empty); } } else { performance.SecondVetGateEntryStatus = vetGateStatus; if (vetGateStatus == VetGateStatus.Failed) { this.performancesData.Update(performance); return(disqualified : true, passed : false, string.Empty); } } var nextPerformanceStartAtTime = SetNextPerformanceStartTime( performance.Index, performance.CompetitorId, performance.MaxRestTimeInMinutes); return(disqualified : false, passed : true, nextPerformanceStartAtTime?.ToString("HH:mm")); }