public static LunchCountGridViewData Create(LunchCountGrid lunchCountGrid) { return(new LunchCountGridViewData { Students = StudentLunchCountViewData.Create(lunchCountGrid.Students), Staffs = StaffViewData.Create(lunchCountGrid.Staffs), MealItems = MealItemViewData.Create(lunchCountGrid.MealItems), Date = lunchCountGrid.Date, ClassId = lunchCountGrid.ClassId, IncludeGuest = lunchCountGrid.IncludeGuest }); }
public async Task <LunchCountGrid> GetLunchCountGrid(int classId, DateTime date, bool includeGuests) { BaseSecurity.EnsureAdminOrTeacher(Context); var scheduledDate = GetNearestScheduledDate(classId, date); var lunchCountsTask = ConnectorLocator.LunchConnector.GetLunchCount(classId, scheduledDate); var students = ServiceLocator.StudentService.GetClassStudents(classId, null, true).OrderBy(x => x.LastName).ThenBy(x => x.FirstName).ToList(); var currentClass = ServiceLocator.ClassService.GetById(classId); var staffs = ServiceLocator.StaffService.SearchStaff(Context.SchoolYearId, classId, null, null, false, 0, int.MaxValue) .OrderBy(x => x.Id != currentClass.PrimaryTeacherRef).ToList(); //primary theacher should be on the TOP var mealTypes = ServiceLocator.MealTypeService.GetAll(); var studentsCustomAlertDetails = ServiceLocator.StudentCustomAlertDetailService.GetListByStudentIds(students.Select(x => x.Id).ToList()); return(LunchCountGrid.Create(classId, scheduledDate, students, staffs, mealTypes, studentsCustomAlertDetails, await lunchCountsTask, includeGuests)); }