Exemplo n.º 1
0
        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 Details(Guid id)
        {
            var org       = GetMyOrganisation();
            var userRight = GetUserRight(org);

            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            var user    = GetUser(thesis.Student.UserId);
            var student = thesis.Student;
            var member  = GetMyMembership();

            if (member == null)
            {
                return(View("_NoAccess"));
            }

            var model = new ThesisStateModel
            {
                User       = user,
                Student    = student,
                Thesis     = thesis,
                Supervisor = thesis.Supervisors.SingleOrDefault(x => x.Member.Id == member.Id)
            };

            ViewBag.UserRight = userRight;
            ViewBag.Organiser = org;


            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Details(Guid id)
        {
            var org       = GetMyOrganisation();
            var userRight = GetUserRight(org);

            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            var user    = GetUser(thesis.Student.UserId);
            var student = thesis.Student;

            if (user == null)
            {
                user = new ApplicationUser
                {
                    FirstName = "Kein Benutzerkonto"
                };
            }

            var model = new ThesisStateModel
            {
                User    = user,
                Student = student,
                Thesis  = thesis
            };

            ViewBag.UserRight = userRight;
            ViewBag.Organiser = org;


            return(View(model));
        }
Exemplo n.º 4
0
        public PartialViewResult SupervisionState(Guid id)
        {
            var userService = new UserInfoService();

            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            var tm = new ThesisStateModel
            {
                Thesis  = thesis,
                Student = thesis.Student,
                User    = userService.GetUser(thesis.Student.UserId)
            };

            var member = GetMyMembership();

            var model = new SupervisionDetailModel
            {
                Thesis     = tm,
                Supervisor = member
            };

            var didIAccepted = thesis.Supervisors.Any(x => x.Member.Id == member.Id && x.AcceptanceDate.HasValue);

            // Habe noch nicht reagiert
            if (!didIAccepted)
            {
                return(PartialView("_StateRequest", model));
            }

            // ich habe angenommen (sonst taucht es eh nicht auf)
            // aktuell noch unklar
            return(PartialView("_StateUnknown", model));
        }
Exemplo n.º 5
0
        public ActionResult RejectRequest(Guid id)
        {
            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);
            var member = GetMyMembership();
            var user   = GetCurrentUser();

            var supervision = thesis.Supervisors.FirstOrDefault(x => x.Member.Id == member.Id);

            if (supervision != null)
            {
                thesis.Supervisors.Remove(supervision);
                Db.Supervisors.Remove(supervision);

                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.SendSupervisionRequestDeny(tm, member, user);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public ActionResult AcceptRequest(Guid id)
        {
            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);
            var member = GetMyMembership();
            var user   = GetCurrentUser();

            var supervision = thesis.Supervisors.FirstOrDefault(x => x.Member.Id == member.Id);

            supervision.AcceptanceDate = DateTime.Now;
            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.SendSupervisionRequestAccept(tm, member, user);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        // GET: Supervision
        public ActionResult Index()
        {
            var user   = GetCurrentUser();
            var org    = GetMyOrganisation();
            var member = GetMyMembership();

            var userService = new UserInfoService();

            var theses = Db.Theses.Where(x => x.Supervisors.Any(m => m.Member.Id == member.Id)).ToList();

            var model = new SupervisionOverviewModel();

            model.Organiser = org;
            model.Member    = member;


            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Thesis.Add(tm);
            }


            return(View(model));
        }
Exemplo n.º 8
0
        public void SendSupervisionRequest(ThesisStateModel model, OrganiserMember member, ApplicationUser user)
        {
            var email = new ThesisEmail("ThesisSupervisionRequest");

            email.Subject = "Anfrage zur Betreuung einer Abschlussarbeit";
            email.Thesis  = model;
            email.Member  = member;
            email.User    = user;

            SendThesisMail(email);
        }
Exemplo n.º 9
0
        public void SendSupervisionRequestDeny(ThesisStateModel model, OrganiserMember member, ApplicationUser user)
        {
            var email = new ThesisEmail("ThesisMailTemplate");

            email.Subject = "Ihre Anfrage zur Betreuung einer Abschlussarbeit";
            email.Thesis  = model;
            email.Member  = member;
            email.User    = user;
            email.Body    = "<p><strong>Die Betreuung Ihrer Abschlussarbeit wurde abgelehnt.</strong></p>";

            SendThesisMail(email);
        }
Exemplo n.º 10
0
        public void SendConditionRequestAccept(ThesisStateModel model, OrganiserMember member, ApplicationUser user)
        {
            var email = new ThesisEmail("ThesisMailTemplate");

            email.Subject = "Ihr Antrag auf Anmeldung einer Abschlussarbeit";
            email.Thesis  = model;
            email.Member  = member;
            email.User    = user;
            email.Body    = "<p><strong>Antrag wurde angenommen. Die Voraussetzungen für die Abschlussarbeit sind erfüllt.</strong></p>";

            SendThesisMail(email);
        }
Exemplo n.º 11
0
        public ActionResult Index()
        {
            var user    = GetCurrentUser();
            var student = StudentService.GetCurrentStudent(user);
            var thesis  = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id);

            var model = new ThesisStateModel
            {
                User    = user,
                Student = student,
                Thesis  = thesis
            };

            return(View(model));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Anzeige des Annahme / Ablehnungsdialog
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Approval(Guid id)
        {
            var userService = new UserInfoService();
            var thesis      = Db.Theses.SingleOrDefault(x => x.Id == id);

            var model = new ThesisStateModel
            {
                Thesis  = thesis,
                Student = thesis.Student,
                User    = userService.GetUser(thesis.Student.UserId)
            };

            ViewBag.UserRight = GetUserRight();

            return(View(model));
        }
Exemplo n.º 13
0
        public PartialViewResult ThesisState(Guid id)
        {
            var userService = new UserInfoService();

            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            var tm = new ThesisStateModel
            {
                Thesis  = thesis,
                Student = thesis.Student,
                User    = userService.GetUser(thesis.Student.UserId)
            };

            // ----- Prüfung der Voraussetzungen ---
            // Welches Detail anzeigen?
            // Antrag auf Anmeldung noch nicht abgeschlossen
            if (tm.ConditionRequest == RequestState.InProgress ||
                tm.ConditionRequest == RequestState.Rejected)
            {
                return(PartialView("_StateConditionRequest", tm));
            }

            // ---- Suche nach Betreuern ---
            // Keinen Betreuer angefragt / vorhanden
            // noch keine Zusage von Betreuer
            if (tm.SupervisionRequest == RequestState.InProgress ||
                tm.SupervisionRequest == RequestState.Rejected)
            {
                return(PartialView("_StateSupervisionRequest", tm));
            }


            // ---- Arbeit läuft -----
            // --- Antrag auf Verlängerung gestellt ---
            if (tm.ExtensionRequested)  // nur wenn der Antrag läuft
            {
                return(PartialView("_StateExtensionRequest", tm));
            }

            // ---- Erfassung der Abgabe ---
            if (!tm.HasDelivered)
            {
                return(PartialView("_StateInProgress", tm));
            }
            // --- Abgegeben
            return(PartialView("_StateDelivered", tm));
        }
Exemplo n.º 14
0
        public ActionResult Plan(ThesisStateModel model)
        {
            var date = DateTime.Parse(model.IssueDate);

            if (date < DateTime.Today)
            {
                var user    = GetCurrentUser();
                var student = StudentService.GetCurrentStudent(user);
                var thesis2 = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id);

                var model2 = new ThesisStateModel
                {
                    User      = user,
                    Student   = student,
                    Thesis    = thesis2,
                    IssueDate = DateTime.Today.ToShortDateString()
                };

                ModelState.AddModelError("", "Das Datum muss in der Zukunft liegen");

                return(View(model2));
            }


            var thesis = Db.Theses.SingleOrDefault(x => x.Id == model.Thesis.Id);

            int  period  = 0;
            bool success = int.TryParse(thesis.Student.Curriculum.Version, out period);

            if (!success || period == 0)
            {
                period = 3;
            }

            thesis.PlannedBegin   = DateTime.Parse(model.IssueDate);
            thesis.PlannedEnd     = thesis.PlannedBegin.Value.AddMonths(period);
            thesis.LastPlanChange = DateTime.Now;
            ;

            Db.SaveChanges();



            return(RedirectToAction("Index"));
        }
