コード例 #1
0
        public Ride GetMostBrokenRide(int?categoryId = null, List <Ride> ridesList = null)
        {
            RideRepository   rideRepository   = new RideRepository();
            ReportRepository reportRepository = new ReportRepository();
            List <Ride>      rides            = ridesList;

            if (rides is null)
            {
                rides = rideRepository.GetRides();
            }
            Ride rideToReturn = null;
            int  breakdowns   = 0;

            foreach (Ride ride in rides)
            {
                if (rideToReturn is null)
                {
                    if (categoryId is null)
                    {
                        rideToReturn = ride;
                        breakdowns   = reportRepository.TotalBreakdowns(ride.Id, rides);
                    }
                    else if (ride.Category.Id == categoryId)
                    {
                        rideToReturn = ride;
                        breakdowns   = reportRepository.TotalBreakdowns(ride.Id, rides);
                    }
                }
                else
                {
                    int rideBreakdowns = reportRepository.TotalBreakdowns(ride.Id, rides);
                    if (rideBreakdowns > breakdowns)
                    {
                        if (categoryId is null)
                        {
                            rideToReturn = ride;
                            breakdowns   = rideBreakdowns;
                        }
                        else if (ride.Id == categoryId)
                        {
                            rideToReturn = ride;
                            breakdowns   = rideBreakdowns;
                        }
                    }
                }
            }

            return(rideToReturn);
        }
コード例 #2
0
        public int?DaysSinceLastBreakdownOnRides(List <Ride> ridesList = null)
        {
            RideRepository rideRepository = new RideRepository();
            List <Ride>    rides          = ridesList;

            if (rides is null)
            {
                rides = rideRepository.GetRides();
            }
            Ride rideToReturn = null;
            int  days         = 0;

            foreach (Ride ride in rides)
            {
                int daysSinceBreakdown = DaysSinceLastRideBreakdown(ride.Id, rides);
                if (rideToReturn is null && daysSinceBreakdown != -1)
                {
                    days         = daysSinceBreakdown;
                    rideToReturn = ride;
                }
コード例 #3
0
        public Ride GetLastBrokenRide(List <Ride> ridesList = null)
        {
            RideRepository   rideRepository   = new RideRepository();
            ReportRepository reportRepository = new ReportRepository();
            List <Ride>      rides            = ridesList;

            if (rides is null)
            {
                rides = rideRepository.GetRides();
            }
            Ride rideToReturn  = null;
            int  lastBreakdown = 0;

            foreach (Ride ride in rides)
            {
                int rideLastBreakdown = reportRepository.DaysSinceLastRideBreakdown(ride.Id, rides);
                if (rideToReturn is null && rideLastBreakdown != -1)
                {
                    rideToReturn  = ride;
                    lastBreakdown = reportRepository.DaysSinceLastRideBreakdown(ride.Id, rides);
                }