示例#1
0
        /// <summary>
        /// Nur Anzeige des Kalenders
        /// </summary>
        /// <returns></returns>
        public ActionResult PersonalPlan()
        {
            var model = new ActivityPlanModel();

            ViewBag.UserRight = GetUserRight();
            return(View(model));
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        public ActionResult PersonalPlanWeekly(Guid id)
        {
            var model = new ActivityPlanModel();

            model.Semester = SemesterService.GetSemester(id);

            return(View(model));
        }
示例#3
0
        public ActionResult PersonalCoursePlan(Guid?id)
        {
            var user     = AppUser;
            var semester = SemesterService.GetSemester(id);
            var org      = GetMyOrganisation();


            var model = new ActivityPlanModel();

            model.Organiser = org;
            model.Semester  = semester;

            // Alle Termine als Teilnehmer

            /*
             * var activities = Db.Activities.Where(a => a.Occurrence.Subscriptions.Any(u => u.UserId.Equals(user.Id))).ToList();
             * foreach (var activity in activities)
             * {
             *  if ((activity.Dates.Any() && activity.Dates.Last().End >= GlobalSettings.Today) ||
             *      !activity.Dates.Any())
             *  {
             *      model.MySubscriptions.Add(new ActivitySubscriptionModel
             *      {
             *          Activity = new ActivitySummary {Activity = activity},
             *          State = ActivityService.GetActivityState(activity.Occurrence, user, semester)
             *      });
             *
             *      if (activity.Occurrence.LotteryEnabled)
             *          model.HasLottery = true;
             *  }
             * }
             *
             * var dates = Db.ActivityDates.Where(d => d.Occurrence.Subscriptions.Any(u => u.UserId.Equals(user.Id))).ToList();
             * foreach (var activityDate in dates)
             * {
             *  if (activityDate.End >= GlobalSettings.Today)
             *  {
             *      model.MySubscriptions.Add(new ActivitySubscriptionModel
             *      {
             *          Activity = new ActivityDateSummary {Date = activityDate},
             *          State = ActivityService.GetActivityState(activityDate.Occurrence, user, semester)
             *      });
             *  }
             * }
             *
             * var slots = Db.ActivitySlots.Where(s => s.Occurrence.Subscriptions.Any(u => u.UserId.Equals(user.Id))).ToList();
             * foreach (var activitySlot in slots)
             * {
             *  if (activitySlot.ActivityDate.End >= GlobalSettings.Today)
             *  {
             *      model.MySubscriptions.Add(new ActivitySubscriptionModel
             *      {
             *          Activity = new ActivitySlotSummary {Slot = activitySlot},
             *          State = ActivityService.GetActivityState(activitySlot.Occurrence, user, semester)
             *      });
             *  }
             * }
             */

            // Alle Termine als Veranstalter im Semester
            var lectureActivities =
                Db.Activities.OfType <Course>().Where(a =>
                                                      a.SemesterGroups.Any(x => x.Semester.Id == semester.Id) &&
                                                      a.Dates.Any(d => d.Hosts.Any(l => !string.IsNullOrEmpty(l.UserId) && l.UserId.Equals(user.Id)))).ToList();

            foreach (var activity in lectureActivities)
            {
                var summary = new ActivitySummary {
                    Activity = activity
                };

                var currentDate =
                    activity.Dates.Where(d => d.Begin <= DateTime.Now && DateTime.Now <= d.End)
                    .OrderBy(d => d.Begin)
                    .FirstOrDefault();
                var nextDate =
                    activity.Dates.Where(d => d.Begin >= DateTime.Now)
                    .OrderBy(d => d.Begin)
                    .FirstOrDefault();

                if (currentDate != null)
                {
                    summary.CurrentDate = new CourseDateStateModel
                    {
                        Summary = new ActivityDateSummary {
                            Date = currentDate
                        },
                        State = ActivityService.GetSubscriptionState(currentDate.Occurrence, currentDate.Begin, currentDate.End),
                    };
                }

                if (nextDate != null)
                {
                    summary.NextDate = new CourseDateStateModel
                    {
                        Summary = new ActivityDateSummary {
                            Date = nextDate
                        },
                        State = ActivityService.GetSubscriptionState(nextDate.Occurrence, nextDate.Begin, nextDate.End),
                    };
                }

                model.MyActivities.Add(summary);
            }

            return(View(model));
        }