public ActionResult Check() { var user = GetCurrentUser(); var student = StudentService.GetCurrentStudent(user); var thesis = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id); // Eine evtl. vorhandene alte Anfrage löschen if (thesis?.RequestAuthority != null) { thesis.ResponseDate = null; thesis.IsPassed = null; thesis.RequestAuthority = null; Db.SaveChanges(); } var model = new ThesisDetailModel { User = user, Student = student, Thesis = thesis }; return(View(model)); }
public ActionResult Request(ThesisDetailModel model) { var user = GetCurrentUser(); var student = StudentService.GetCurrentStudent(user); var thesis = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id); if (student != null && !string.IsNullOrEmpty(model.Student.Number)) { student.Number = model.Student.Number; } if (thesis == null) { thesis = new Thesis { Student = student, RequestDate = DateTime.Now, }; Db.Theses.Add(thesis); } Db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Check(ThesisDetailModel model) { var user = GetCurrentUser(); var student = StudentService.GetCurrentStudent(user); var thesis = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id); if (thesis == null) { thesis = new Thesis { Student = student, RequestDate = DateTime.Now, }; Db.Theses.Add(thesis); } // die eigene Bestätigung thesis.ResponseDate = DateTime.Now; thesis.IsPassed = true; thesis.RequestAuthority = null; Db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Approve(ThesisDetailModel model) { var member = GetMyMembership(); var user = GetCurrentUser(); var thesis = Db.Theses.SingleOrDefault(x => x.Id == model.Thesis.Id); thesis.ResponseDate = DateTime.Now; thesis.IsPassed = true; thesis.RequestAuthority = member; Db.SaveChanges(); // TODO: E-Mail versenden var userService = new UserInfoService(); var tm = new ThesisStateModel { Thesis = thesis, Student = thesis.Student, User = userService.GetUser(thesis.Student.UserId) }; var mailService = new ThesisMailService(); mailService.SendConditionRequestAccept(tm, member, user); return(RedirectToAction("Index")); }
public ActionResult Deny(Guid id) { var userService = new UserInfoService(); var thesis = Db.Theses.SingleOrDefault(x => x.Id == id); var model = new ThesisDetailModel { Thesis = thesis, Student = thesis.Student, User = userService.GetUser(thesis.Student.UserId) }; ViewBag.UserRight = GetUserRight(); return(View(model)); }
public ActionResult Approve(ThesisDetailModel model) { var member = GetMyMembership(); var user = GetCurrentUser(); var thesis = Db.Theses.SingleOrDefault(x => x.Id == model.Thesis.Id); thesis.ResponseDate = DateTime.Now; thesis.IsPassed = true; thesis.RequestAuthority = member; Db.SaveChanges(); var tm = InitMailModel(thesis, user); new MailController().ThesisConditionCheckResponseEMail(tm).Deliver(); return(RedirectToAction("Announced")); }
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); }