Exemplo n.º 1
0
        public ActionResult Semester(string publicDivisionAlias, int studentGroupId, int?autumn)
        {
            var studentGroup   = studentGroupRepository.GetStudentGroupById(studentGroupId);
            var publicDivision = publicDivisionRepository.GetPublicDivisionByAlias(publicDivisionAlias);

            if (studentGroup != null)
            {
                var viewModel = StudentGroupEventsSemesterViewModel.Build(studentGroup, publicDivision, autumn);

                return(View(viewModel.ViewName, viewModel));
            }
            return(View());
        }
Exemplo n.º 2
0
        public FileStreamResult ExcelSemester(string publicDivisionAlias, int studentGroupId, int?autumn)
        {
            var studentGroup   = studentGroupRepository.GetStudentGroupById(studentGroupId);
            var publicDivision = publicDivisionRepository.GetPublicDivisionByAlias(publicDivisionAlias);

            if (studentGroup != null)
            {
                var viewModel = StudentGroupEventsSemesterViewModel.Build(studentGroup, publicDivision, autumn);
                return(File(
                           GetXmlContentAsStream(studentGroup, viewModel),
                           "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                           $"расписание {studentGroup.Name} {(viewModel.IsSpringSemester ? "весенний": "осенний")} семестр {studentGroup.CurrentStudyYear.DisplayName}.xlsx"));
            }
            return(null);
        }
Exemplo n.º 3
0
        private Stream GetXmlContentAsStream(StudentGroup studentGroup, StudentGroupEventsSemesterViewModel viewModel)
        {
            var aggregatedEventDayModels = viewModel.Days.Select(day =>
                                                                 new AggregatedEventDayModel(day.DayString, day.DayStudyEvents.Select(aggregatedEvent =>
                                                                                                                                      new AggregatedEventModel(
                                                                                                                                          aggregatedEvent.DateTime.Time.Value,
                                                                                                                                          string.Join("\n", aggregatedEvent.DateTime.Dates.Select(d => d.Value)),
                                                                                                                                          aggregatedEvent.Subject,
                                                                                                                                          aggregatedEvent.Cohort,
                                                                                                                                          aggregatedEvent.ShowCohort,
                                                                                                                                          string.Join("\n", aggregatedEvent.EventLocations.Select(el => el.DisplayName)),
                                                                                                                                          string.Join("\n", aggregatedEvent.EventLocations.Select(el => string.Join("; ", el.Educators.Select(e => e.Name)))),
                                                                                                                                          null))));
            var stream = AppointmentsSpreadsheetsHelper.GetStudentGroupSemesterTimetableWorkbookStream(studentGroup.TermStart, studentGroup.TermEnd,
                                                                                                       $"{studentGroup.Name}", aggregatedEventDayModels);

            return(stream);
        }