Пример #1
0
        public async Task <bool> DeleteAsync(Models.Follow model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (model.Id <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(model.Id));
            }

            var success = await _followRepository.DeleteAsync(model.Id);

            if (success)
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Deleted follow with EntityId {0} UserId {1}",
                                           model.ThingId, model.CreatedUserId);
                }

                CancelTokens(model);
            }

            return(success);
        }
Пример #2
0
        public async Task <string> RemoveFollowing(string toFollowerId)
        {
            try
            {
                var findFilter = Builders <Follow> .Filter.Eq(ToId, toFollowerId);

                var following = await followRepository.FindAsync(findFilter);

                var followViewModel = mapper.Map <FollowViewModel>(following);
                await followRepository.DeleteAsync(following.Id);

                return($"{UserUnfollow}{followViewModel.ToName}");
            }
            catch (Exception)
            {
                throw new Exception(UserNotFound);
            }
        }