Beispiel #1
0
        public async Task <IActionResult> Put(string username, [FromBody] UpdateProfileRequestBody updateProfileRequestBody)
        {
            using (_logger.BeginScope("{Username}", username))
            {
                try
                {
                    var profile = new Profile
                    {
                        Username         = username,
                        Firstname        = updateProfileRequestBody.Firstname,
                        Lastname         = updateProfileRequestBody.Lastname,
                        ProfilePictureId = updateProfileRequestBody.ProfilePictureId
                    };

                    if (!ValidateProfile(profile, out string error))
                    {
                        _logger.LogWarning(error);
                        return(BadRequest(error));
                    }

                    var stopWatch = Stopwatch.StartNew();
                    await _profileStore.UpdateProfile(profile);

                    _telemetryClient.TrackMetric("ProfileStore.UpdateProfile.Time", stopWatch.ElapsedMilliseconds);
                    _telemetryClient.TrackEvent("ProfileUpdated");
                    return(Ok(profile));
                }
                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 update profile {username} in storage");
                    return(StatusCode(503, "The service is unavailable, please retry in few minutes"));
                }
                catch (StorageConflictException e)
                {
                    _logger.LogError(e, $"Failed to update profile {username} in storage");
                    return(StatusCode(503, "The service is unavailable, please retry in few minutes"));
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"Unknown exception occured while updating profile {username} in storage");
                    return(StatusCode(500, "An internal server error occured, please reachout to support if this error persists"));
                }
            }
        }
Beispiel #2
0
        public async Task UpdateProfile(string username, UpdateProfileRequestBody updateProfileRequestBody)
        {
            using (_logger.BeginScope("{Username}", username))
            {
                var userProfile = new UserProfile
                {
                    Username         = username,
                    FirstName        = updateProfileRequestBody.FirstName,
                    LastName         = updateProfileRequestBody.LastName,
                    ProfilePictureId = updateProfileRequestBody.ProfilePictureId
                };

                if (!ValidateProfile(userProfile, out string error))
                {
                    throw new BadRequestException(error);
                }
                var stopWatch = Stopwatch.StartNew();
                await _profileStore.UpdateProfile(userProfile);

                _telemetryClient.TrackMetric("ProfileStore.UpdateProfile.Time", stopWatch.ElapsedMilliseconds);
                _telemetryClient.TrackEvent("ProfileUpdated");
            }
        }
 public Task UpdateProfile(UserProfile profile)
 {
     return(faultTolerancePolicy.Execute(
                async() => await store.UpdateProfile(profile)
                ));
 }
Beispiel #4
0
 public Task UpdateProfile(UserProfile profile)
 {
     return(updateProfileMetric.TrackTime(() => store.UpdateProfile(profile)));
 }
 public async Task UpdateProfile(UserProfile profile)
 {
     await resiliencyPolicy.ExecuteAsync(() => profileStore.UpdateProfile(profile));
 }
 public Task UpdateProfile(UserProfile profile)
 {
     return(store.UpdateProfile(profile));
 }
Beispiel #7
0
 public Task UpdateProfile(Profile profile)
 {
     return(_profileStore.UpdateProfile(profile));
 }