Exemple #1
0
        /// <summary>
        /// Gets the pairings associated with the clients and shows the details about them
        /// in the view.
        /// </summary>
        #region Handlers
        public async Task <IActionResult> OnGetAsync()
        {
            //Gets the client account by passing the username to GetClientAsync function in the DAL
            var client = await _context.GetClientAsync(this.Username);

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

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

            //Gets the pairs relating to the client based off of the client ID being passed
            //into the GetClientForProtege function in the ApplicationDbContext file
            var pairs = await _context.GetPairsForClient(client.Client.ID);

            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,
                    ProtegeUserName = pair.Protege?.AppUser?.UserName ?? ""
                };

                this.Display.Add(display);
            }

            return(Page());
        }