Beispiel #1
0
        public async Task <List <Postage> > GetPostageFriendIdAsync(int idFriend)
        {
            var userId = _logged.GetUserLoggedId();
            var checkIfAlredyFriend = _friendsRepository
                                      .GetFriendsByFriendIdAsync(userId, idFriend)
                                      .ConfigureAwait(false);


            var postageFriend = await _postageRepository
                                .GetPostageByUserIdAsync(idFriend)
                                .ConfigureAwait(false);

            if (string.IsNullOrEmpty(checkIfAlredyFriend.ToString()))
            {
                throw new ArgumentException("Você Não tem permissão para ver as postagens deste usuário, envie uma solicitação de amizade");
            }

            if (!string.IsNullOrEmpty(postageFriend.ToString()))
            {
                return(postageFriend);
            }

            if (string.IsNullOrEmpty(postageFriend.ToString()))
            {
                throw new ArgumentException("Este usuário ainda não tem postagem");
            }


            return(default);
Beispiel #2
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");
            }
        }