예제 #1
0
 public async Task DisposeAsync()
 {
     try
     {
         await _profileStore.DeleteProfile(_profile.Username); // cleanup the store
     }
     catch (ProfileNotFoundException)
     {
         // profile was already deleted in the test
     }
 }
예제 #2
0
        public async Task <IActionResult> Delete(string username)
        {
            using (_logger.BeginScope("{Username}", username))
            {
                if (string.IsNullOrWhiteSpace(username))
                {
                    return(BadRequest("The username must not be empty or null"));
                }
                try
                {
                    var stopWatch = Stopwatch.StartNew();
                    await _profileStore.DeleteProfile(username);

                    _telemetryClient.TrackMetric("ProfileStore.DeleteProfile.Time", stopWatch.ElapsedMilliseconds);
                    _telemetryClient.TrackEvent("ProfileDeleted");
                    return(Ok(username));
                }
                catch (ProfileNotFoundException e)
                {
                    _logger.LogError(e, $"Profile {username} does not exists in storage");
                    return(NotFound($"The profile with username {username} was not found"));
                }
                catch (StorageErrorException e)
                {
                    _logger.LogError(e, $"Failed to delete profile {username} from storage");
                    return(StatusCode(503, "The service is unavailable, please retry in few minutes"));
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"Unknown exception occured while deleting profile {username} from storage");
                    return(StatusCode(500, "An internal server error occured, please reachout to support if this error persists"));
                }
            }
        }
예제 #3
0
        public async Task DeleteProfile(string username)
        {
            using (_logger.BeginScope("{Username}", username))
            {
                var stopWatch = Stopwatch.StartNew();
                await _profileStore.DeleteProfile(username);

                _telemetryClient.TrackMetric("ProfileStore.DeleteProfile.Time", stopWatch.ElapsedMilliseconds);
                _telemetryClient.TrackEvent("ProfileDeleted");
            }
        }
예제 #4
0
        public async Task DeleteProfile(Guid profileId, CancellationToken cancellationToken)
        {
            Ensure.Guid.IsNotEmpty(profileId, nameof(profileId));

            var profile = await _store.GetProfile(profileId, cancellationToken).ConfigureAwait(false);

            if (profile == null)
            {
                return;
            }

            // We will mark the profile (in memory) as hidden here so that the hide profile logic
            // will ensure that the profile is not added back into the profile results cache
            profile.Status = ProfileStatus.Hidden;

            // Remove all the category links, profile cache and profile results cache entries related
            // to this profile
            await HideProfile(profile, cancellationToken).ConfigureAwait(false);

            await _store.DeleteProfile(profileId, cancellationToken).ConfigureAwait(false);
        }
예제 #5
0
 public Task DeleteProfile(string username)
 {
     return(_profileStore.DeleteProfile(username));
 }