Exemplo n.º 15
0
        public ActionResult Plan()
        {
            var user    = GetCurrentUser();
            var student = StudentService.GetCurrentStudent(user);
            var thesis  = Db.Theses.FirstOrDefault(x => x.Student.Id == student.Id);

            var model = new ThesisStateModel
            {
                User      = user,
                Student   = student,
                Thesis    = thesis,
                IssueDate = DateTime.Today.ToShortDateString()
            };



            return(View(model));
        }
Exemplo n.º 16
0
        public void SendConditionRequestDeny(ThesisStateModel model, OrganiserMember member, ApplicationUser user)
        {
            var email = new ThesisEmail("ThesisMailTemplate");

            email.Subject = "Ihr Antrag auf Anmeldung einer Abschlussarbeit";
            email.Thesis  = model;
            email.Member  = member;
            email.User    = user;

            var sb = new StringBuilder();

            sb.Append(
                "<p><strong>Antrag wurde abgelehnt. Die Voraussetzungen für die Abschlussarbeit sind NICHT erfüllt.</strong></p>");
            sb.AppendFormat("<p>Begründung:</p><p>{0}</p>", model.Thesis.RequestMessage);

            email.Body = sb.ToString();

            SendThesisMail(email);
        }
Exemplo n.º 17
0
        public ActionResult Marking(Guid id)
        {
            var userService = new UserInfoService();
            var user        = GetCurrentUser();

            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            // Mail mit Notenbeleg zum Ausdrucken an sich selbst senden
            var tm = new ThesisStateModel()
            {
                Thesis  = thesis,
                Student = thesis.Student,
                User    = userService.GetUser(thesis.Student.UserId),
                Mark    = ""
            };


            // hier zunächst mit Postal - weil es so geht
            var stream = new MemoryStream();

            var email = new ThesisEmail("ThesisMarked");

            email.To       = user.Email;
            email.From     = MailController.InitSystemFrom();
            email.Subject  = "Notenmeldung Abschlussarbeit";
            email.Thesis   = tm;
            email.Receiver = user;


            var         html = this.RenderViewToString("_ThesisPrintOut", email);
            PdfDocument pdf  = PdfGenerator.GeneratePdf(html, PageSize.A4);

            //pdf.Save("document.pdf");
            pdf.Save(stream, false);

            // Stream zurücksetzen
            stream.Position = 0;
            email.Attach(new Attachment(stream, "Notenmeldung.pdf", System.Net.Mime.MediaTypeNames.Application.Pdf));
            email.Send();


            return(RedirectToAction("Details", new { id = thesis.Id }));
        }
