/// <summary> /// Gets all the users except the user associated with the specified Id. /// </summary> /// <param name="userId"></param> /// <param name="usersToShow"></param> /// <returns></returns> public async Task <IEnumerable <UserWithRelationsDto> > GetUsers(string token) { try { string userId = await _commonOperationsManager.VerifyToken(token); string usersToShowString = ConfigurationManager.AppSettings["UsersToShow"]; int usersToShow = _commonOperationsManager.IntegerBiggerThanZero(usersToShowString); var usersToReturn = new List <UserWithRelationsDto>(); HashSet <string> usedIds = new HashSet <string>(); for (int i = 0; i < _getUsersHandlers.Length && usersToShow > 0; i++) { int usersBeforAddition = usersToReturn.Count; await _getUsersHandlers[i](usersToReturn, userId, usersToShow, usedIds); int usersAdded = usersToReturn.Count - usersBeforAddition; usersToShow -= usersAdded; } return(usersToReturn); } catch (Exception) { throw; } }
/// <summary> /// Gets the comments (with their tags) of the post associated with the post /// id extracted from the http request specified. /// </summary> /// <param name="httpRequest"></param> /// <param name="token"></param> /// <returns></returns> public async Task <IEnumerable <CommentAndTaggedUsersDto> > GetCommentsOfPost(string postId, string token) { try { await _commonOperationsManager.VerifyToken(token); string commentsToShowString = ConfigurationManager.AppSettings["CommentsToShow"]; _commonOperationsManager.VerifyString(postId); int commentsToShow = _commonOperationsManager.IntegerBiggerThanZero(commentsToShowString); return(await _postsRepository.GetCommentsOfPost(postId, commentsToShow)); } catch (Exception) { throw; } }