private async Task RenameTagJobAsync(string uniqueKey, TagResult workingTag, string newTagId) { try { await _jobStatusNotifier.PushRenameTagJobStatusUpdate(uniqueKey, workingTag, JobStage.InProgress); // below is only needed if the current tag is null (not in DB) for some reason. update Projects / Blog Posts createsOrFinds any NEW tag var currentTagId = workingTag.Data.TagId; var currentTagCount = workingTag.Data.ArticleCount; var projectsChangedCount = await RenameTagInProjects(currentTagId, newTagId); var blogPostsChangedCount = await RenameTagInBlogPosts(currentTagId, newTagId); var deletedTagId = await _tagBL.DeleteTagByTagId(currentTagId); var newTagResult = await _tagBL.CreateOrFindByTagId(newTagId); // newTagResult.Details.Message = // $@"{currentTagId} with {currentTagCount} articles was renamed to {newTagId}. It now has {newTagResult.Data.ArticleCount} articles. Projects count: {projectsChangedCount}. Blog Posts count: {blogPostsChangedCount}."; newTagResult.Details.Message = workingTag.Data.TagId; await _jobStatusNotifier.PushRenameTagJobStatusUpdate(uniqueKey, newTagResult, JobStage.Done); } catch (Exception exception) { var currentTagId = workingTag.Data.TagId; _logger.LogError(exception, "There was a problem renaming {tagId}", currentTagId); var result = new TagResult { Details = new ResultDetails { ResultStatus = ResultStatus.Failure, Message = $"There was a problem renaming {currentTagId} to {newTagId}." } }; await _jobStatusNotifier.PushRenameTagJobStatusUpdate(uniqueKey, result, JobStage.Error); } }
public async Task <IActionResult> CreateOrFindByTagId([Required] string tagId) { var addTagResult = await _tagBL.CreateOrFindByTagId(tagId); return(Ok(addTagResult)); }