Пример #1
0
        public async Task <ActionResult <LinkBundle> > GetLinkBundlesForUserAsync(string userId, [FromQuery] QueryOptions queryOptions)
        {
            string userHandle = _linksService.GetUserAccountEmail();

            if (string.IsNullOrEmpty(userHandle) || userHandle != userId)
            {
                return(Unauthorized());
            }

            var linkBundlesForUser = await _linksService.FindLinkBundlesForUserAsync(userId, queryOptions);

            if (!linkBundlesForUser.Any())
            {
                return(NotFound());
            }

            var results = linkBundlesForUser.Select(d => new
            {
                userId      = d.UserId,
                vanityUrl   = d.VanityUrl,
                description = d.Description,
                linkCount   = d.Links.Count.ToString()
            });

            return(Ok(results));
        }