private void TakeCareOfProp(JObject modelProp, string propKey) { var oldJValue = modelProp[propKey]; if (oldJValue == null || !(oldJValue is JValue value) || value.Type != JTokenType.String) { return; } var oldValue = modelProp[propKey].ToString(); var translation = _translationsRepository.Translate(oldValue).Result; if (translation != null) { if (translation == "empty-string") { translation = null; } modelProp[propKey] = new JValue(translation); } else { NotTranslations[oldValue] = true; } }
public override async Task <IActionResult> GetAll() { var allE = await Repo.GetAll(); var allVm = Map(allE).ToList(); foreach (var vm in allVm) { vm.Category = !string.IsNullOrEmpty(vm.Category) ? await _transRepo.Translate(vm.Category) : vm.Category; } var categories = new List <FaqCategoryViewModel>(); foreach (var faqViewModel in allVm) { var cat = categories.FirstOrDefault(c => c.Name == faqViewModel.Category); if (cat == null) { cat = new FaqCategoryViewModel { Name = faqViewModel.Category, Faqs = new List <FaqViewModel>() }; categories.Add(cat); } cat.Faqs.Add(faqViewModel); } return(Ok(categories)); }