Beispiel #1
0
        /// <summary>
        /// Updates the user name in stories.
        /// </summary>
        /// <param name="updateUserFullNameModel">The update user full name model.</param>
        public async Task UpdateUserNameInStories(UpdateUserFullNameModel updateUserFullNameModel)
        {
            using var scope = serviceScopeFactory.CreateScope();
            var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();

            var getStoriesByUserIdQuery = new GetStoryByUserIdQuery(updateUserFullNameModel.Id);
            var stories = await mediator.Send(getStoriesByUserIdQuery);

            if (stories != null && stories.Any())
            {
                stories.ForEach(x => x.Author = $"{updateUserFullNameModel.FirstName} {updateUserFullNameModel.LastName}");
            }

            var updateStoriesCommand = new UpdateStoriesByUserIdCommand(updateUserFullNameModel.Id, stories);
            var response             = await mediator.Send(updateStoriesCommand);
        }
Beispiel #2
0
 /// <summary>
 /// Handles the message.
 /// </summary>
 /// <param name="updateUserFullNameModel">The update user full name model.</param>
 private void HandleMessage(UpdateUserFullNameModel updateUserFullNameModel)
 {
     userNameUpdateService.UpdateUserNameInStories(updateUserFullNameModel);
 }