Beispiel #1
0
        public async Task DeleteAsync(int idFriend)
        {
            var userId = _logged.GetUserLoggedId();

            var checkIfExistFriend = await _friendsRepository
                                     .GetFriendsByFriendIdAsync(userId, idFriend)
                                     .ConfigureAwait(false);

            if (checkIfExistFriend != null)
            {
                await _friendsRepository
                .DeleteAsync(checkIfExistFriend.UserId, checkIfExistFriend.UserFriendId)
                .ConfigureAwait(false);

                await _friendsRepository
                .DeleteAsync(checkIfExistFriend.UserFriendId, checkIfExistFriend.UserId)
                .ConfigureAwait(false);
            }
            if (checkIfExistFriend == null)
            {
                throw new ArgumentException("O usuário que está tentando desfazer a amizade não está na sua lista de amigos");
            }
        }