Add index and create

This commit is contained in:
2014-05-20 14:24:08 -04:00
parent ef88c52658
commit 0fcfa3a3a1
8 changed files with 159 additions and 22 deletions
+33 -19
View File
@@ -238,33 +238,47 @@ namespace MileageTraker.Web.Utility
}
public static Dictionary<string, List<string>> YearMonthList(IEnumerable<DateTime> dates)
{
var tuples =
from d in dates
orderby d descending
select Tuple.Create(d.Year.ToString(), d.Month.ToString());
return GroupTuple(tuples);
//return
// (from d in dates
// orderby d.Year descending
// group d by d.Year
// into yg
// select
// new
// {
// Year = yg.Key.ToString(),
// MonthList =
// (from o in yg
// orderby o.Month descending
// group o by o.Month
// into mg
// select mg.Key.ToString()).ToList()
// }).ToDictionary(arg => arg.Year, arg => arg.MonthList);
}
public static Dictionary<string, List<string>> GroupTuple(IEnumerable<Tuple<string,string>> tuples)
{
return
(from d in dates
orderby d.Year descending
group d by d.Year
(from t in tuples
group t by t.Item1
into yg
select
new
{
Year = yg.Key.ToString(),
MonthList =
Item1 = yg.Key,
Item2List =
(from o in yg
orderby o.Month descending
group o by o.Month
group o by o.Item2
into mg
select mg.Key.ToString()).ToList()
}).ToDictionary(arg => arg.Year, arg => arg.MonthList);
}
public static RouteValueDictionary ToRouteValueDictionary(this NameValueCollection collection)
{
var routeValueDictionary = new RouteValueDictionary();
foreach (var key in collection.AllKeys)
{
routeValueDictionary.Add(key, collection[key]);
}
return routeValueDictionary;
select mg.Key).ToList()
}).ToDictionary(arg => arg.Item1, arg => arg.Item2List);
}
//public static IEnumerable<SelectListItem> ToSelectList<T>(