public List <PerformanceObj> GetTopFiveWorstThisMonth() { List <PerformanceTable> AllPerformanceItems = SqlLink.GetPerformanceItems(); List <PerformanceTable> TopFiveWorstPerformance = new List <PerformanceTable>(); List <PerformanceObj> TopFivePerformanceObjectsWorst = new List <PerformanceObj>(); string currentMonth = DateTime.Now.ToString("MMMM"); if (currentMonth == "January") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.January).ToList(); } if (currentMonth == "February") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.February).ToList(); } if (currentMonth == "March") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.March).ToList(); } if (currentMonth == "April") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.April).ToList(); } if (currentMonth == "May") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.May).ToList(); } if (currentMonth == "June") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.June).ToList(); } if (currentMonth == "July ") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.July).ToList(); } if (currentMonth == "August") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.August).ToList(); } if (currentMonth == "September") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.September).ToList(); } if (currentMonth == "October") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.October).ToList(); } if (currentMonth == "November") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.November).ToList(); } if (currentMonth == "December") { AllPerformanceItems = AllPerformanceItems.OrderBy(o => o.December).ToList(); } int x = 1; foreach (PerformanceTable perfElement in AllPerformanceItems) { if (x <= 5) { TopFiveWorstPerformance.Add(perfElement); x++; } } foreach (PerformanceTable conv in TopFiveWorstPerformance) { PerformanceObj nextobj = new PerformanceObj(); nextobj.ItemName = conv.ItemName; if (currentMonth == "January") { nextobj.Transfers = conv.January.Value; } if (currentMonth == "February") { nextobj.Transfers = conv.February.Value; } if (currentMonth == "March") { nextobj.Transfers = conv.March.Value; } if (currentMonth == "April") { nextobj.Transfers = conv.April.Value; } if (currentMonth == "May") { nextobj.Transfers = conv.May.Value; } if (currentMonth == "June") { nextobj.Transfers = conv.June.Value; } if (currentMonth == "July ") { nextobj.Transfers = conv.July.Value; } if (currentMonth == "August") { nextobj.Transfers = conv.August.Value; } if (currentMonth == "September") { nextobj.Transfers = conv.September.Value; } if (currentMonth == "October") { nextobj.Transfers = conv.October.Value; } if (currentMonth == "November") { nextobj.Transfers = conv.November.Value; } if (currentMonth == "December") { nextobj.Transfers = conv.December.Value; } TopFivePerformanceObjectsWorst.Add(nextobj); } return(TopFivePerformanceObjectsWorst); }
public List <PerformanceObj> GetTopFiveThisMonth() { //get every performance record List <PerformanceTable> AllPerformanceItems = SqlLink.GetPerformanceItems(); //the top five items List <PerformanceTable> TopFivePerformance = new List <PerformanceTable>(); //top five items as performance objects List <PerformanceObj> TopFivePerformanceObjects = new List <PerformanceObj>(); //get the current month string currentMonth = DateTime.Now.ToString("MMMM"); if (currentMonth == "January") { //orders the list in descending order for the January column AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.January).ToList(); } if (currentMonth == "February") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.February).ToList(); } if (currentMonth == "March") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.March).ToList(); } if (currentMonth == "April") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.April).ToList(); } if (currentMonth == "May") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.May).ToList(); } if (currentMonth == "June") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.June).ToList(); } if (currentMonth == "July ") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.July).ToList(); } if (currentMonth == "August") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.August).ToList(); } if (currentMonth == "September") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.September).ToList(); } if (currentMonth == "October") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.October).ToList(); } if (currentMonth == "November") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.November).ToList(); } if (currentMonth == "December") { AllPerformanceItems = AllPerformanceItems.OrderByDescending(o => o.December).ToList(); } int x = 1; //add the first five items to the top five performance list foreach (PerformanceTable perfElement in AllPerformanceItems) { if (x <= 5) { TopFivePerformance.Add(perfElement); x++; } } foreach (PerformanceTable conv in TopFivePerformance) { PerformanceObj nextobj = new PerformanceObj(); //setup the performance object nextobj.ItemName = conv.ItemName; if (currentMonth == "January") { nextobj.Transfers = conv.January.Value; } if (currentMonth == "February") { nextobj.Transfers = conv.February.Value; } if (currentMonth == "March") { nextobj.Transfers = conv.March.Value; } if (currentMonth == "April") { nextobj.Transfers = conv.April.Value; } if (currentMonth == "May") { nextobj.Transfers = conv.May.Value; } if (currentMonth == "June") { nextobj.Transfers = conv.June.Value; } if (currentMonth == "July ") { nextobj.Transfers = conv.July.Value; } if (currentMonth == "August") { nextobj.Transfers = conv.August.Value; } if (currentMonth == "September") { nextobj.Transfers = conv.September.Value; } if (currentMonth == "October") { nextobj.Transfers = conv.October.Value; } if (currentMonth == "November") { nextobj.Transfers = conv.November.Value; } if (currentMonth == "December") { nextobj.Transfers = conv.December.Value; } TopFivePerformanceObjects.Add(nextobj); } return(TopFivePerformanceObjects); }