public async Task <Result> AddFriendAsync(Friend friend)
        {
            var result = new Result();

            try
            {
                await _repository.AddAsync(friend);

                result.ReturnInsert(friend);
            }
            catch (Exception e)
            {
                result.WithError(e.Message);
            }
            return(result);
        }
        public async Task <Result> AddNewFriend(FriendDto entity)
        {
            var result = new Result();

            try
            {
                var newFriend = _mapper.Map <Friend>(entity);
                await _repository.AddAsync(newFriend);

                result.ReturnInsert(newFriend);
            }
            catch (Exception e)
            {
                result.WithError(e.Message);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <bool> SendFriendInvitationAsync(FriendInvitationCreationVM friendInvitation)
        {
            bool addedSuccessfully = false;

            try
            {
                addedSuccessfully = await _friendRepository.AddAsync(_mapper.Map <Friend>(friendInvitation));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(false);
            }

            if (!addedSuccessfully)
            {
                throw new DataAccessException($"Sending friend invitation failed for model: {JsonConvert.SerializeObject(friendInvitation)}");
            }

            return(true);
        }