Exemplo n.º 18
0
        // GET: Supervision
        public ActionResult Index()
        {
            var user   = GetCurrentUser();
            var org    = GetMyOrganisation();
            var member = GetMyMembership();

            if (member == null)
            {
                return(View("_NoAccess"));
            }

            var userService = new UserInfoService();


            var theses = Db.Theses.Where(x =>
                                         x.Supervisors.Any(m => m.Member.Id == member.Id) && // Alle Abschlussarbeiten für den Betreuer
                                         x.IsCleared == null || x.IsCleared.Value == false   // noch nicht abgerechnet
                                         ).ToList();


            var model = new SupervisionOverviewModel();

            model.Organiser = org;
            model.Member    = member;


            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Thesis.Add(tm);
            }


            return(View(model));
        }
Exemplo n.º 19
0
        /*
         * public ActionResult Requests()
         * {
         *  var user = GetCurrentUser();
         *  var org = GetMyOrganisation();
         *  var member = GetMyMembership();
         *
         *  var userService = new UserInfoService();
         *
         *
         *  var theses = Db.Theses.Where(x =>
         *          x.Supervisors.Any(m => m.Member.Id == member.Id) && // Alle Abschlussarbeiten für den Betreuer
         *          x.DeliveryDate == null   // noch nich abgegeben
         *  ).ToList();
         *
         *
         *  var model = new SupervisionOverviewModel();
         *  model.Organiser = org;
         *  model.Member = member;
         *
         *
         *  foreach (var thesis in theses)
         *  {
         *      var tm = new ThesisStateModel
         *      {
         *          Thesis = thesis,
         *          Student = thesis.Student,
         *          User = userService.GetUser(thesis.Student.UserId)
         *      };
         *
         *      model.Thesis.Add(tm);
         *  }
         *
         *
         *  return View(model);
         * }
         */

        public ActionResult Cleared()
        {
            var user   = GetCurrentUser();
            var org    = GetMyOrganisation();
            var member = GetMyMembership();

            if (member == null)
            {
                return(View("_NoAccess"));
            }

            var userService = new UserInfoService();


            var theses = Db.Theses.Where(x =>
                                         x.Supervisors.Any(m => m.Member.Id == member.Id) && // Alle Abschlussarbeiten für den Betreuer
                                         x.DeliveryDate != null &&                           // abgegeben
                                         x.IsCleared != null && x.IsCleared == true          // archiviert / abgerechnet
                                         ).ToList();


            var model = new SupervisionOverviewModel {
                Organiser = org, Member = member
            };


            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Thesis.Add(tm);
            }


            return(View(model));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Angekündigt
        /// Alle Arbeiten, bei denen das Prüfungsamt noch nicht draufgesehen hat
        /// oder draufgesehen hat, aber die Voraussetzungen nicht erfüllt sind
        /// </summary>
        /// <returns></returns>
        public ActionResult Announced()
        {
            var org       = GetMyOrganisation();
            var userRight = GetUserRight(org);

            if (!userRight.IsExamAdmin)
            {
                return(View("_NoAccess"));
            }

            var userService = new UserInfoService();

            var theses = Db.Theses.Where(x =>
                                         x.Student.Curriculum.Organiser.Id == org.Id &&                                     // Student zur Fakultät gehörend
                                         x.IssueDate == null &&                                                             // noch nicht angemeldet
                                         ((x.RequestAuthority == null) ||                                                   // PA hat das noch nicht gesehen
                                          (x.RequestAuthority != null && x.IsPassed.HasValue && x.IsPassed.Value == false)) // Voraussetzungen nicht erfüllt
                                         ).ToList();

            var model = new List <ThesisStateModel>();

            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Add(tm);
            }

            ViewBag.UserRight = userRight;
            ViewBag.Organiser = org;


            return(View(model));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Absolventen, sind alle mit abegebener Arbeit
        /// </summary>
        /// <returns></returns>
        public ActionResult Done()
        {
            var org       = GetMyOrganisation();
            var userRight = GetUserRight(org);

            if (!userRight.IsExamAdmin)
            {
                return(View("_NoAccess"));
            }

            var userService = new UserInfoService();

            var theses = Db.Theses.Where(x =>
                                         x.Student.Curriculum.Organiser.Id == org.Id && // Student zur Fakultät gehörend
                                         x.IsCleared == null &&                         // noch nicht archiviert
                                         x.GradeDate == null &&                         // noch keine Note gemeldet
                                         x.DeliveryDate != null                         // abgegeben haben
                                         ).ToList();

            var model = new List <ThesisStateModel>();

            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Add(tm);
            }

            ViewBag.UserRight = userRight;
            ViewBag.Organiser = org;


            return(View(model));
        }
