Beispiel #1
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"));
        }
Beispiel #2
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"));
        }
Beispiel #3
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"));
        }
Beispiel #4
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") }));
        }