public void GetAllTest() { int count = _memoryDbContext.Localizations.Where(c => c.CountryId == CountryId).Count(); Assert.IsTrue(count == _localizationService.GetAll(String.Empty, String.Empty, CountryId).Count); Assert.IsTrue(_localizationService.GetAll("localizationkey", String.Empty, CountryId).Count > 0); Assert.IsTrue(_localizationService.GetAll("localizationvalue", String.Empty, CountryId).Count > 0); }
public override async Task <Languages> GetAll(Empty request, ServerCallContext context) { try { var localizationEntities = await _localizationService.GetAll(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <IEnumerable <LocalizationEntity>, Languages>() .ForMember(d => d.Value, opt => opt.MapFrom(src => src)); cfg.CreateMap <LocalizationEntity, LanguageSet>() .ForMember(d => d.LanguageSets, opt => opt.MapFrom(src => src.LanguageSets)); }); var mapper = config.CreateMapper(); mapper.ConfigurationProvider.AssertConfigurationIsValid(); return(mapper.Map <IEnumerable <LocalizationEntity>, Languages>(localizationEntities)); } catch (Exception) { return(null); } }
public IActionResult Index(string columnName, string searchString) { searchString = String.IsNullOrEmpty(searchString) ? String.Empty : searchString; columnName = String.IsNullOrEmpty(columnName) ? String.Empty : columnName; ViewData["CurrentFilter"] = searchString; ViewData["CurrentColumn"] = columnName; try { return(View(_localizationService.GetAll(columnName, searchString, CountryId))); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(NotFound().WithError(ex.Message)); } }
private void InstallLocaleResources() { if (_localizationService.GetAll().Count > 0) { return; } var contentRootPath = _hostEnvironment.ContentRootPath; foreach (var language in _languageRepo.Table.ToList()) { foreach (var filePath in System.IO.Directory.EnumerateFiles(Path.Combine(contentRootPath, "Files/Localization/"), string.Format("*.{0}.res.xml", language.UniqueSeoCode), SearchOption.TopDirectoryOnly)) { // string xmlText = File.ReadAllText(filePath); //var localizationService = ServiceLocator.Instance.GetService<ILocalizationService>(); _localizationService.ImportResourcesFromXml(language, xmlText); } } _localizationUnitOfWork.Complete(); }
public IActionResult Get() { var model = _localizationService.GetAll(); return(Ok(model)); }
public IActionResult GetResources(int languageId) { var model = _localizationService.GetAll().Where(x => x.LanguageId == languageId).ToList(); return(Ok(model)); }