private IEnumerable <double> GetCollection(string modelBoat, string property) { var collection = new List <double>(); switch (TypeReport) { case "Группировка по дням": { if (property == "Count") { foreach (var date in ListDates) { if (DailyPopularBoatsReport.Find(r => r.Model == modelBoat && ((DateTime)r.Date).ToString("yyyy-MM-dd") == date) == null) { collection.Add(double.NaN); } } DailyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Count)); } if (property == "Rate") { foreach (var date in ListDates) { if (DailyPopularBoatsReport.Find(r => r.Model == modelBoat && ((DateTime)r.Date).ToString("yyyy-MM-dd") == date) == null) { collection.Add(double.NaN); } } DailyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Rate)); } } break; case "Группировка по неделям": { if (property == "Count") { foreach (var date in ListDates) { if (WeeklyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } WeeklyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Count)); } if (property == "Rate") { foreach (var date in ListDates) { if (WeeklyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } WeeklyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Rate)); } } break; case "Группировка по месяцам": { if (property == "Count") { foreach (var date in ListDates) { if (MonthlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } MonthlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Count)); } if (property == "Rate") { foreach (var date in ListDates) { if (MonthlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } MonthlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Rate)); } } break; case "Группировка по кварталам": { if (property == "Count") { foreach (var date in ListDates) { if (QuarterlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } QuarterlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Count)); } if (property == "Rate") { foreach (var date in ListDates) { if (QuarterlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } QuarterlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Rate)); } } break; case "Группировка по годам": { if (property == "Count") { foreach (var date in ListDates) { if (YearlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } YearlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Count)); } if (property == "Rate") { foreach (var date in ListDates) { if (YearlyPopularBoatsReport.Find(r => r.Model == modelBoat && r.Date == date) == null) { collection.Add(double.NaN); } } YearlyPopularBoatsReport.Where(r => r.Model == modelBoat).ForEach(i => collection.Add((double)i.Rate)); } } break; } return(collection); }
private void GettingAndFillData() { BriefPopularBoatsReport = _eF.GetReportPopularBoats(ListSelectedBoats.ToList()); switch (TypeReport) { case "Группировка по дням": { DailyPopularBoatsReport = _eF.GetDetailDailyReportPopularBoats(ListSelectedBoats.ToList(), new Range <DateTime>(BeginValueDate, EndValueDate)); DailyPopularBoatsReport.ForEach(i => { if (!ListDates.Contains(((DateTime)i.Date).ToString("yyyy-MM-dd"))) { ListDates.Add(((DateTime)i.Date).ToString("yyyy-MM-dd")); } }); } break; case "Группировка по неделям": { WeeklyPopularBoatsReport = _eF.GetDetailWeeklyReportPopularBoats(ListSelectedBoats.ToList(), new Date(BeginValueDate), new Date(EndValueDate)); WeeklyPopularBoatsReport.ForEach(i => { if (!ListDates.Contains(i.Date)) { ListDates.Add(i.Date); } }); } break; case "Группировка по месяцам": { MonthlyPopularBoatsReport = _eF.GetDetailMonthlyReportPopularBoats(ListSelectedBoats.ToList(), new Date(BeginValueDate), new Date(EndValueDate)); MonthlyPopularBoatsReport.ForEach(i => { if (!ListDates.Contains(i.Date)) { ListDates.Add(i.Date); } }); } break; case "Группировка по кварталам": { QuarterlyPopularBoatsReport = _eF.GetDetailQuarterlyReportPopularBoats(ListSelectedBoats.ToList(), new Date(BeginValueDate), new Date(EndValueDate)); QuarterlyPopularBoatsReport.ForEach(i => { if (!ListDates.Contains(i.Date)) { ListDates.Add(i.Date); } }); } break; case "Группировка по годам": { YearlyPopularBoatsReport = _eF.GetDetailYearlyReportPopularBoats(ListSelectedBoats.ToList(), new Date(BeginValueDate), new Date(EndValueDate)); YearlyPopularBoatsReport.ForEach(i => { if (!ListDates.Contains(i.Date)) { ListDates.Add(i.Date); } }); } break; } }