コード例 #1
0
        public int TotalBreakdowns(int id, List <Ride> ridesList = null)
        {
            RideRepository rideRepository = new RideRepository();
            List <Ride>    rides          = ridesList;
            Ride           ride           = null;

            if (rides is null)
            {
                ride = rideRepository.GetRide(id);
            }
            else
            {
                ride = rideRepository.GetRide(id, rides);
            }
            int breakdowns = 0;

            foreach (Report report in ride.Reports)
            {
                if (report.Status == Status.Broken)
                {
                    breakdowns++;
                }
            }

            return(breakdowns);
        }
コード例 #2
0
        public int DaysSinceLastRideBreakdown(int id, List <Ride> ridesList = null)
        {
            RideRepository rideRepository = new RideRepository();
            List <Ride>    rides          = ridesList;
            Ride           ride           = null;

            if (rides is null)
            {
                ride = rideRepository.GetRide(id);
            }
            else
            {
                ride = rideRepository.GetRide(id, rides);
            }
            int days = 0;

            DateTime today      = DateTime.Now.Date;
            Report   lastReport = null;

            foreach (Report report in ride.Reports)
            {
                if (report.Status == Status.Broken)
                {
                    if (lastReport is null)
                    {
                        lastReport = report;
                    }
                    else
                    {
                        if (report.ReportTime.Date > lastReport.ReportTime.Date)
                        {
                            lastReport = report;
                        }
                    }
                }
            }

            if (lastReport is null)
            {
                return(-1);
            }

            DateTime lastReportDate = lastReport.ReportTime.Date;

            days = (today - lastReportDate).Days;

            return(days);
        }
コード例 #3
0
        public List <Report> GetReportsForRide(int id)
        {
            RideRepository rideRepository = new RideRepository();

            Ride ride = rideRepository.GetRide(id);

            return(ride.Reports);
        }