Beispiel #1
0
        public IActionResult Get(string username, string categoryName)
        {
            var user = _userProfileRepository.GetByUsername(username);

            var requestingUser = GetCurrentUserProfile();


            var category = _categoryRepository.GetByCategoryName(user, categoryName);

            if (category == null || user == null)
            {
                return(NotFound());
            }
            if (category.IsPublic || requestingUser?.Id == category.UserProfileId)
            {
                var links = _linkRepository.GetByCategoryName(user, category);

                return(Ok(links));
            }

            if (requestingUser == null)
            {
                return(Unauthorized());
            }

            var requestedLinks = _linkRepository.GetRequestedLinks(requestingUser.Id, category.Id);

            return(Ok(requestedLinks));
        }