public object function(List<Students> stu)
{
var res=from p in stu
where p.CurrentStatus=="Present"
group p by (Weekly(p.DateTime))) into Grp
group p by (Quarterly(p.DateTime.Value.Month)) into Grp
select new ResClass
{
label = Grp.Key.ToString(),
fee = Grp.Count(x=>x.fee)
};
}
public int Weekly(DateTime day)
{
return System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(day, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
}
public int Quarterly(int month)
{
if (month == 1 || month == 2 || month == 3)
{
return 1;
}
if (month == 4 || month == 5 || month == 6)
{
return 2;
}
if (month == 7 || month == 8 || month == 9)
{
return 3;
}
else
{
return 4;
}
}
No comments:
Post a Comment