Пример #1
0
        public ActionResult CreateEvent()
        {
            Init(null);
            var sem = SemesterService.GetSemester(DateTime.Today);
            var org = _union;

            CourseCreateModel2 model = new CourseCreateModel2();

            model.SemesterId   = sem.Id;
            model.OrganiserId  = org.Id;
            model.OrganiserId2 = org.Id;
            model.OrganiserId3 = org.Id;

            // Liste aller Fakultäten
            ViewBag.Organiser = Db.Organisers.OrderBy(x => x.ShortName).Select(c => new SelectListItem
            {
                Text  = c.ShortName,
                Value = c.Id.ToString(),
            });

            // Liste aller Fakultäten, auf die Zugriff auf Räume bestehen
            // aktuell nur meine
            ViewBag.RoomOrganiser = Db.Organisers.Where(x => x.Id == org.Id).Select(c => new SelectListItem
            {
                Text  = c.ShortName,
                Value = c.Id.ToString(),
            });


            ViewBag.Semester = Db.Semesters.Where(x => x.EndCourses >= DateTime.Today).OrderBy(s => s.StartCourses).Take(5).Select(c => new SelectListItem
            {
                Text  = c.Name,
                Value = c.Id.ToString(),
            });
            model.SemesterId = sem.Id;

            return(View(model));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateThesis(Guid?id)
        {
            var sem = SemesterService.GetSemester(id);

            var org = GetMyOrganisation();

            CourseCreateModel2 model = new CourseCreateModel2();

            model.SemesterId   = sem.Id;
            model.OrganiserId  = org.Id;
            model.OrganiserId2 = org.Id;
            model.OrganiserId3 = org.Id;

            // Liste aller Fakultäten
            ViewBag.Organiser = Db.Organisers.Select(c => new SelectListItem
            {
                Text  = c.ShortName,
                Value = c.Id.ToString(),
            });

            // Liste aller Fakultäten, auf die Zugriff auf Räume bestehen
            // aktuell nur meine
            ViewBag.RoomOrganiser = Db.Organisers.Where(x => x.Id == org.Id).Select(c => new SelectListItem
            {
                Text  = c.ShortName,
                Value = c.Id.ToString(),
            });

            // Alle Semester, die in Zukunft enden
            ViewBag.Semester = Db.Semesters.Where(x => x.EndCourses >= DateTime.Today).OrderBy(s => s.StartCourses)
                               .Take(5).Select(c => new SelectListItem
            {
                Text  = c.Name,
                Value = c.Id.ToString(),
            });
            model.SemesterId = sem.Id;

            ViewBag.Curricula = null;
            ViewBag.Groups    = null;
            ViewBag.Chapters  = null;
            ViewBag.Topics    = null;



            // bei der ersten Anzeige wird kein onChange ausgelöst
            var currList = Db.Curricula.Where(c => c.Organiser.Id == org.Id).ToList();
            var curr     = currList.FirstOrDefault();

            if (curr != null)
            {
                model.CurriculumId = curr.Id;
                ViewBag.Curricula  = currList.Select(c => new SelectListItem
                {
                    Text  = c.ShortName,
                    Value = c.Id.ToString(),
                });


                // alle Studiengruppen
                var currGroups = curr.CurriculumGroups.ToList();
                var group      = currGroups.FirstOrDefault();
                model.CurrGroupId  = @group?.Id ?? Guid.Empty;
                ViewBag.CurrGroups = currGroups.Select(c => new SelectListItem
                {
                    Text  = c.Name,
                    Value = c.Id.ToString(),
                });

                // alle Kapazitätsgruppen

                if (group != null)
                {
                    var capGroups  = group.CapacityGroups.ToList();
                    var firstGroup = capGroups.FirstOrDefault();
                    model.CapGroupId = firstGroup?.Id ?? Guid.Empty;

                    ViewBag.CapGroups = capGroups.Select(c => new SelectListItem
                    {
                        Text  = c.Name,
                        Value = c.Id.ToString(),
                    });
                }


                var chapters = curr.Chapters.ToList();
                var chapter  = chapters.FirstOrDefault();
                model.ChapterId  = chapter?.Id ?? Guid.Empty;
                ViewBag.Chapters = chapters.Select(c => new SelectListItem
                {
                    Text  = c.Name,
                    Value = c.Id.ToString(),
                });

                if (chapter != null)
                {
                    var topics = chapter.Topics.ToList();
                    var topic  = topics.FirstOrDefault();
                    model.TopicId = topic?.Id ?? Guid.Empty;

                    ViewBag.Topics = topics.Select(c => new SelectListItem
                    {
                        Text  = c.Name,
                        Value = c.Id.ToString(),
                    });
                }
            }


            return(View(model));
        }