public IEnumerable <DynamicForAYear> GetDynamicForAYearByUser(string UserId) { var reports = GetAllReportsByUserLastYear(UserId); var dynamics = new List <DynamicForAYear>(); for (int i = 1; i <= 12; i++) { var entry = new DynamicForAYear() { Month = i, Number = 0 }; foreach (var item in reports) { if (item.Creation.Month == i) { entry.Number++; } } dynamics.Add(entry); } return(dynamics); }
public IEnumerable <DynamicForAYear> RegistrationStatistik() { var _context = new ApplicationDbContext(); var users = _context.Users.ToList(); var statistik = new List <DynamicForAYear>(); for (int i = 1; i <= 12; i++) { var record = new DynamicForAYear { Month = i, Number = 0 }; foreach (var item in users) { if (item.RegistrationDate.Month == i && item.RegistrationDate.Year == DateTime.Now.Year) { record.Number++; } } statistik.Add(record); } return(statistik); }