Exemplo n.º 22
0
        public ActionResult Archived()
        {
            var org       = GetMyOrganisation();
            var userRight = GetUserRight(org);

            if (!userRight.IsExamAdmin)
            {
                return(View("NoAccess"));
            }

            var userService = new UserInfoService();

            var theses = Db.Theses.Where(x =>
                                         x.Student.Curriculum.Organiser.Id == org.Id && // Student zur Fakultät gehörend
                                         x.IsCleared != null && x.IsCleared == true     // archiviert
                                         ).ToList();

            var model = new List <ThesisStateModel>();

            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Add(tm);
            }

            ViewBag.UserRight = userRight;
            ViewBag.Organiser = org;


            return(View(model));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Der Status meiner Abschlussarbeit
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var userService = new UserInfoService();
            // der aktuelle Benutzer
            var org = GetMyOrganisation();

            var userRight = GetUserRight(org);

            var theses = Db.Theses.Where(x =>
                                         x.Student.Curriculum.Organiser.Id == org.Id).ToList();

            if (!userRight.IsExamAdmin)
            {
                return(View("NoAccess"));
            }


            var model = new List <ThesisStateModel>();

            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.Add(tm);
            }


            ViewBag.UserRight = userRight;

            return(View(model));
        }
Exemplo n.º 24
0
        // GET: Teaching
        public ActionResult Index(Guid?id)
        {
            var user    = GetCurrentUser();
            var members = MemberService.GetFacultyMemberships(user.Id);

            if (!members.Any())
            {
                return(RedirectToAction("Apply"));
            }

            Semester currentSemester = null;

            if (id == null)
            {
                // das aktuelle Semester bestimmen es gilt das neues aller Semester in alle
                // Fakultäen
                var semesterToday = SemesterService.GetSemester(DateTime.Today);
                var mySemester    = semesterToday;
                foreach (var organiserMember in members)
                {
                    var latestSemester = SemesterService.GetLatestSemester(organiserMember.Organiser);

                    if (latestSemester.StartCourses > semesterToday.StartCourses)
                    {
                        mySemester = latestSemester;
                    }
                }

                // gegencheck: wenn ich noch termine im aktuellen Semester habe, dann nimm das
                if (mySemester != semesterToday)
                {
                }


                currentSemester = mySemester;
            }
            else
            {
                currentSemester = SemesterService.GetSemester(id);
            }

            var TeachingService = new TeachingService(Db);
            var userService     = new UserInfoService();

            var model = new TeachingOverviewModel();

            model.CurrentSemester = TeachingService.GetActivities(currentSemester, user, members);
            model.PrevSemester    = SemesterService.GetPreviousSemester(currentSemester);
            model.NextSemester    = SemesterService.GetNextSemester(currentSemester);
            model.Members         = members.ToList();


            // Abschlussarbeiten
            model.ActiveTheses = new List <ThesisStateModel>();

            var theses = TeachingService.GetActiveTheses(user);

            foreach (var thesis in theses)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                model.ActiveTheses.Add(tm);
            }


            return(View(model));
        }
