예제 #1
0
        public void GetInvites(FriendRequestViewDTO FriendRequestViewDTO, List <Request> RecievedInvites,
                               List <Request> SentInvites, IFriendsListStore _FriendListStore,
                               IUserStore _userStore, IRequestStore _RequestStore)
        {
            foreach (var Request in RecievedInvites)
            {
                var RequestUser = _RequestStore.GetRequestUserById(Request.RequestUserId);
                FriendRequestViewDTO.RecievedInvites.Add(new FriendRequestDTO()
                {
                    Id            = Request.Id,
                    RequestUserId = Request.RequestUserId,
                    FriendListId  = Request.FriendListId,
                    Pending       = Request.Pending,
                    Username      = RequestUser.Username,
                    message       = $"{RequestUser.Username} would like to be your friend."
                });
            }

            foreach (var Request in SentInvites)
            {
                var InviteeFriendsList = _FriendListStore.GetFriendListById(Request.FriendListId);
                var Invitee            = _userStore.GetByIdentityUserId(InviteeFriendsList.UserId);
                FriendRequestViewDTO.SentInvites.Add(new FriendRequestDTO()
                {
                    Id            = Request.Id,
                    RequestUserId = Request.RequestUserId,
                    FriendListId  = Request.FriendListId,
                    Pending       = Request.Pending,
                    Username      = Invitee.Username
                });
            }
        }
예제 #2
0
        public FriendRequestViewDTO Handle()
        {
            var FriendList           = FriendListStore.GetFriendListOfUser(CurrentAccount.UserId);
            var IncomingRequests     = RequestStore.GetAllRequests().FindAll(x => x.FriendListId == FriendList.Id);
            var CurrentAsRequestUser = RequestStore.GetAllRequestUsers().FirstOrDefault(x => x.UserId == CurrentUser.Id);
            var OutgoingRequests     = (CurrentAsRequestUser is null) ? new List <Request>() : RequestStore.GetAllRequests().FindAll(x => x.Username == CurrentAsRequestUser.Username);
            var FriendRequestViewDTO = new FriendRequestViewDTO();

            GetInvites(FriendRequestViewDTO, IncomingRequests, OutgoingRequests, FriendListStore, UserStore, RequestStore);
            return(FriendRequestViewDTO);
        }