Exemplo n.º 1
0
        public async Task <IActionResult> OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SessionID = id.GetValueOrDefault();

            var session = await _context.GetSessionAsync(SessionID);

            if (session == null)
            {
                return(NotFound());
            }

            await CheckRole(_context, _userManager, session.Course.Pair.JoinCode);

            if (!IsProtege)
            {
                return(RedirectToPage("/Identity/Account/AccessDenied"));
            }

            return(Page());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?sessionID)
        {
            if (sessionID == null)
            {
                return(NotFound());
            }

            SessionID = sessionID.GetValueOrDefault();

            Session = await _context.GetSessionAsync(SessionID);

            if (Session == null)
            {
                return(NotFound());
            }

            await CheckRole(_context, _userManager, Session.Course.Pair.JoinCode);

            if (!IsMentor)
            {
                return(new ForbidResult());
            }

            return(Page());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an assignment, sends an email to the protege
        /// </summary>
        /// <returns>The post async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Assignment.SessionID = SessionID;
            var session = await _context.GetSessionAsync(SessionID);

            Assignment.Session = session;

            var success = await _context.AddAssingmentAsync(Assignment);

            var subject = session.Course.CourseName + " New Assigment Created";
            var message = $"<h1>Hello!</h1> <p>A new assigment: {Assignment.Title} was just created<p/>.<br/><p>Due Date: {Assignment.DueDate}</p> <br/> <p>Description: {Assignment.Description}</p>";

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


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

                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

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

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

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

            return(RedirectToPage("/Error"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var sessionID = id.GetValueOrDefault();

            Session = await _context.GetSessionAsync(sessionID);

            if (Session == null)
            {
                return(NotFound());
            }

            var joinCode = Session.Course.Pair.JoinCode;

            await CheckRole(_context, _userManager, joinCode);

            return(Page());
        }