Example #1
0
        public SeatingChartInfo GetSeatingChart(int classId, int markingPeriodId)
        {
            var seatingChart = ConnectorLocator.SeatingChartConnector.GetChart(classId, markingPeriodId);

            if (seatingChart == null)
            {
                return(null);
            }
            return(SeatingChartInfo.Create(seatingChart));
        }
Example #2
0
        public ActionResult PostSeatingChart(DateTime?date, SeatingChartInfo seatingChartInfo, bool needInfo)
        {
            var d  = (date ?? Context.NowSchoolYearTime).Date;
            var mp = SchoolLocator.MarkingPeriodService.GetMarkingPeriodByDate(d, true);

            SchoolLocator.AttendanceService.UpdateSeatingChart(seatingChartInfo.ClassId, mp.Id, seatingChartInfo);
            if (needInfo)
            {
                return(Json(GetSeatingChart(date, seatingChartInfo.ClassId)));
            }
            return(Json(true));
        }
        public static AttendanceSeatingChartViewData Create(SeatingChartInfo seatingChart
                                                            , IList <StudentClassAttendanceOldViewData> classAttendance, IList <Student> students)
        {
            var res = new AttendanceSeatingChartViewData
            {
                Columns                 = seatingChart.Columns,
                Rows                    = seatingChart.Rows,
                SeatingList             = new List <IList <AttendanceSeatingChartItemViewData> >(),
                NotSeatingStudents      = new List <StudentClassAttendanceOldViewData>(),
                IsScheduled             = classAttendance.Count > 0,
                IsDailyAttendancePeriod = classAttendance.Count > 0 && classAttendance.First().IsDailyAttendancePeriod
            };
            var notSeatingStudents = students.Where(x => seatingChart.SeatingList.All(y => y.All(z => x.Id != z.StudentId))).OrderBy(x => x.LastName).ThenBy(x => x.FirstName).ToList();

            foreach (var notSeatingStudent in notSeatingStudents)
            {
                var classAtt = classAttendance.FirstOrDefault(x => x.Student.Id == notSeatingStudent.Id) ??
                               new StudentClassAttendanceOldViewData {
                    Student = StudentViewData.Create(notSeatingStudent)
                };
                res.NotSeatingStudents.Add(classAtt);
            }

            classAttendance.Where(x => seatingChart.SeatingList.All(y => y.All(z => x.Student.Id != z.StudentId))).ToList();
            foreach (var seats in seatingChart.SeatingList)
            {
                var seatingItems = new List <AttendanceSeatingChartItemViewData>();
                foreach (var seat in seats)
                {
                    StudentClassAttendanceOldViewData classAtt = null;
                    var student = students.FirstOrDefault(x => x.Id == seat.StudentId);
                    if (student != null)
                    {
                        classAtt = classAttendance.FirstOrDefault(x => x.Student.Id == student.Id) ??
                                   new StudentClassAttendanceOldViewData {
                            Student = StudentViewData.Create(student)
                        }
                    }
                    ;

                    seatingItems.Add(AttendanceSeatingChartItemViewData.Create(seat, classAtt));
                }
                res.SeatingList.Add(seatingItems);
            }
            return(res);
        }
    }
        public void UpdateSeatingChart(int classId, int markingPeriodId, SeatingChartInfo seatingChartInfo)
        {
            var seatingChart = new SeatingChart
            {
                Columns   = seatingChartInfo.Columns,
                Rows      = seatingChartInfo.Rows,
                SectionId = classId,
            };
            var stiSeats       = new List <Seat>();
            var students       = ServiceLocator.StudentService.GetClassStudents(classId, markingPeriodId);
            var defaultStudent = students.FirstOrDefault(x => seatingChartInfo.SeatingList.All(y => y.All(z => z.StudentId != x.Id)));

            if (defaultStudent == null)
            {
                defaultStudent = students.First();
            }
            foreach (var seats in seatingChartInfo.SeatingList)
            {
                foreach (var seatInfo in seats)
                {
                    var seat = new Seat();
                    if (seatInfo.StudentId.HasValue)
                    {
                        seat.Column    = seatInfo.Column;
                        seat.Row       = seatInfo.Row;
                        seat.StudentId = seatInfo.StudentId.Value;
                    }
                    else
                    {
                        seat.StudentId = defaultStudent.Id;
                    }
                    stiSeats.Add(seat);
                }
            }
            seatingChart.Seats = stiSeats;
            SeatingChartStorage.UpdateChart(classId, markingPeriodId, seatingChart);
        }
        public SeatingChartInfo GetSeatingChart(int classId, int markingPeriodId)
        {
            var seatingChart = SeatingChartStorage.GetChart(classId, markingPeriodId);

            return(SeatingChartInfo.Create(seatingChart));
        }