Ejemplo n.º 1
0
        public async Task <IActionResult> IndexAsync(long id, string name, CancellationToken token)
        {
            var query  = new UserProfileQuery(id, 0);
            var retVal = await _queryBus.QueryAsync(query, token);

            if (retVal is null)
            {
                return(NotFound());
            }

            if (retVal.Tutor is null)
            {
                Response.Headers.Add("X-Robots-Tag", "noindex");
                return(View("Index"));
            }

            ViewBag.title           = _localizer["TitleNoUniversity", retVal.Name];
            ViewBag.metaDescription = _localizer["Description", retVal.Description];
            if (retVal.Image != null)
            {
                Country country = retVal.Tutor.TutorCountry;

                //ViewBag.ogImage = $"{retVal.Image}?width=1200&height=630";
                ViewBag.ogImage = _urlBuilder.BuildUserImageProfileShareEndpoint(retVal.Id, new
                {
                    width  = 1200,
                    height = 630,
                    rtl    = country.MainLanguage.Info.TextInfo.IsRightToLeft.ToString()
                });
                ViewBag.ogImageWidth  = 1200;
                ViewBag.ogImageHeight = 630;
                ViewBag.ogTitle       = retVal.Name;
                if (retVal.Tutor?.Subjects?.Any() == true)
                {
                    ViewBag.ogDescription =
                        _localizer.WithCulture(country.MainLanguage)["OgDescription",
                                                                     string.Join(", ", retVal.Tutor.Subjects)];
                }
            }

            //var jsonLd = new ProfilePage()
            //{
            //    SourceOrganization = new Organization
            //    {
            //        Logo = new Uri($"{_configuration["site"].TrimEnd('/')}/images/favicons/android-icon-192x192.png"),
            //        Url = Request.GetUri()
            //    },
            //    About = new Person()
            //    {
            //        Name = retVal.Name,
            //        GivenName = retVal.FirstName,
            //        FamilyName = retVal.LastName,
            //        Image = new Uri($"{_configuration["site"].TrimEnd('/')}{retVal.Image}"), // TODO should be fixed
            //        Description = retVal.Description,
            //    },
            //    Url = Request.GetUri()
            //};
            //ViewBag.jsonLd = jsonLd;
            return(View("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Profile(string id)
        {
            var currentUserID = User.GetIdentifier();
            var query         = new UserProfileQuery(currentUserID, id, MaxThumbnailsInUserProfile);
            var model         = await _dispatcher.Send(query);

            return(View(model));
        }
        public async Task <ActionResult> GetUserProfile()
        {
            var userContext = _claimService.GetUserContext();

            var query = new UserProfileQuery(userContext.Claims.OnUserId);

            return(Ok(await _dispatcher.QueryAsync(query)));
        }
Ejemplo n.º 4
0
        public async Task UserProfileQuery_Ok(long id, long userId)
        {
            var query = new UserProfileQuery(id, userId);

            var result = await fixture.QueryBus.QueryAsync(query, default);

            result.Should().NotBeNull();
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <UserProfileDto> > GetAsync(long id,
                                                                    CancellationToken token)
        {
            _userManager.TryGetLongUserId(User, out var userId);
            var query  = new UserProfileQuery(id, userId);
            var retVal = await _queryBus.QueryAsync(query, token);

            if (retVal == null)
            {
                return(NotFound());
            }
            return(retVal);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OldIndexAsync(long id, CancellationToken token)
        {
            //not really need it in here
            var query  = new UserProfileQuery(id, 0);
            var retVal = await _queryBus.QueryAsync(query, token);

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

            return(RedirectToRoutePermanent(SeoTypeString.Tutor, new
            {
                id,
                name = FriendlyUrlHelper.GetFriendlyTitle(retVal.Name)
            }));
        }
Ejemplo n.º 7
0
        public async Task <Profile> ExecuteAsync(UserProfileQuery query)
        {
            Guid userId = _principalProvider.Get().GetUserId();
            User result = await _userReader.ByIdAsync(userId);

            var profile = new Profile
            {
                Id        = result.Id,
                FirstName = result.FirstName,
                LastName  = result.LastName,
                Email     = result.Email,
                Nickname  = result.Nickname,
                IsAdmin   = result.Roles?.Contains(UserRoles.Administrator) ?? false
            };

            return(profile);
        }
Ejemplo n.º 8
0
        public async Task Should_Load_User_Profile()
        {
            UserProfileModel result;

            var author   = new User((Nickname)"authoruser", (FullName)"author user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var followed = new User((Nickname)"followeduser", (FullName)"followed user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var follower = new User((Nickname)"followeruser", (FullName)"follower user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var post     = new Post(author, (Picture)Convert.FromBase64String(DatabaseFixture.GetTestPictureBase64()), (PostText)"test post");

            using (var session = _testFixture.OpenSession(_output))
            {
                await session.SaveAsync(followed);

                await session.SaveAsync(follower);

                await session.SaveAsync(author);

                await session.SaveAsync(post);

                author.Follow(followed);
                follower.Follow(author);
                await session.FlushAsync();
            }

            var query = new UserProfileQuery(follower.ID, author.Nickname, 3);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new UserProfileQueryHandler(session, Log.Logger);
                result = await sut.Handle(query, default);
            }

            using (new AssertionScope())
            {
                result.IsCurrentUserProfile.Should().BeFalse();
                result.NumberOfFollowers.Should().Be(1);
                result.NumberOfFollows.Should().Be(1);
                result.NumberOfPosts.Should().Be(1);
                result.RecentPosts.Length.Should().Be(1);
            }
        }
Ejemplo n.º 9
0
 public async Task <Tuple <List <UserProfileListViewModel>, int> > UserProfile_Search(UserProfileQuery req)
 {
     return(await(_dbContext as Model.PunnelContext).msp_UserProfile_Search(req));
 }
Ejemplo n.º 10
0
        public async Task <Profile> Get()
        {
            var query = new UserProfileQuery();

            return(await QueryPublisher.ExecuteAsync(query));
        }