Exemplo n.º 1
0
        public async Task <IActionResult> AcceptFriendRequest(Guid id)
        {
            var command = new AcceptFriendRequestCommand(id);
            var result  = await _mediator.Send(command);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
        public FriendListViewModel CreateFriendListViewModel(FriendList friendList, Action refreshFriendListAction)
        {
            var friendListViewModel = new FriendListViewModel()
            {
                FriendListItems = new ObservableCollection <FriendListItem>()
            };

            var acceptFriendCommand = new AcceptFriendRequestCommand(friendListViewModel, refreshFriendListAction, _friendService, _logger);
            var removeFriendCommand = new RemoveFriendCommand(friendListViewModel, refreshFriendListAction, _friendService, _logger);

            foreach (var incomingRequest in friendList.IncomingRequests)
            {
                friendListViewModel.FriendListItems.Add(MapFriendRequestToViewModel(incomingRequest, acceptFriendCommand, removeFriendCommand));
            }

            foreach (var friend in friendList.Friends.Where(t => t.IsOnline))
            {
                friendListViewModel.FriendListItems.Add(MapFriendToViewModel(friend, removeFriendCommand));
            }

            foreach (var friend in friendList.Friends.Where(t => !t.IsOnline))
            {
                friendListViewModel.FriendListItems.Add(MapFriendToViewModel(friend, removeFriendCommand));
            }

            friendListViewModel.FriendListItems.Add(new FriendListSeparator());

            foreach (var outgoingRequest in friendList.OutgoingRequests)
            {
                friendListViewModel.FriendListItems.Add(MapOutoingFriendRequest(outgoingRequest, removeFriendCommand));
            }

            friendListViewModel.OnlineFriendsCount = friendListViewModel.FriendListItems.Count(t => t is OnlineFriend);
            friendListViewModel.FriendListCount    = friendList.Friends.Count;

            return(friendListViewModel);
        }