protected SearchUserResultDTO GetSearchResult(IdentityUser currentUser, UserAccount Result) { UserAccount CurrentUserAccount = _UserStore.GetByIdentityUserId(currentUser.Id); FriendList FriendList = _FriendListStore.GetFriendListOfUser(CurrentUserAccount.UserId); FriendList ResultFriendList = _FriendListStore.GetFriendListOfUser(Result.UserId); bool areFriends = _FriendListStore.IsFriendsOfUser(FriendList.Id, Result.UserId); List <Request> ResultRequests = _RequestStore.PendingRequest(ResultFriendList.Id); List <Request> CurrentUserRequests = _RequestStore.PendingRequest(FriendList.Id); Request SentByCurrent = ResultRequests.FirstOrDefault(x => x.Username == currentUser.UserName); Request SentByResult = CurrentUserRequests.FirstOrDefault(x => x.Username == Result.Username); var SearchResultDTO = new SearchUserResultDTO { Id = Result.Id, Firstname = Result.FirstName, Lastname = Result.LastName, Username = Result.Username, UserType = Result.UserType, UserId = Result.UserId, isFriendsOfCurrentUser = (areFriends is true) ? true : false, ResultUserFriendListID = ResultFriendList.Id, RequestIsPending = (areFriends is false && (SentByCurrent != null || SentByResult != null)), RequestId = (SentByCurrent != null) ? SentByCurrent.Id : new Guid(), }; GetFriendInvites(SentByCurrent, SentByResult, SearchResultDTO); return(SearchResultDTO); }
public SearchUserDTO Handle() { if (existingAccount.AccountStatus.Equals(Status.Suspended)) { signInManager.SignOutAsync(); } var AllUsers = _UserStore.GetAccounts(); var FriendList = _FriendListStore.GetFriendListOfUser(existingAccount.UserId); var CurrentUserRequests = _RequestStore.PendingRequest(FriendList.Id); return(new SearchUserDTO() { Users = GetUserDTOs(AllUsers, FriendList, CurrentUserRequests), InviteCount = CurrentUserRequests.Count }); }