Esempio n. 1
0
        /// <summary>
        /// Gets the address and about details for the mentor
        /// </summary>
        /// <param name="MentorID"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnGetAsync(int?MentorID)
        {
            //Gets mentor profile based on the username
            var user = await _context.GetMentorAsync(this.Username);

            //checks to see if user is null
            if (user == null)
            {
                return(Redirect("/Error"));
            }

            var Mentor = user.Mentor;

            //checks to see if mentor is null
            if (Mentor == null)
            {
                return(Redirect("/Error"));
            }

            //sets the address model to the mentor address
            Address = Mentor.Address;

            //sets the about model to the mentor about
            About = Mentor.About;

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

            var courseID = id.GetValueOrDefault();

            Course = await _context.GetCourseAsync(courseID);

            var appUser = await _context.GetMentorAsync(Username);

            var mentor = appUser.Mentor;

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

            if (Course == null || mentor == null)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }
            else if (Course.Pair.MentorID != mentor.ID)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }

            else
            {
                return(Page());
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var user = await _context.GetMentorAsync(this.Username);

            var mentor = user.Mentor;

            if (mentor == null)
            {
                return(NotFound($"Unable to load user with ID '{Username}'."));
            }


            if (mentor.Address != null)
            {
                return(Redirect("/Error"));
            }

            await _context.UpdateMentor(mentor, AddressMentor);

            return(Redirect("./Certificates"));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("/Error"));
            }

            var user = await _context.GetMentorAsync(this.Username);

            if (user.Mentor == null)
            {
                return(NotFound($"Unable to load user with ID '{Username}'."));
            }

            if (user.Mentor.StrategicDomains == null)
            {
                user.Mentor.StrategicDomains = new List <StrategicDomain>();
            }

            await _context.UpdateMentor(user.Mentor, this.StrategicDomain);

            this.SuccessfullyCreated = true;

            return(RedirectToPage());
        }
Esempio n. 5
0
        /// <summary>
        /// Adds strategic domains to the User's mentor profile
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync()
        {
            //checks to see if model state is valid
            if (!ModelState.IsValid)
            {
                return(Redirect("/Error"));
            }

            //gets the users mentor profile based on the username
            var user = await _context.GetMentorAsync(this.Username);

            //checks to see if the mentor is null
            if (user.Mentor == null)
            {
                return(NotFound($"Unable to load user with ID '{Username}'."));
            }

            //checks to see mentors strategic domains is null if so creates a new list
            if (user.Mentor.StrategicDomains == null)
            {
                user.Mentor.StrategicDomains = new List <StrategicDomain>();
            }

            //Adds the strategic domains to the mentor profile
            await _context.UpdateMentor(user.Mentor, this.StrategicDomain);

            this.SuccessfullyCreated = true;

            return(RedirectToPage());
        }
Esempio n. 6
0
        public async Task <IActionResult> OnGetAsync()
        {
            var mentor = await _context.GetMentorAsync(this.Username);

            if (mentor?.Mentor == null)
            {
                return(Redirect("/Error"));
            }

            var pairs = await _context.GetPairsForMentorAsync(mentor.Mentor.ID);

            this.Display = new List <DisplayModel>();
            foreach (var pair in pairs)
            {
                var display = new DisplayModel
                {
                    ClientUserName  = pair.Client?.AppUser?.UserName ?? "",
                    DateCreated     = pair.DateCreated.ToShortDateString(),
                    JoinCode        = pair.JoinCode,
                    PairID          = pair.PairID,
                    ProtegeUserName = pair.Protege?.AppUser?.UserName ?? ""
                };

                this.Display.Add(display);
            }

            return(Page());
        }
Esempio n. 7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // Get the Mentor
            var mentor = await _context.GetMentorAsync(this.Username);

            // Add the pairing to the mentor
            var mentorId = mentor.Mentor.ID;
            var joinCode = Guid.NewGuid().ToString();
            var addDate  = DateTime.Now;

            var pair = new Pair
            {
                DateCreated = addDate,
                MentorID    = mentorId,
                Mentor      = mentor.Mentor,
                JoinCode    = joinCode
            };

            await _context.AddPairAsync(pair);


            var message = "Welcome to the Mentor Protege Program powered by Esolvit Government Solutions. Please use the Code Below to join!: " + joinCode;
            var subject = "Join Mentor-Protege Program.";

            try
            {
                await _emailSender.SendEmailAsync(Input.ProtegeEmailAddress, subject, message);

                await _emailSender.SendEmailAsync(Input.ClientEmailAddress, subject, message);
            }
            catch (Exception)
            {
            }


            var mentorRole        = new IdentityRole("Mentor-" + joinCode);
            var mentorRoleSuccess = await _roleManager.CreateAsync(mentorRole);

            if (mentorRoleSuccess.Succeeded)
            {
                await _userManager.AddToRoleAsync(mentor, mentorRole.Name);
            }

            else
            {
                return(RedirectToPage("/Error"));
            }


            return(RedirectToPage("/Mentor/Pairing/Index"));
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the certificate to the User's mentor profile
        /// </summary>
        /// <returns>
        ///
        /// </returns>
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("/Error"));
            }

            var user = await _context.GetMentorAsync(this.Username);

            if (user.Mentor == null)
            {
                return(NotFound($"Unable to load user with ID '{Username}'."));
            }

            await _context.UpdateMentor(user.Mentor, Certificate);

            this.SuccessCreated = "Successfully Created a Certificate";

            return(RedirectToPage());
        }
Esempio n. 9
0
        /// <summary>
        /// Adds the certificate to the User's mentor profile
        /// </summary>
        /// <returns>
        ///
        /// </returns>
        public async Task <IActionResult> OnPostAsync()
        {
            //Checks to see if model state is valid
            if (!ModelState.IsValid)
            {
                return(Redirect("/Error"));
            }

            //Gets the user mentor profile based on the username
            var user = await _context.GetMentorAsync(this.Username);

            //checks to see if user mentor section is null
            if (user.Mentor == null)
            {
                return(NotFound($"Unable to load user with ID '{Username}'."));
            }

            //Adds the certificate to the mentor profile
            await _context.UpdateMentor(user.Mentor, Certificate);

            this.SuccessCreated = "Successfully Created a Certificate";

            return(RedirectToPage());
        }