コード例 #1
0
        public ActionResult ReviewPilots()
        {
            List <Member> members = _dataService.GetMembersWithFlightReview();
            List <PilotReviewItemViewModel> pilots = new List <PilotReviewItemViewModel>();

            foreach (var member in members)
            {
                PilotReviewItemViewModel item = new PilotReviewItemViewModel();
                item.PilotId           = member.Id;
                item.PilotName         = member.FullName;
                item.AircraftCheckouts = String.Empty;

                //foreach (var c in member.Checkouts)
                //{
                //    Aircraft aircraft = _dataService.GetAircraftById(c.AircraftId);
                //    item.AircraftCheckouts += aircraft.RegistrationNumber + ",";
                //}
                //if (item.AircraftCheckouts != String.Empty)
                //    item.AircraftCheckouts = item.AircraftCheckouts.Remove(item.AircraftCheckouts.Length - 1, 1);

                if (member.FlightReviews != null && member.FlightReviews.Count > 0)
                {
                    DateTime reviewDate = member.FlightReviews.OrderByDescending(r => r.Date).First().Date;
                    item.LastReviewDate = reviewDate.ToString("MM-dd-yyyy");
                    if (reviewDate.AddYears(1) < DateTime.Now)
                    {
                        item.IsOverdue = true;
                    }
                }
                else
                {
                    item.IsOverdue = true;
                }

                pilots.Add(item);
            }

            //List<PilotCheckoutsViewModel> pilots = new List<PilotCheckoutsViewModel>();
            //foreach (var member in members)
            //    pilots.Add(InitializeCheckoutViewModel(member));

            return(View(ViewNames.ReviewPilots, pilots));
        }