/// <summary> /// /// </summary> /// <returns></returns> public ActionResult OfficeHour(Guid?id) { var semester = SemesterService.GetSemester(id); var member = GetMyMembership(); var officeHour = Db.Activities.OfType <OfficeHour>().FirstOrDefault(x => x.Semester.Id == semester.Id && x.Owners.Any(y => y.Member.Id == member.Id)); var infoService = new OfficeHourInfoService(UserManager); if (officeHour == null) { return(RedirectToAction("Create", "OfficeHour", new { id = semester.Id })); } var model = new OfficeHourSubscriptionViewModel { OfficeHour = officeHour, Semester = semester, Host = infoService.GetHost(officeHour), }; if (officeHour.ByAgreement) { return(View("DateListAgreement", model)); } model.Dates.AddRange(infoService.GetDates(officeHour)); return(View("DateList", model)); }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult OfficeHour(Guid?id) { var user = GetCurrentUser(); var infoService = new OfficeHourInfoService(UserManager); if (id == null) { var summaryModel = new LecturerSummaryModel() { Memberships = MemberService.GetFacultyMemberships(user.Id) }; var officeHours = Db.Activities.OfType <OfficeHour>().Where(x => x.Owners.Any(o => !string.IsNullOrEmpty(o.Member.UserId) && o.Member.UserId.Equals(user.Id))) .ToList(); foreach (var oh in officeHours) { var ohModel = new LecturerOfficehourSummaryModel() { OfficeHour = oh }; summaryModel.OfficeHours.Add(ohModel); } var semester = SemesterService.GetSemester(DateTime.Today); ViewBag.ThisSemester = semester; ViewBag.NextSemester = SemesterService.GetNextSemester(semester); return(View(summaryModel)); } var officeHour = Db.Activities.OfType <OfficeHour>().SingleOrDefault(x => x.Id == id.Value); var model = new OfficeHourSubscriptionViewModel { OfficeHour = officeHour, Semester = officeHour.Semester, Host = infoService.GetHost(officeHour), }; if (officeHour.ByAgreement) { return(View("DateListAgreement", model)); } model.Dates.AddRange(infoService.GetDates(officeHour)); return(View("DateList", model)); }