示例#1
0
        public static string middleThreeAve(List <RaceTimesVM> list)
        {
            double avg;

            if (list.Count > 1)
            {
                List <RaceTimesVM> mylist = new List <RaceTimesVM>();
                mylist = list;
                mylist.OrderByDescending(s => s.predictedRaw);
                int mid = Convert.ToInt32(mylist.Count / 2);
                List <RaceTimesVM> newList = mylist.GetRange(mid, 3);
                double             sum     = 0.0;
                double             count   = 0.0;

                foreach (var r in newList)
                {
                    sum = r.predictedRaw + sum;
                    count++;
                }
                avg = sum / count;
            }
            else
            {
                avg = list.First().predictedRaw;
            }
            return(RaceDetails.formatResult(Convert.ToInt32(avg)));
        }
示例#2
0
        public static string TopandTailAve(List <RaceTimesVM> list)
        {
            double avg;

            if (list.Count > 1)
            {
                List <RaceTimesVM> mylist = new List <RaceTimesVM>();
                mylist = list;
                double sum   = 0.0;
                double count = 0.0;
                mylist.OrderBy(s => s.predictedRaw);
                if (mylist.Count > 3)
                {
                    mylist.RemoveAt(0);
                }
                if (list.Count > 3)
                {
                    list.RemoveAt(list.Count - 1);
                }
                foreach (var r in list)
                {
                    sum = r.predictedRaw + sum;
                    count++;
                }
                avg = sum / count;
            }
            else
            {
                avg = list.First().predictedRaw;
            }
            return(RaceDetails.formatResult(Convert.ToInt32(avg)));
        }
示例#3
0
        public static IEnumerable <ClubMemberListItemVM> buildVM(IEnumerable <ClassLibrary1.memberList> listIN)
        {
            var vm = listIN.Select(m => new ClubMemberListItemVM
            {
                Name     = m.Name,
                Distance = RaceDetails.GetByRaceNameByMeters((double)m.Distance),
                Time     = RaceDetails.formatResult(m.Time),
                Id       = m.Id
            }

                                   ).AsEnumerable();

            return(vm);
        }
示例#4
0
        public static List <RaceTimesVM> buildList(IEnumerable <race> listofraces, double targetdistance)
        {
            List <RaceTimesVM> list = new List <RaceTimesVM>();

            list = listofraces.Select(s => new RaceTimesVM
            {
                lastRaceId       = s.Id,
                lastRaceDistance = RaceDetails.GetByRaceNameByMeters(s.distance),
                lastRaceTime     = RaceDetails.formatResult(s.time),
                //predictedTime = RaceDetails.formatResult(Convert.ToInt32(RaceDetails.calcPredictedTime(s.distance, , s.time) + RaceDetails.cameron(s.distance, 8046.72, s.time)) / 2),
                //predictedRaw = (RaceDetails.calcPredictedTime(s.distance, 8046.72, s.time) + RaceDetails.cameron(s.distance, 8046.72, s.time)) / 2
                predictedTime = RaceDetails.formatResult(Convert.ToInt32(RaceDetails.calcPredictedTime(s.distance, targetdistance, s.time) + RaceDetails.cameron(s.distance, targetdistance, s.time)) / 2),
                predictedRaw  = (RaceDetails.calcPredictedTime(s.distance, targetdistance, s.time) + RaceDetails.cameron(s.distance, targetdistance, s.time)) / 2
            }

                                      ).ToList();

            return(list);
        }
示例#5
0
        public static string CalcSimpleAve(List <RaceTimesVM> list)
        {
            double avg;

            if (list.Count > 1)
            {
                double sum   = 0.0;
                double count = 0.0;
                foreach (var r in list)
                {
                    sum = r.predictedRaw + sum;
                    count++;
                }
                avg = sum / count;
            }
            else
            {
                avg = list.First().predictedRaw;
            }
            return(RaceDetails.formatResult(Convert.ToInt32(avg)));
        }