Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            // Get the Assingment
            AssignmentID = Assignment.AssignmentID;
            var assignment = await _context.GetAssignmentAsync(Assignment.AssignmentID);

            var document = new Document
            {
                AssignmentID = Assignment.AssignmentID,
                Assignment   = assignment
            };

            document = await
                       MemoryStreamExtention.FileToDocumentAsync(FileUpload, document);

            var documentSuccess = await _context.AddDocumentAsync(document);

            var assignmentSuccess = true;

            if (assignment.DateCompleted == new DateTime())
            {
                assignment.DateCompleted = DateTime.Now;
                assignmentSuccess        = await _context.UpdateAssignmentAsync(assignment);
            }

            if (documentSuccess && assignmentSuccess)
            {
                var protege = await _context.GetProtegeByIDAsync(assignment.Session.Course.Pair.ProtegeID);

                var mentor = await _context.GetMentorByIDAsync(assignment.Session.Course.Pair.MentorID);

                var client = await _context.GetClientByIDAsync(assignment.Session.Course.Pair.ClientID);

                var subject = $"{protege?.AppUser?.Email} uploaded Assignment {assignment?.Title}";
                var message = "<h1>Assignment Uploaded</h1>" +
                              $"<p>The Assigment <strong>{assignment.Title}</strong> was submitted by <strong>{protege?.AppUser?.Email}</strong> at <strong>{assignment?.DateCompleted}</strong></p>";

                if (protege != null && mentor != null)
                {
                    await _emailSender.SendEmailAsync(protege.AppUser.Email, subject, message);
                }

                if (mentor != null)
                {
                    await _emailSender.SendEmailAsync(mentor.AppUser.Email, subject, message);
                }

                if (client != null)
                {
                    await _emailSender.SendEmailAsync(client.AppUser.Email, subject, message);
                }

                return(RedirectToPage("./Details", new { id = assignment.AssignmentID }));
            }

            return(RedirectToPage("/Error"));
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var course = await _context.GetCourseAsync(CourseID);

            if (course == null)
            {
                return(RedirectToPage("/Error"));
            }

            Session.CourseID = CourseID;

            var success = await _context.CreateSessionAsync(Session);

            if (success)
            {
                var mentor = await _context.GetMentorByIDAsync(course.Pair.MentorID);

                var client = await _context.GetClientByIDAsync(course.Pair.ClientID);

                var protege = await _context.GetClientByIDAsync(course.Pair.ProtegeID);

                var subject = $"New Session Created for {course.CourseName}";
                var message = "<h1>Session Created</h1>" +
                              $"<p>The Session <strong>{Session.Name}</strong> was created by <strong>{mentor?.AppUser?.Email}</strong> and starts at <strong>{Session.StartDate}</strong></p>";

                if (mentor != null)
                {
                    await _emailSender.SendEmailAsync(mentor.AppUser.Email, subject, message);
                }

                if (protege != null)
                {
                    await _emailSender.SendEmailAsync(protege.AppUser.Email, subject, message);
                }

                if (client != null)
                {
                    await _emailSender.SendEmailAsync(client.AppUser.Email, subject, message);
                }

                return(RedirectToPage("./Details", new { id = Session.SessionID }));
            }
            else
            {
                return(RedirectToPage("/Error"));
            }
        }
Пример #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var course = await _context.GetCourseAsync(CourseID);

            Event.Course   = course;
            Event.CourseID = CourseID;

            var success = await _context.AddEventAsync(Event);

            if (!success)
            {
                return(RedirectToPage("/Error"));
            }

            var mentor = await _context.GetMentorByIDAsync(course.Pair.MentorID);

            var protege = await _context.GetProtegeByIDAsync(course.Pair.ProtegeID);

            var client = await _context.GetClientByIDAsync(course.Pair.ClientID);

            var subject = $"{mentor?.AppUser?.Email} created an Event {Event.EventName}";
            var message = "<h1>Assignment Uploaded</h1>" +
                          $"<p>The Event <strong>{Event.EventName}</strong> was created by <strong>{mentor?.AppUser?.Email}</strong> and starts at <strong>{Event.StartDate}</strong></p>";

            if (mentor != null)
            {
                await _emailSender.SendEmailAsync(mentor.AppUser.Email, subject, message);
            }

            if (protege != null)
            {
                await _emailSender.SendEmailAsync(protege.AppUser.Email, subject, message);
            }

            if (client != null)
            {
                await _emailSender.SendEmailAsync(client.AppUser.Email, subject, message);
            }

            return(RedirectToPage("/Mentor/Course/Index", new { id = course.CourseID }));
        }
Пример #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var session = await _context.GetSessionAsync(SessionID);

            if (session == null)
            {
                return(RedirectToPage("/Error"));
            }

            var fileUpload = new FileUpload
            {
                Category = "Agenda",
                Document = FileUpload
            };

            var document = new Document();

            document = await MemoryStreamExtention.FileToDocumentAsync(fileUpload, document);

            var agenda = new Agenda
            {
                CreationDate = DateTime.Now,
                Name         = Name,
                SessionID    = SessionID,
                Session      = session,
                Document     = document
            };

            var success = await _context.AddAgendaAsync(agenda);

            if (success)
            {
                var protege = await _context.GetProtegeByIDAsync(session.Course.Pair.ProtegeID);

                var mentor = await _context.GetMentorByIDAsync(session.Course.Pair.MentorID);

                var client = await _context.GetClientByIDAsync(session.Course.Pair.ClientID);

                var subject = $"{protege?.AppUser?.Email} uploaded Agenda {agenda.Name}";
                var message = "<h1>Agenda Uploaded</h1>" +
                              $"<p>The Assigment <strong>{agenda.Name}</strong> was submitted by <strong>{protege?.AppUser?.Email}</strong> at <strong>{agenda.CreationDate}</strong></p>";

                if (protege != null)
                {
                    await _emailSender.SendEmailAsync(protege.AppUser.Email, subject, message);
                }
                if (mentor != null)
                {
                    await _emailSender.SendEmailAsync(mentor.AppUser.Email, subject, message);
                }
                if (client != null)
                {
                    await _emailSender.SendEmailAsync(client.AppUser.Email, subject, message);
                }

                return(RedirectToPage("/Sessions/Details", new { id = session.SessionID }));
            }

            return(RedirectToPage("./Index"));
        }