Example #1
0
        public string GenerateReport()
        {
            var driverTripSummaries = udcs.GetDriverTripSummaries()
                                      .OrderByDescending(dts => dts.TotalDistance)
                                      .ThenBy(dts => dts.DriverName);

            //Generate Report
            var sb    = new StringBuilder();
            int count = driverTripSummaries.Count();

            foreach (var summary in driverTripSummaries.Select((x, i) => new { Value = x, Index = i }))
            {
                sb.AppendFormat("{0}: {1} miles", summary.Value.DriverName, bs.GetRoundedDistance(summary.Value.TotalDistance));

                int mph = Convert.ToInt32(bs.GetRoundedMph(summary.Value.TotalDistance, summary.Value.TotalMinutes));
                if (mph > 0)
                {
                    sb.AppendFormat(" @ {0} mph", mph);
                }

                //new lines except at the end
                if (summary.Index < count - 1)
                {
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }
        public void CheckTripThenRegister(Trip t)
        {
            // TODO would want to test if someone is registered first.

            // Discard any trips that average a speed of less than 5 mph or greater than 100 mph.
            var mph = bs.GetRoundedMph(t.MilesDriven, bs.GetMinutesElapsed(t));

            if (mph < 5 || mph > 100)
            {
                //For now, just discard. Later we may want to log it or something.
            }
            else
            {
                ActuallyRegisterTrip(t);
            }
        }