public List <ProfileDisplayViewModel> GetProfiles()
        {
            List <Profile> profiles = new List <Profile>();

            profiles = _context.Profiles.AsNoTracking()
                       .Include(x => x.EducationLevel)
                       .Include(x => x.Location)
                       .Include(x => x.School)
                       .ToList();

            if (profiles != null)
            {
                List <ProfileDisplayViewModel> profilesDisplay = new List <ProfileDisplayViewModel>();
                foreach (var x in profiles)
                {
                    var profileDisplay = new ProfileDisplayViewModel()
                    {
                        ProfileId   = x.Id,
                        DateofBirth = x.DateofBirth,
                        Level       = x.EducationLevel.Level,
                        County      = x.Location.County,
                        School      = x.School.Name
                    };
                    profilesDisplay.Add(profileDisplay);
                }
                return(profilesDisplay);
            }
            return(null);
        }
Beispiel #2
0
        public override async Task <IViewProviderResult> BuildDisplayAsync(Profile profile,
                                                                           IViewProviderContext context)
        {
            var user = await _platoUserStore.GetByIdAsync(profile.Id);

            if (user == null)
            {
                return(await BuildIndexAsync(profile, context));
            }

            var badges = await _badgeEntriesStore.SelectByUserIdAsync(user.Id);

            var viewModel = new ProfileDisplayViewModel()
            {
                User   = user,
                Badges = badges
            };

            return(Views(
                       View <ProfileDisplayViewModel>("Profile.Display.Content", model => viewModel).Zone("content").Order(0)
                       ));
        }