Exemplo n.º 25
0
        public ActionResult RequestSupervision(Guid id, string Name, string ShortName, string Date, Guid[] DozIds)
        {
            var thesis = Db.Theses.SingleOrDefault(x => x.Id == id);

            if (thesis == null || string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Date) || DozIds == null || !DozIds.Any())
            {
                return(Json(new { result = "Redirect", url = Url.Action("RequestIncomplete") }));
            }



            thesis.TitleDe        = Name;
            thesis.AbstractDe     = ShortName;
            thesis.AcceptanceDate = DateTime.Now;

            var issueDate = DateTime.Today;

            if (!string.IsNullOrEmpty(Date))
            {
                issueDate = DateTime.Parse(Date);
            }
            if (issueDate < DateTime.Today)
            {
                issueDate = DateTime.Today;
            }

            thesis.IssueDate      = issueDate;
            thesis.ExpirationDate = issueDate.AddMonths(6).AddDays(-1);

            foreach (var dozId in DozIds)
            {
                var member = Db.Members.SingleOrDefault(x => x.Id == dozId);

                if (member != null && thesis.Supervisors.All(x => x.Member.Id != member.Id))
                {
                    var supervisor = new Supervisor
                    {
                        Thesis = thesis,
                        Member = member
                    };
                    thesis.Supervisors.Add(supervisor);
                    Db.Supervisors.Add(supervisor);
                }
            }

            Db.SaveChanges();

            var mailService = new ThesisMailService();
            var userService = new UserInfoService();

            foreach (var supervisor in thesis.Supervisors)
            {
                var tm = new ThesisStateModel
                {
                    Thesis  = thesis,
                    Student = thesis.Student,
                    User    = userService.GetUser(thesis.Student.UserId)
                };

                var user = userService.GetUser(supervisor.Member.UserId);

                if (user != null)
                {
                    mailService.SendSupervisionRequest(tm, supervisor.Member, user);
                }
            }


            return(Json(new { result = "Redirect", url = Url.Action("MyWork") }));
        }