Exemple #1
0
        /// <summary>
        /// Gets the Proteges Pairs and shows relevant data pertaining to the pairing.
        /// </summary>
        public async Task <IActionResult> OnGetAsync()
        {
            //Gets the protege account by passing the username to GetProtegeAsync function in the DAL
            var protege = await _context.GetProtegeAsync(Username);

            //Checks to see if user is actually a protege if not then returns error
            if (protege?.Protege == null)
            {
                return(Redirect("/Error"));
            }

            //Gets the pairs relating to the protege based off of the protege ID being passed
            //into the GetPairsForProtege function in the ApplicationDbContext file
            var pairs = await _context.GetPairsForProtege(protege.Protege.ID);

            //stores the displaymodel as a list and puts them in display
            this.Display = new List <DisplayModel>();

            foreach (var pair in pairs)
            {
                //updates the information of the displaymodel by what is stored for the pairs
                var display = new DisplayModel
                {
                    MentorUserName = pair.Mentor?.AppUser?.UserName ?? "",
                    DateCreated    = pair.DateCreated.ToShortDateString(),
                    JoinCode       = pair.JoinCode,
                    PairID         = pair.PairID,
                    ClientUserName = pair.Client?.AppUser?.UserName ?? ""
                };

                this.Display.Add(display);
            }

            return(Page());
        }