public async Task <Result <string> > SaveString(SaveStringRequestDto dto) { if (_config.IsProduction) { return(Error <string>(ResultKey.UnexpectedError)); } var stringsBlob = await _stringsResourcesService.GetStringsBlob(); var strings = stringsBlob.Strings.ToList(); var entry = strings.FirstOrDefault(x => x.Key == dto.Key) ?? CreateEntry(strings, dto.Key); foreach (var dtoTranslation in dto.Translations) { var languageCode = dtoTranslation.LanguageCode.ToLower(); if (entry.Translations.ContainsKey(languageCode)) { entry.Translations[languageCode] = dtoTranslation.Value; } else { entry.Translations.Add(languageCode, dtoTranslation.Value); } } await _stringsResourcesService.SaveStringsBlob(new StringsBlob { Strings = strings.OrderBy(x => x.Key) }); return(Success("Success")); }
public async Task <Result> SaveString([FromBody] SaveStringRequestDto dto) { var result = await _resourcesService.SaveString(dto); if (result.IsSuccess) { foreach (var translation in dto.Translations) { _inMemoryCache.Remove($"GetStrings.{translation.LanguageCode.ToLower()}"); } } return(result); }