Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Subscribe(Guid id)
        {
            var semester = SemesterService.GetSemester(id);

            var semSubService = new SemesterSubscriptionService(Db);

            // Liegt eine Einschreibung vor?
            var semGroup = semSubService.GetSemesterGroup(AppUser.Id, semester);

            SemesterSubscriptionViewModel model;

            if (semGroup == null)
            {
                model = GetModel(semester);
            }
            else
            {
                model = new SemesterSubscriptionViewModel
                {
                    Group    = semGroup,
                    Semester = semester.Id.ToString()
                };
            }

            ViewBag.Semester = semester;

            return(View("Semester", model));
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            // Alle Semester mit Stundenplänen, die in der Zukunft enden
            var semesterList = Db.Semesters.Where(x =>
                                                  x.EndCourses >= DateTime.Today &&
                                                  x.Groups.Any(g => g.IsAvailable)).ToList();

            var semSubService = new SemesterSubscriptionService(Db);

            var model = new List <SemesterSubscriptionOverviewModel>();

            foreach (var semester in semesterList)
            {
                var semGroup = semSubService.GetSemesterGroup(AppUser.Id, semester);

                var m = new SemesterSubscriptionOverviewModel
                {
                    Semester = semester,
                    Group    = semGroup
                };

                model.Add(m);
            }


            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Change()
        {
            var semester = SemesterService.GetSemester(DateTime.Today);
            var user     = GetCurrentUser();

            var semSubService        = new SemesterSubscriptionService();
            var semesterSubscription = semSubService.GetSemesterGroup(user.Id, semester);

            var model = new CurriculumSubscriptionViewModel
            {
                OrgId  = semesterSubscription?.CapacityGroup.CurriculumGroup.Curriculum.Organiser.Id ?? Guid.Empty,
                CurrId = semesterSubscription?.CapacityGroup.CurriculumGroup.Curriculum.Id ?? Guid.Empty,
                SemId  = semester.Id
            };

            var orgs = Db.Organisers.Where(x => x.IsFaculty && x.Curricula.Any()).OrderBy(f => f.ShortName).ToList();
            var org  = semesterSubscription?.CapacityGroup.CurriculumGroup.Curriculum.Organiser ?? orgs.FirstOrDefault();

            ViewBag.Faculties = orgs.Select(f => new SelectListItem
            {
                Text  = f.ShortName,
                Value = f.Id.ToString(),
            });


            ViewBag.Curricula = org.Curricula.OrderBy(f => f.ShortName).Select(f => new SelectListItem
            {
                Text  = f.Name,
                Value = f.Id.ToString(),
            });

            var nextDate = DateTime.Today.AddDays(70);

            ViewBag.Semesters = Db.Semesters.Where(x => x.StartCourses <= nextDate).OrderByDescending(x => x.EndCourses)
                                .Select(f => new SelectListItem
            {
                Text  = f.Name,
                Value = f.Id.ToString(),
            }
                                        );


            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Schedule(Guid id)
        {
            var userRight = GetUserRight();

            ViewBag.UserRight = userRight;

            var semSubService = new SemesterSubscriptionService();

            var user = AppUser;

            // das übergebene Semester
            var currentSemester = SemesterService.GetSemester(id);

            var model = new DashboardStudentViewModel();

            model.User      = user;
            model.Organiser = GetMyOrganisation();

            model.Semester      = currentSemester;
            model.SemesterGroup = semSubService.GetSemesterGroup(user.Id, currentSemester);

            return(View(model));
        }
Exemplo n.º 5
0
        private DashboardStudentViewModel CreateDashboardModelStudent(UserRight userRight)
        {
            var semSubService = new SemesterSubscriptionService();

            var currentSemester = SemesterService.GetSemester(DateTime.Today);
            var nextSemester    = SemesterService.GetNextSemester(DateTime.Today);

            var model = new DashboardStudentViewModel
            {
                User          = userRight.User,
                Semester      = currentSemester,
                SemesterGroup = semSubService.GetSemesterGroup(userRight.User.Id, currentSemester),
                Student       = Db.Students.Where(x => x.UserId.Equals(userRight.User.Id)).OrderByDescending(x => x.Created).FirstOrDefault()
            };

            // keine Semestergruppe gewählt => aktive Pläne suchen
            if (model.SemesterGroup == null)
            {
                model.ActiveOrgsSemester = SemesterService.GetActiveOrganiser(currentSemester, true);
            }


            // das nächste Semester nur anzeigen, wenn es einen veröffentlichsten Stundenplan für die letzte Fakultät gibt!
            var nextSemesterOrgs = SemesterService.GetActiveOrganiser(nextSemester, true);

            if (nextSemesterOrgs.Any())
            {
                model.NextSemester      = nextSemester;
                model.NextSemesterGroup = semSubService.GetSemesterGroup(userRight.User.Id, nextSemester);
                if (model.NextSemesterGroup == null)
                {
                    model.ActiveOrgsNextSemester = nextSemesterOrgs;
                }
            }



            // Alle Anfragen zu Abschlussarbeiten
            var supervisions = Db.Activities.OfType <Supervision>()
                               .Where(x => x.Occurrence.Subscriptions.Any(y => y.UserId.Equals(userRight.User.Id))).ToList();

            foreach (var supervision in supervisions)
            {
                var request = new SupervisionRequestModel();

                request.Supervision  = supervision;
                request.Lecturer     = supervision.Owners.First().Member;
                request.Subscription =
                    supervision.Occurrence.Subscriptions.FirstOrDefault(x => x.UserId.Equals(userRight.User.Id));

                model.Requests.Add(request);
            }

            // Alle Abschlussarbeiten
            var theses = Db.Theses.Where(x => x.Student.UserId.Equals(userRight.User.Id)).ToList();

            foreach (var thesis in theses)
            {
                var tModel = new ThesisDetailModel();

                tModel.Thesis   = thesis;
                tModel.Lecturer = thesis.Supervision.Owners.First().Member;

                model.Theses.Add(tModel);
            }

            // Alle heutigen Termine
            // Alle Eintragungen
            var begin = DateTime.Now;
            var end   = DateTime.Today.AddDays(1);

            var allDates =
                Db.ActivityDates.Where(d =>
                                       (d.Activity.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userRight.User.Id)) ||
                                        d.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userRight.User.Id)) ||
                                        d.Slots.Any(slot => slot.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userRight.User.Id)))) &&
                                       d.End >= begin && d.End <= end).OrderBy(d => d.Begin).ToList();

            foreach (var date in allDates)
            {
                var act = new AgendaActivityViewModel
                {
                    Date = date,
                    Slot = date.Slots.FirstOrDefault(x => x.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userRight.User.Id)))
                };

                model.TodaysActivities.Add(act);
            }

            if (model.Student != null)
            {
                var org = model.Student.Curriculum.Organiser;


                // Alle Platzverlosungen
                // letzte 90 Tage
                var lastEnd     = DateTime.Today;
                var alLotteries = Db.Lotteries.Where(x =>
                                                     x.IsActiveUntil >= lastEnd && x.IsAvailable &&
                                                     x.Organiser != null && x.Organiser.Id == org.Id).OrderBy(x => x.FirstDrawing).ToList();

                foreach (var lottery in alLotteries)
                {
                    var courseList = new List <Course>();
                    courseList.AddRange(
                        lottery.Occurrences.Select(
                            occurrence => Db.Activities.OfType <Course>().SingleOrDefault(
                                c => c.Occurrence.Id == occurrence.Id)).Where(course => course != null));

                    var hasFit =
                        courseList.Any(c => c.SemesterGroups.Any(g =>
                                                                 g.CapacityGroup.CurriculumGroup.Curriculum.Id == model.Student.Curriculum.Id));

                    if (hasFit)
                    {
                        model.Lotteries.Add(lottery);
                    }
                }
            }


            return(model);
        }